Skip to content

Instantly share code, notes, and snippets.

@juanpicado
Last active March 20, 2016 18:51
Show Gist options
  • Save juanpicado/03671095fb18e5fbb650 to your computer and use it in GitHub Desktop.
Save juanpicado/03671095fb18e5fbb650 to your computer and use it in GitHub Desktop.
esrefactor example
var esrefactor = require('esrefactor');
var code = require('./ast');
// function bar(){ var a; console.log("foo", a);}
var ctx = new esrefactor.Context(code.codeVariable);
var id = ctx.identify(21);
console.log("id", id);
//id { identifier: { type: 'Identifier', name: 'a', range: [ 20, 21 ] },
// declaration: { type: 'Identifier', name: 'a', range: [ 20, 21 ] },
// references: [ { type: 'Identifier', name: 'a', range: [Object] } ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment