isoscope

ECMAScript function isolation analyzer

isoscope

ECMAScript function isolation analyzer. This is project is very alpha but intention is to provide API for performing static analyzes on the nodes of the JS AST in the de facto syntax tree format. All the API function take AST nodes denoting a function definition / declaration and perform static analyzes on it.

Function takes AST node that represents a scope (function declaration / expression) form and returns array of identifier names for all the enclosed references.

var esprima = require("esprima")
var enclosed = require("isoscope/enclosed")
 
// Parse some code 
var form = esprima.parse(String(function fn(ab) {
  console.log(String(a) + b)
}))
 
// Get a function form we'll be analyzing 
var fn = form.body[0]
fn.id
// => { type: "Identifier", name: "fn" } 
 
// Get names of enclosed references 
enclosed(fn)
// => [ "console", "String" ] 
npm install isoscope