[Pkg-javascript-commits] [uglifyjs] 180/190: Add Node API documentation for mangling options

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit 030611b729af46d2239bd09c95f88e708660f254
Author: iliashk <ilia at tsaver.co.il>
Date:   Sat Jun 25 11:48:39 2016 +0300

    Add Node API documentation for mangling options
---
 README.md | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 2ab9de6..7262ef8 100644
--- a/README.md
+++ b/README.md
@@ -661,7 +661,8 @@ Other options:
 - `fromString` (default `false`) — if you pass `true` then you can pass
   JavaScript source code, rather than file names.
 
-- `mangle` — pass `false` to skip mangling names.
+- `mangle` (default `true`) — pass `false` to skip mangling names, or pass
+  an object to specify mangling options (see below).
 
 - `mangleProperties` (default `false`) — pass an object to specify custom
   mangle property options.
@@ -680,6 +681,32 @@ Other options:
 
  - `except` - pass an array of identifiers that should be excluded from mangling
 
+ - `toplevel` — mangle names declared in the toplevel scope (disabled by
+  default).
+
+  - `eval` — mangle names visible in scopes where eval or with are used
+  (disabled by default).
+
+  Examples:
+
+  ```javascript
+  //tst.js
+  var globalVar;
+  function funcName(firstLongName, anotherLongName)
+  {
+    var myVariable = firstLongName +  anotherLongName;
+  }
+
+  UglifyJS.minify("tst.js").code;
+  // 'function funcName(a,n){}var globalVar;'
+
+  UglifyJS.minify("tst.js", { mangle: { except: ['firstLongName'] }}).code;
+  // 'function funcName(firstLongName,a){}var globalVar;'
+
+  UglifyJS.minify("tst.js", { mangle: toplevel: true }}).code;
+  // 'function n(n,a){}var a;'
+  ```
+
 ##### mangleProperties options
 
  - `regex` — Pass a RegExp to only mangle certain names (maps to the `--mangle-regex` CLI arguments option)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list