Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
helpers.list.forEach(function (name) {
if (whitelist && whitelist.indexOf(name) < 0) return;
const key = t.identifier(name);
// AST tree for: objectMember.helperName = function () { ... }
body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier('babelHelpers'), key), helpers.get(name))));
});
}
getUsedMethods({exclude}={}){
if (!Array.isArray(exclude)) {
exclude = [];
}
let ret = [];
for (let name of this.usedHelpers) {
if (exclude.indexOf(name) == -1) {
let METHOD = this._definedHelpers[name] || babelHelpers.get(name);
ret.push(helperDefineTemplate({
METHOD_NAME: Identifier(name),
METHOD
}))
}
}
return ret;
}
helpers.list.forEach(function(helperName) {
var tree = t.program([
t.exportDefaultDeclaration(helpers.get(helperName))
]);
fs.writeFileSync('../babel-helpers/' + helperName + '.js', babel.transformFromAst(tree).code);
});
each(helpers.list, function (name) {
if (whitelist && whitelist.indexOf(name) < 0) return;
let key = t.identifier(name);
body.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(namespace, key), helpers.get(name))
));
});
}
list.forEach( function(fn){
if (whitelist && whitelist.indexOf(fn) < 0) return;
callback(fn, bh.get(fn));
});
}
function buildGlobal(namespace, builder) {
let body = [];
let container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
let tree = t.program([t.expressionStatement(t.callExpression(container, [helpers.get("selfGlobal")]))]);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(
namespace,
t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([]))
)
]));
builder(body);
return tree;
}