$ cnpm install free-variables
Get a list of free variables used in a JS program. A free variable is one which is used but not declared.
With your favorite package manager:
packin add free-variablescomponent install jkroso/free-variablesnpm install free-variablesthen in your app:
var free = require('free-variables')
Takes any standard JS AST and returns and Array of String's
var parse = require('esprima').parse
free(parse('console.log')) // => ['console']
free(parse('console[log]')) // => ['console', 'log']
free(parse('function b(){a}')) // => ['a']
free(parse('var a = 1; a + b')) // => ['b']
free(parse('a; var a')) // => []
Copyright 2013 - present © cnpmjs.org | Home |