Skip to content

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

Notifications You must be signed in to change notification settings

GravityNetwork/hoister

This branch is 1 commit behind mmckegg/hoister:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a784145 · Feb 8, 2018

History

7 Commits
Nov 25, 2013
Nov 25, 2013
Nov 25, 2013
Feb 8, 2018
Nov 26, 2013

Repository files navigation

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';

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%