aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2014-02-08 12:33:56 +0200
committerMihai Bazon <mihai@bazon.net>2014-02-08 12:33:56 +0200
commitef2ef07cbd945c7a6456adedc413858145a9ed10 (patch)
tree924e1ffe4516e262ee16391ad2fe309ff2cd8181
parent1a4440080dd2632eb47ee446058fa01ad76c6e9b (diff)
downloadtracifyjs-ef2ef07cbd945c7a6456adedc413858145a9ed10.tar.gz
tracifyjs-ef2ef07cbd945c7a6456adedc413858145a9ed10.zip
Add option `keep_fargs`.
By default it's `false`. Pass `true` if you need to keep unused function arguments. Close #188.
-rw-r--r--lib/compress.js25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 005c606d..b589aca5 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -61,6 +61,7 @@ function Compressor(options, false_by_default) {
loops : !false_by_default,
unused : !false_by_default,
hoist_funs : !false_by_default,
+ keep_fargs : false,
hoist_vars : false,
if_return : !false_by_default,
join_vars : !false_by_default,
@@ -1044,18 +1045,20 @@ merge(Compressor.prototype, {
var tt = new TreeTransformer(
function before(node, descend, in_list) {
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
- for (var a = node.argnames, i = a.length; --i >= 0;) {
- var sym = a[i];
- if (sym.unreferenced()) {
- a.pop();
- compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
- name : sym.name,
- file : sym.start.file,
- line : sym.start.line,
- col : sym.start.col
- });
+ if (!compressor.option("keep_fargs")) {
+ for (var a = node.argnames, i = a.length; --i >= 0;) {
+ var sym = a[i];
+ if (sym.unreferenced()) {
+ a.pop();
+ compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
+ name : sym.name,
+ file : sym.start.file,
+ line : sym.start.line,
+ col : sym.start.col
+ });
+ }
+ else break;
}
- else break;
}
}
if (node instanceof AST_Defun && node !== self) {