@next-core/cook 1.9.20 → 1.9.22
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 +16 -5
- package/dist/cjs/cook.js.map +1 -1
- package/dist/cjs/interfaces.js.map +1 -1
- package/dist/cjs/precookFunction.js +15 -3
- package/dist/cjs/precookFunction.js.map +1 -1
- package/dist/cjs/preevaluate.js +17 -3
- package/dist/cjs/preevaluate.js.map +1 -1
- package/dist/esm/cook.js +16 -5
- package/dist/esm/cook.js.map +1 -1
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/precookFunction.js +16 -5
- package/dist/esm/precookFunction.js.map +1 -1
- package/dist/esm/preevaluate.js +20 -3
- package/dist/esm/preevaluate.js.map +1 -1
- package/dist/types/cook.d.ts +1 -0
- package/dist/types/interfaces.d.ts +1 -0
- package/dist/types/precookFunction.d.ts +4 -2
- package/dist/types/preevaluate.d.ts +6 -3
- package/package.json +2 -2
package/dist/cjs/cook.js
CHANGED
|
@@ -133,6 +133,8 @@ function cook(rootAst, codeSource, {
|
|
|
133
133
|
// Currently unicode flag is not fully supported across major browsers.
|
|
134
134
|
throw new SyntaxError(`Unsupported unicode flag in regular expression: ${node.raw}`);
|
|
135
135
|
}
|
|
136
|
+
// Always create a new RegExp, because the AST will be reused.
|
|
137
|
+
return (0, _ExecutionContext.NormalCompletion)(new RegExp(node.regex.pattern, node.regex.flags));
|
|
136
138
|
}
|
|
137
139
|
return (0, _ExecutionContext.NormalCompletion)(node.value);
|
|
138
140
|
}
|
|
@@ -1114,8 +1116,8 @@ function cook(rootAst, codeSource, {
|
|
|
1114
1116
|
}
|
|
1115
1117
|
|
|
1116
1118
|
// https://tc39.es/ecma262/#sec-runtime-semantics-instantiatefunctionobject
|
|
1117
|
-
function InstantiateFunctionObject(func, scope) {
|
|
1118
|
-
return OrdinaryFunctionCreate(func, scope, true);
|
|
1119
|
+
function InstantiateFunctionObject(func, scope, isRoot) {
|
|
1120
|
+
return OrdinaryFunctionCreate(func, scope, true, isRoot);
|
|
1119
1121
|
}
|
|
1120
1122
|
|
|
1121
1123
|
// https://tc39.es/ecma262/#sec-runtime-semantics-instantiateordinaryfunctionexpression
|
|
@@ -1142,10 +1144,19 @@ function cook(rootAst, codeSource, {
|
|
|
1142
1144
|
}
|
|
1143
1145
|
|
|
1144
1146
|
// https://tc39.es/ecma262/#sec-ordinaryfunctioncreate
|
|
1145
|
-
function OrdinaryFunctionCreate(sourceNode, scope, isConstructor) {
|
|
1147
|
+
function OrdinaryFunctionCreate(sourceNode, scope, isConstructor, isRoot) {
|
|
1146
1148
|
const F = function () {
|
|
1149
|
+
const perf = isRoot && hooks.perfCall;
|
|
1150
|
+
let start;
|
|
1151
|
+
if (perf) {
|
|
1152
|
+
start = performance.now();
|
|
1153
|
+
}
|
|
1147
1154
|
// eslint-disable-next-line prefer-rest-params
|
|
1148
|
-
|
|
1155
|
+
const result = CallFunction(F, arguments);
|
|
1156
|
+
if (perf) {
|
|
1157
|
+
perf(performance.now() - start);
|
|
1158
|
+
}
|
|
1159
|
+
return result;
|
|
1149
1160
|
};
|
|
1150
1161
|
Object.defineProperties(F, {
|
|
1151
1162
|
[_ExecutionContext.SourceNode]: {
|
|
@@ -1361,7 +1372,7 @@ function cook(rootAst, codeSource, {
|
|
|
1361
1372
|
const [fn] = (0, _traverse.collectBoundNames)(rootAst);
|
|
1362
1373
|
// Create an immutable binding for the root function.
|
|
1363
1374
|
rootEnv.CreateImmutableBinding(fn, true);
|
|
1364
|
-
const fo = InstantiateFunctionObject(rootAst, rootEnv);
|
|
1375
|
+
const fo = InstantiateFunctionObject(rootAst, rootEnv, true);
|
|
1365
1376
|
rootEnv.InitializeBinding(fn, fo);
|
|
1366
1377
|
return fo;
|
|
1367
1378
|
}
|