[Pkg-javascript-commits] [uglifyjs] 84/491: document minify `warnings` and add an error example (#1973)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:24 UTC 2018


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

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit 1df9d06f4a6b9116216d8420f5b2ec67f576a301
Author: kzc <kzc at users.noreply.github.com>
Date:   Fri May 19 05:20:21 2017 -0400

    document minify `warnings` and add an error example (#1973)
---
 README.md | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index a763509..579390c 100644
--- a/README.md
+++ b/README.md
@@ -319,9 +319,27 @@ var result = UglifyJS.minify({
 console.log(result.code);
 ```
 
+To produce warnings:
+```javascript
+var result = UglifyJS.minify("function f(){ var u; return 5; }", {
+    warnings: true
+});
+console.log(result.code);     // function f(){return 5}
+console.log(result.warnings); // [ 'Dropping unused variable u [0:1,18]' ]
+console.log(result.error);    // runtime error, not defined in this case
+```
+
+An error example:
+```javascript
+var result = UglifyJS.minify({"foo.js" : "if (0) else console.log(1);"});
+console.log(JSON.stringify(result.error));
+// {"message":"Unexpected token: keyword (else)","filename":"foo.js","line":1,"col":7,"pos":7}
+```
+
 ## Minify options
 
-- `warnings` (default `false`) — pass `true` to display compressor warnings.
+- `warnings` (default `false`) — pass `true` to return compressor warnings 
+  in `result.warnings`. Use the value `"verbose"` for more detailed warnings.
 
 - `parse` (default `{}`) — pass an object if you wish to specify some
   additional [parse options](#parse-options).

-- 
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