Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function findFast(src, opts) {
if (!opts) opts = {};
if (typeof src !== 'string') src = String(src);
if (opts.word === undefined) opts.word = 'require';
var tokenizer = acorn.tokenizer(src, opts.parse);
var token;
var state = ST_NONE;
// Current index in the require redefinition pattern.
var redefIndex = 0;
// Block scope depth when require was redefined. This is used to match the
// correct } with the opening { after the redefining function parameter list.
var redefDepth = 0;
var opener;
var args = [];
var modules = { strings: [], expressions: [] };
if (opts.nodes) modules.nodes = [];
while ((token = tokenizer.getToken()) && token.type !== acorn.tokTypes.eof) {
if (state === ST_REDEFINED) {