JSPM

es-lookup-scope

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27688
  • Score
    100M100P100Q158641F
  • License MIT

Look up the scoop of an estree compatible node

Package Exports

  • es-lookup-scope

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (es-lookup-scope) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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));
    }
});