Skip to content

Instantly share code, notes, and snippets.

@juanpicado
Created March 20, 2016 17:24
Show Gist options
  • Save juanpicado/a17bdb5da0c83ef9f0b6 to your computer and use it in GitHub Desktop.
Save juanpicado/a17bdb5da0c83ef9f0b6 to your computer and use it in GitHub Desktop.
Esprima and Escope
var escope = require('escope');
var esprima = require('esprima');
var estraverse = require('estraverse');
var code = require('./ast');
var ast = code.esprimaAST();
var scopeManager = escope.analyze(ast);
var scopes = scopeManager.scopes;
// return an array of scopes, in our example we have 2, the global and inside of the function
var currentScope = scopeManager.acquire(ast);
// return the global scope, the current one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment