@sudoo/marked
Version:
JavaScript & TypeScript code runner in JavaScript, safe with marked territory, asynchronous
27 lines (26 loc) • 937 B
JavaScript
;
/**
* @author WMXPY
* @namespace Operation_FunctionExpression
* @description Params Register
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerFunctionExpressionParams = registerFunctionExpressionParams;
const variable_1 = require("../../declare/variable");
function registerFunctionExpressionParams(args, params, scope) {
loop: for (let i = 0; i < params.length; i++) {
const pattern = params[i];
const index = i;
const registerer = scope.register(variable_1.VARIABLE_TYPE.CONSTANT);
if (pattern.type === "Identifier") {
const value = args[index];
registerer(pattern.name, value);
}
else if (pattern.type === "RestElement") {
const identifier = pattern.argument;
const value = args.slice(index);
registerer(identifier.name, value);
break loop;
}
}
}