Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (state !== ST_INSIDE_CALL && token.type === acorn.tokTypes.dot) {
state = ST_MEMBER_EXPRESSION;
} else if (state === ST_NONE && token.type === acorn.tokTypes.name && mayBeRequire(token)) {
state = ST_SAW_NAME;
opener = token;
} else if (state === ST_SAW_NAME && token.type === acorn.tokTypes.parenL) {
state = ST_INSIDE_CALL;
args = [];
} else if (state === ST_INSIDE_CALL) {
if (token.type === acorn.tokTypes.parenR) { // End of fn() call
if (args.length === 1 && args[0].type === acorn.tokTypes.string) {
modules.strings.push(args[0].value);
} else if (args.length === 3 // A template string without any expressions
&& args[0].type === acorn.tokTypes.backQuote
&& args[1].type === acorn.tokTypes.template
&& args[2].type === acorn.tokTypes.backQuote) {
modules.strings.push(args[1].value);
} else if (args.length > 0) {
modules.expressions.push(src.slice(args[0].start, args[args.length - 1].end));
}
if (opts.nodes) {
// Cut `src` at the end of this call, so that parseExpressionAt doesn't consider the `.abc` in
// `require('xyz').abc`
var chunk = src.slice(0, token.end);
var node = acorn.parseExpressionAt(chunk, opener.start, opts.parse);
modules.nodes.push(node);
}
state = ST_NONE;
} else {
function (token) { return token.type === acorn.tokTypes.num || token.type === acorn.tokTypes.string; }, // 0
function (token) { return token.type === acorn.tokTypes.colon; }, // :
function mayBeRequire(token) {
return token.type === acorn.tokTypes.name &&
token.value === opts.word;
}
}