node-modules/esmangle

Name: esmangle

Owner: node_modules

Description: esmangle is mangler / minifier for Mozilla Parser API AST

Created: 2015-10-21 13:41:26.0

Updated: 2015-10-21 13:46:12.0

Pushed: 2015-10-29 03:52:47.0

Homepage: https://estools.github.io/esmangle/

Size: 1410

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

esmangle NPM version Build Status Dependency Status

esmangle (esmangle) is mangler / minifier for Parser API AST.

Install

esmangle can be used in a web browser: Download

ipt src="esmangle.js"></script>

Node.js application via the package manager:

install esmangle

If you would like to use latest esmangle in a browser, you can build build/esmangle.min.js:

run-script build
Usage

A simple example: the program

ast = esprima.parse(code);
result = esmangle.mangle(ast);  // gets mangled AST
ole.log(escodegen.generate(result));  // dump AST

Or you can simply use this esmangle command in the shell.

mangle file.js

Get more compressed result: (in Node.js)

ast = esprima.parse(code);
et optimized AST
optimized = esmangle.optimize(ast, null);
ets mangled AST
result = esmangle.mangle(optimized);
ole.log(escodegen.generate(result, {
format: {
    renumber: true,
    hexadecimal: true,
    escapeless: true,
    compact: true,
    semicolons: false,
    parentheses: false
}
  // dump AST
Design

Slide is here. This resolution algorithm is based on my bytecode compiler iv / lv5 / railgun.

License

Copyright © 2012 Yusuke Suzuki (twitter: @Constellation) and other contributors.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.