Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (declar) return declar;
const generator = this.get("helperGenerator");
const runtime = this.get("helpersNamespace");
if (generator) {
const res = generator(name);
if (res) return res;
} else if (runtime) {
return t.memberExpression(runtime, t.identifier(name));
}
const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
name,
));
const { nodes, globals } = getHelper(
name,
name => this.addHelper(name),
uid,
() => Object.keys(this.scope.getAllBindings()),
);
globals.forEach(name => {
if (this.path.scope.hasBinding(name, true /* noGlobals */)) {
this.path.scope.rename(name);
}
});
nodes.forEach(node => {
node._compact = true;
});
if (!this.usedHelpers[name]) {
this.metadata.usedHelpers.push(name);
this.usedHelpers[name] = true;
}
const generator = this.get("helperGenerator");
const runtime = this.get("helpersNamespace");
if (generator) {
const res = generator(name);
if (res) return res;
} else if (runtime) {
return t.memberExpression(runtime, t.identifier(name));
}
const ref = getHelper(name);
const uid = this.declarations[name] = this.scope.generateUidIdentifier(name);
if (t.isFunctionExpression(ref) && !ref.id) {
ref.body._compact = true;
ref._generated = true;
ref.id = uid;
ref.type = "FunctionDeclaration";
this.path.unshiftContainer("body", ref);
} else {
ref._compact = true;
this.scope.push({
id: uid,
init: ref,
unique: true
});
}
if (!this.usedHelpers[name]) {
this.metadata.usedHelpers.push(name);
this.usedHelpers[name] = true;
}
let generator = this.store.get("helperGenerator");
let runtime = this.store.get("helpersNamespace");
if (generator) {
let res = generator(name);
if (res) return res;
} else if (runtime) {
return t.memberExpression(runtime, t.identifier(name));
}
let ref = getHelper(name);
let uid = this.declarations[name] = this.scope.generateUidIdentifier(name);
if (t.isFunctionExpression(ref) && !ref.id) {
ref.body._compact = true;
ref._generated = true;
ref.id = uid;
ref.type = "FunctionDeclaration";
this.path.unshiftContainer("body", ref);
} else {
ref._compact = true;
this.scope.push({
id: uid,
init: ref,
unique: true
});
}