Add Node API documentation for mangling options
authoriliashk <ilia@tsaver.co.il>
Sat, 25 Jun 2016 08:48:39 +0000 (11:48 +0300)
committerRichard van Velzen <rvanvelzen1@gmail.com>
Thu, 30 Jun 2016 19:45:25 +0000 (21:45 +0200)
README.md

index 2ab9de6..7262ef8 100644 (file)
--- 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)