npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

hoister

0.0.2 • Public • Published

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;
= func(123);
var a = 'test';

Keywords

none

install

npm i hoister

Downloadsweekly downloads

1,840

version

0.0.2

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability