mirror of
https://github.com/yt-dlp/ejs.git
synced 2026-06-26 08:08:45 +00:00
Rename nsig -> n
This commit is contained in:
@@ -9,7 +9,7 @@ export default function main(input: Input): Output {
|
||||
|
||||
const responses = input.requests.map(
|
||||
(input): Response => {
|
||||
if (!isOneOf(input.type, "nsig", "sig")) {
|
||||
if (!isOneOf(input.type, "n", "sig")) {
|
||||
return {
|
||||
type: "error",
|
||||
error: `Unknown request type: ${input.type}`,
|
||||
@@ -64,7 +64,7 @@ export type Input =
|
||||
};
|
||||
|
||||
type Request = {
|
||||
type: "nsig" | "sig";
|
||||
type: "n" | "sig";
|
||||
challenges: string[];
|
||||
};
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ function makeSolverFuncFromName(name: string): ESTree.ArrowFunctionExpression {
|
||||
params: [
|
||||
{
|
||||
type: "Identifier",
|
||||
name: "nsig",
|
||||
name: "n",
|
||||
},
|
||||
],
|
||||
body: {
|
||||
@@ -128,7 +128,7 @@ function makeSolverFuncFromName(name: string): ESTree.ArrowFunctionExpression {
|
||||
arguments: [
|
||||
{
|
||||
type: "Identifier",
|
||||
name: "nsig",
|
||||
name: "n",
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
@@ -11,7 +11,7 @@ for (const test of tests) {
|
||||
await io.test(`${test.player} ${variant}`, async (assert, subtest) => {
|
||||
const content = await io.read(path);
|
||||
const solvers = getFromPrepared(preprocessPlayer(content));
|
||||
for (const mode of ["nsig", "sig"] as const) {
|
||||
for (const mode of ["n", "sig"] as const) {
|
||||
for (const step of test[mode] || []) {
|
||||
await subtest(`${step.input} (${mode})`, () => {
|
||||
const got = solvers[mode]?.(step.input);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type ESTree, parse } from "meriyah";
|
||||
import { generate } from "astring";
|
||||
import { extract as extractSig } from "./sig.ts";
|
||||
import { extract as extractNsig } from "./nsig.ts";
|
||||
import { extract as extractN } from "./n.ts";
|
||||
import { setupNodes } from "./setup.ts";
|
||||
|
||||
export function preprocessPlayer(data: string): string {
|
||||
@@ -41,13 +41,13 @@ export function preprocessPlayer(data: string): string {
|
||||
})();
|
||||
|
||||
const found = {
|
||||
nsig: [] as ESTree.ArrowFunctionExpression[],
|
||||
n: [] as ESTree.ArrowFunctionExpression[],
|
||||
sig: [] as ESTree.ArrowFunctionExpression[],
|
||||
};
|
||||
const plainExpressions = block.body.filter((node: ESTree.Node) => {
|
||||
const nsig = extractNsig(node);
|
||||
if (nsig) {
|
||||
found.nsig.push(nsig);
|
||||
const n = extractN(node);
|
||||
if (n) {
|
||||
found.n.push(n);
|
||||
}
|
||||
const sig = extractSig(node);
|
||||
if (sig) {
|
||||
@@ -101,10 +101,10 @@ export function preprocessPlayer(data: string): string {
|
||||
}
|
||||
|
||||
export function getFromPrepared(code: string): {
|
||||
nsig: ((val: string) => string) | null;
|
||||
n: ((val: string) => string) | null;
|
||||
sig: ((val: string) => string) | null;
|
||||
} {
|
||||
const resultObj = { nsig: null, sig: null };
|
||||
const resultObj = { n: null, sig: null };
|
||||
Function("_result", code)(resultObj);
|
||||
return resultObj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user