Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Commit f0e1ec2

Browse files
make the module exports a convenience function so minifying src with the defaults is just a one-lininer: min = require('uglify-js')(src);
I am unfamiliar with the documentation generator you use, so I did not update the README. Addresses Issue 132.
1 parent 6e89f5b commit f0e1ec2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

uglify-js.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
exports.parser = require("./lib/parse-js");
2-
exports.uglify = require("./lib/process");
1+
//convienence function(src, [options]);
2+
function uglify(orig_code, options){
3+
options || (options = {});
4+
var jsp = uglify.parser;
5+
var pro = uglify.uglify;
6+
7+
var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST
8+
ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names
9+
ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations
10+
var final_code = pro.gen_code(ast, options.gen_options); // compressed code here
11+
return final_code;
12+
};
13+
14+
uglify.parser = require("./lib/parse-js");
15+
uglify.uglify = require("./lib/process");
16+
17+
module.exports = uglify

0 commit comments

Comments
 (0)