es-lookup-scope

Look up the scoop of an estree compatible node

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
es-lookup-scope
111.0.19 years ago9 years agoMinified + gzip package size for es-lookup-scope in KB

Readme

es-lookup-scope
Travis build status Code Climate Test Coverage Dependency Status devDependency Status
Using escope we find the scope of any estree compatible AST node.
import {parse} from 'acorn';
import lookup from 'es-lookup-scope';
import {traverse} from 'estraverse'

let ast = parse(`
      (function() {
        const x = 2;
        try {
          const x = 1;
          [1, 2, 3].map(x => x);
        } catch(o_O) {}
        console.log(x);
      })();
      module.exports = {
        x() {
          let y = this;
          console.log(y);
        }
      }
    `, { ecmaVersion: 6});
    
traverse(ast, {
    enter(node) {
        console.log(lookup(node));
    }
});