@next-core/cook 2.4.4 → 2.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cook.js +22 -2
- package/dist/cjs/cook.js.map +1 -1
- package/dist/esm/cook.js +22 -2
- package/dist/esm/cook.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/cook.js
CHANGED
|
@@ -28,7 +28,7 @@ function cook(rootAst, codeSource, {
|
|
|
28
28
|
ArrayConstructor = Array,
|
|
29
29
|
hooks = {}
|
|
30
30
|
} = {}) {
|
|
31
|
-
var _hooks$
|
|
31
|
+
var _hooks$beforeEvaluate4;
|
|
32
32
|
const expressionOnly = rootAst.type !== "FunctionDeclaration";
|
|
33
33
|
function doSanitize(cooked) {
|
|
34
34
|
if (!externalSourceForDebug) {
|
|
@@ -1144,6 +1144,8 @@ function cook(rootAst, codeSource, {
|
|
|
1144
1144
|
|
|
1145
1145
|
// https://tc39.es/ecma262/#sec-runtime-semantics-namedevaluation
|
|
1146
1146
|
function NamedEvaluation(node, name) {
|
|
1147
|
+
var _hooks$beforeEvaluate3;
|
|
1148
|
+
(_hooks$beforeEvaluate3 = hooks.beforeEvaluate) === null || _hooks$beforeEvaluate3 === void 0 || _hooks$beforeEvaluate3.call(hooks, node);
|
|
1147
1149
|
// No ParenthesizedExpression in ESTree.
|
|
1148
1150
|
switch (node.type) {
|
|
1149
1151
|
case "FunctionExpression":
|
|
@@ -1366,6 +1368,11 @@ function cook(rootAst, codeSource, {
|
|
|
1366
1368
|
value: lexicalThis ? _ExecutionContext.Mode.LEXICAL : _ExecutionContext.Mode.STRICT
|
|
1367
1369
|
}
|
|
1368
1370
|
});
|
|
1371
|
+
const len = ExpectedArgumentCount(sourceNode.params);
|
|
1372
|
+
Object.defineProperty(F, "length", {
|
|
1373
|
+
configurable: true,
|
|
1374
|
+
value: len
|
|
1375
|
+
});
|
|
1369
1376
|
if (debug || externalSourceForDebug) {
|
|
1370
1377
|
Object.defineProperty(F, _ExecutionContext.DebuggerCall, {
|
|
1371
1378
|
value: function () {
|
|
@@ -1376,6 +1383,19 @@ function cook(rootAst, codeSource, {
|
|
|
1376
1383
|
}
|
|
1377
1384
|
return F;
|
|
1378
1385
|
}
|
|
1386
|
+
function ExpectedArgumentCount(params) {
|
|
1387
|
+
let count = 0;
|
|
1388
|
+
for (const param of params) {
|
|
1389
|
+
switch (param.type) {
|
|
1390
|
+
case "AssignmentPattern":
|
|
1391
|
+
case "RestElement":
|
|
1392
|
+
return count;
|
|
1393
|
+
default:
|
|
1394
|
+
count++;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
return count;
|
|
1398
|
+
}
|
|
1379
1399
|
|
|
1380
1400
|
// Patterns initialization.
|
|
1381
1401
|
// https://tc39.es/ecma262/#sec-runtime-semantics-bindinginitialization
|
|
@@ -1572,7 +1592,7 @@ function cook(rootAst, codeSource, {
|
|
|
1572
1592
|
if (expressionOnly) {
|
|
1573
1593
|
return (0, _contextFree.GetValue)(unwind(Evaluate(rootAst)));
|
|
1574
1594
|
}
|
|
1575
|
-
(_hooks$
|
|
1595
|
+
(_hooks$beforeEvaluate4 = hooks.beforeEvaluate) === null || _hooks$beforeEvaluate4 === void 0 || _hooks$beforeEvaluate4.call(hooks, rootAst);
|
|
1576
1596
|
ThrowIfFunctionIsInvalid(rootAst);
|
|
1577
1597
|
const [fn] = (0, _traverse.collectBoundNames)(rootAst);
|
|
1578
1598
|
// Create an immutable binding for the root function.
|