hoister

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

2 个版本
安装
npm install hoister
yarn add hoister
pnpm add hoister
bun add hoister
README

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';
版本列表
0.0.2 2013-11-26
0.0.1 2013-11-25