How to use the acorn-node.tokenizer function in acorn-node

To help you get started, we’ve selected a few acorn-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github browserify / detective / find-fast.js View on Github external
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) {

acorn-node

the acorn javascript parser, preloaded with plugins for syntax parity with recent node versions

Apache-2.0
Latest version published 4 years ago

Package Health Score

68 / 100
Full package analysis