Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (t.isObjectProperty(node) || t.isClassProperty(node)) {
value = node.value;
} else if (t.isObjectMethod(node) || t.isClassMethod(node)) {
value = t.functionExpression(null, node.params, node.body, node.generator, node.async);
}
let inheritedKind = toKind(node);
if (!kind || inheritedKind !== "value") {
kind = inheritedKind;
}
// infer function name
if (scope && t.isStringLiteral(key) && (kind === "value" || kind === "initializer") && t.isFunctionExpression(value)) {
value = nameFunction({ id: key, node: value, scope });
}
if (value) {
t.inheritsComments(value, node);
map[kind] = value;
}
return map;
}
}).expression;
if (isDeclaration) {
const declar = t.variableDeclaration('let', [
t.variableDeclarator(
t.identifier(asyncFnId.name),
t.callExpression(container, [])
),
]);
declar._blockHoist = true;
path.replaceWith(declar);
} else {
const retFunction = container.body.body[1].argument;
if (!asyncFnId) {
nameFunction({
node: retFunction,
parent: path.parent,
scope: path.scope,
});
}
if (!retFunction || retFunction.id || node.params.length) {
// we have an inferred function id or params so we need this wrapper
path.replaceWith(t.callExpression(container, []));
} else {
// we can omit this wrapper as the conditions it protects for do not apply
path.replaceWith(built);
}
}
}
function coverFunction (path) {
if (!path.node.loc) return
const node = path.node
const data = getData(this)
const id = String(data.nextId.f++)
const nameOf = (namedNode) => namedNode && namedNode.id && namedNode.id.name || null
data.base.f[id] = 0
data.base.fnMap[id] = {
name: nameOf(nameFunction(path)), // I love Babel!
line: node.loc.start.line,
loc: locToObject(node.loc)
}
const increment = increase(this, 'f', id)
const body = path.get('body')
if (body.isBlockStatement()) {
body.node.body.unshift(t.expressionStatement(increment))
} else if (body.isExpression()) {
const sid = nextStatementId(this, body.node.loc || path.node.loc)
body.replaceWith(t.sequenceExpression([
increment,
increase(this, 's', sid),
body.node
]))
} else {
throw new Error(`wtf?? Can’t cover function with ${body.node.type}`)
ClassExpression: function ClassExpression(path, file) {
var inferred = _babelHelperFunctionName.bare(path);
if (inferred) return inferred;
if (file.isLoose("es6.classes")) {
return new _loose2["default"](path, file).run();
} else {
return new _vanilla2["default"](path, file).run();
}
}
};