hoister

v0.0.2
Put all function and variable declarations at the top of the scope in an AST
ast hoist esprima javascript

hoister

Put all function and variable declarations at the top of the scope in an AST

NPM

Example

var parse = require('esprima').parse
var generate = require('escodegen').generate
var hoist = require('hoist')

var src = 'a = func(123); var a = "test"; function func(x){return x}'
var ast = parse(src)
hoist(ast)

console.log(generate(ast))

Console result:

function func(x) {
  return x;
}
var a;
a = func(123);
var a = 'test';
npm i hoister

Metadata

  • MIT
  • Whatever
  • Matt McKegg
  • released 11/26/2013

Downloads

Maintainers