terser 3.7.6 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of terser might be problematic. Click here for more details.
- package/README.md +55 -15
- package/bin/uglifyjs +19 -7
- package/dist/.gitkeep +0 -0
- package/dist/browser.bundle.js +11960 -0
- package/dist/browser.bundle.js.map +1 -0
- package/lib/ast.js +46 -47
- package/lib/compress.js +309 -254
- package/lib/minify.js +1 -1
- package/lib/mozilla-ast.js +31 -31
- package/lib/output.js +217 -213
- package/lib/parse.js +128 -108
- package/lib/propmangle.js +4 -4
- package/lib/scope.js +19 -19
- package/lib/sourcemap.js +3 -3
- package/lib/transform.js +37 -37
- package/lib/utils.js +29 -29
- package/package.json +35 -6
- package/tools/colorless-console.js +3 -2
- package/tools/exports.js +3 -3
package/lib/propmangle.js
CHANGED
@@ -74,7 +74,7 @@ function find_builtins(reserved) {
|
|
74
74
|
objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
|
75
75
|
Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
|
76
76
|
objects.WeakMap, objects.WeakSet
|
77
|
-
].forEach(function(ctor){
|
77
|
+
].forEach(function(ctor) {
|
78
78
|
Object.getOwnPropertyNames(ctor).map(add);
|
79
79
|
if (ctor.prototype) {
|
80
80
|
Object.getOwnPropertyNames(ctor.prototype).map(add);
|
@@ -156,7 +156,7 @@ function mangle_properties(ast, options) {
|
|
156
156
|
var unmangleable = [];
|
157
157
|
|
158
158
|
// step 1: find candidates to mangle
|
159
|
-
ast.walk(new TreeWalker(function(node){
|
159
|
+
ast.walk(new TreeWalker(function(node) {
|
160
160
|
if (node instanceof AST_ObjectKeyVal) {
|
161
161
|
add(node.key);
|
162
162
|
}
|
@@ -177,7 +177,7 @@ function mangle_properties(ast, options) {
|
|
177
177
|
}));
|
178
178
|
|
179
179
|
// step 2: transform the tree, renaming properties
|
180
|
-
return ast.transform(new TreeTransformer(function(node){
|
180
|
+
return ast.transform(new TreeTransformer(function(node) {
|
181
181
|
if (node instanceof AST_ObjectKeyVal) {
|
182
182
|
node.key = mangle(node.key);
|
183
183
|
}
|
@@ -254,7 +254,7 @@ function mangle_properties(ast, options) {
|
|
254
254
|
}
|
255
255
|
|
256
256
|
function mangleStrings(node) {
|
257
|
-
return node.transform(new TreeTransformer(function(node){
|
257
|
+
return node.transform(new TreeTransformer(function(node) {
|
258
258
|
if (node instanceof AST_Sequence) {
|
259
259
|
var last = node.expressions.length - 1;
|
260
260
|
node.expressions[last] = mangleStrings(node.expressions[last]);
|
package/lib/scope.js
CHANGED
@@ -56,7 +56,7 @@ function SymbolDef(scope, orig, init) {
|
|
56
56
|
this.mangled_name = null;
|
57
57
|
this.undeclared = false;
|
58
58
|
this.id = SymbolDef.next_id++;
|
59
|
-
}
|
59
|
+
}
|
60
60
|
|
61
61
|
SymbolDef.next_id = 1;
|
62
62
|
|
@@ -101,7 +101,7 @@ SymbolDef.prototype = {
|
|
101
101
|
}
|
102
102
|
};
|
103
103
|
|
104
|
-
AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
104
|
+
AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
105
105
|
options = defaults(options, {
|
106
106
|
cache: null,
|
107
107
|
ie8: false,
|
@@ -115,7 +115,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|
115
115
|
var defun = null;
|
116
116
|
var in_destructuring = null;
|
117
117
|
var for_scopes = [];
|
118
|
-
var tw = new TreeWalker(function(node, descend){
|
118
|
+
var tw = new TreeWalker(function(node, descend) {
|
119
119
|
if (node.is_block_scope()) {
|
120
120
|
var save_scope = scope;
|
121
121
|
node.block_scope = scope = new AST_Scope(node);
|
@@ -269,7 +269,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|
269
269
|
|
270
270
|
// pass 2: find back references and eval
|
271
271
|
self.globals = new Dictionary();
|
272
|
-
var tw = new TreeWalker(function(node, descend){
|
272
|
+
var tw = new TreeWalker(function(node, descend) {
|
273
273
|
if (node instanceof AST_LoopControl && node.label) {
|
274
274
|
node.label.thedef.references.push(node);
|
275
275
|
return true;
|
@@ -342,7 +342,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|
342
342
|
}
|
343
343
|
});
|
344
344
|
|
345
|
-
AST_Toplevel.DEFMETHOD("def_global", function(node){
|
345
|
+
AST_Toplevel.DEFMETHOD("def_global", function(node) {
|
346
346
|
var globals = this.globals, name = node.name;
|
347
347
|
if (globals.has(name)) {
|
348
348
|
return globals.get(name);
|
@@ -355,7 +355,7 @@ AST_Toplevel.DEFMETHOD("def_global", function(node){
|
|
355
355
|
}
|
356
356
|
});
|
357
357
|
|
358
|
-
AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope){
|
358
|
+
AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
|
359
359
|
this.variables = new Dictionary(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
|
360
360
|
this.functions = new Dictionary(); // map name to AST_SymbolDefun (functions defined in this scope)
|
361
361
|
this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
|
@@ -373,7 +373,7 @@ AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
|
|
373
373
|
AST_Block.DEFMETHOD("is_block_scope", return_true);
|
374
374
|
AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
|
375
375
|
|
376
|
-
AST_Lambda.DEFMETHOD("init_scope_vars", function(){
|
376
|
+
AST_Lambda.DEFMETHOD("init_scope_vars", function() {
|
377
377
|
AST_Scope.prototype.init_scope_vars.apply(this, arguments);
|
378
378
|
this.uses_arguments = false;
|
379
379
|
this.def_variable(new AST_SymbolFunarg({
|
@@ -383,7 +383,7 @@ AST_Lambda.DEFMETHOD("init_scope_vars", function(){
|
|
383
383
|
}));
|
384
384
|
});
|
385
385
|
|
386
|
-
AST_Arrow.DEFMETHOD("init_scope_vars", function(){
|
386
|
+
AST_Arrow.DEFMETHOD("init_scope_vars", function() {
|
387
387
|
AST_Scope.prototype.init_scope_vars.apply(this, arguments);
|
388
388
|
this.uses_arguments = false;
|
389
389
|
});
|
@@ -408,20 +408,20 @@ AST_Symbol.DEFMETHOD("reference", function(options) {
|
|
408
408
|
this.mark_enclosed(options);
|
409
409
|
});
|
410
410
|
|
411
|
-
AST_Scope.DEFMETHOD("find_variable", function(name){
|
411
|
+
AST_Scope.DEFMETHOD("find_variable", function(name) {
|
412
412
|
if (name instanceof AST_Symbol) name = name.name;
|
413
413
|
return this.variables.get(name)
|
414
414
|
|| (this.parent_scope && this.parent_scope.find_variable(name));
|
415
415
|
});
|
416
416
|
|
417
|
-
AST_Scope.DEFMETHOD("def_function", function(symbol, init){
|
417
|
+
AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
|
418
418
|
var def = this.def_variable(symbol, init);
|
419
419
|
if (!def.init || def.init instanceof AST_Defun) def.init = init;
|
420
420
|
this.functions.set(symbol.name, def);
|
421
421
|
return def;
|
422
422
|
});
|
423
423
|
|
424
|
-
AST_Scope.DEFMETHOD("def_variable", function(symbol, init){
|
424
|
+
AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
|
425
425
|
var def = this.variables.get(symbol.name);
|
426
426
|
if (def) {
|
427
427
|
def.orig.push(symbol);
|
@@ -458,11 +458,11 @@ function next_mangled(scope, options) {
|
|
458
458
|
}
|
459
459
|
}
|
460
460
|
|
461
|
-
AST_Scope.DEFMETHOD("next_mangled", function(options){
|
461
|
+
AST_Scope.DEFMETHOD("next_mangled", function(options) {
|
462
462
|
return next_mangled(this, options);
|
463
463
|
});
|
464
464
|
|
465
|
-
AST_Toplevel.DEFMETHOD("next_mangled", function(options){
|
465
|
+
AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
|
466
466
|
var name;
|
467
467
|
do {
|
468
468
|
name = next_mangled(this, options);
|
@@ -470,7 +470,7 @@ AST_Toplevel.DEFMETHOD("next_mangled", function(options){
|
|
470
470
|
return name;
|
471
471
|
});
|
472
472
|
|
473
|
-
AST_Function.DEFMETHOD("next_mangled", function(options, def){
|
473
|
+
AST_Function.DEFMETHOD("next_mangled", function(options, def) {
|
474
474
|
// #179, #326
|
475
475
|
// in Safari strict mode, something like (function x(x){...}) is a syntax error;
|
476
476
|
// a function expression's argument cannot shadow the function expression's name
|
@@ -526,7 +526,7 @@ AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
|
|
526
526
|
return options;
|
527
527
|
});
|
528
528
|
|
529
|
-
AST_Toplevel.DEFMETHOD("mangle_names", function(options){
|
529
|
+
AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
530
530
|
options = this._default_mangler_options(options);
|
531
531
|
|
532
532
|
// We only need to mangle declaration nodes. Special logic wired
|
@@ -546,7 +546,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
|
|
546
546
|
}
|
547
547
|
}
|
548
548
|
|
549
|
-
var tw = new TreeWalker(function(node, descend){
|
549
|
+
var tw = new TreeWalker(function(node, descend) {
|
550
550
|
if (node instanceof AST_LabeledStatement) {
|
551
551
|
// lname is incremented when we get to the AST_Label
|
552
552
|
var save_nesting = lname;
|
@@ -574,7 +574,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
|
|
574
574
|
}
|
575
575
|
});
|
576
576
|
this.walk(tw);
|
577
|
-
to_mangle.forEach(function(def){ def.mangle(options) });
|
577
|
+
to_mangle.forEach(function(def) { def.mangle(options); });
|
578
578
|
|
579
579
|
function collect(symbol) {
|
580
580
|
if (!member(symbol.name, options.reserved)) {
|
@@ -646,7 +646,7 @@ AST_Sequence.DEFMETHOD("tail_node", function() {
|
|
646
646
|
return this.expressions[this.expressions.length - 1];
|
647
647
|
});
|
648
648
|
|
649
|
-
AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options){
|
649
|
+
AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
|
650
650
|
options = this._default_mangler_options(options);
|
651
651
|
try {
|
652
652
|
AST_Node.prototype.print = function(stream, force_parens) {
|
@@ -715,6 +715,6 @@ var base54 = (function() {
|
|
715
715
|
base = 64;
|
716
716
|
} while (num > 0);
|
717
717
|
return ret;
|
718
|
-
}
|
718
|
+
}
|
719
719
|
return base54;
|
720
720
|
})();
|
package/lib/sourcemap.js
CHANGED
@@ -88,10 +88,10 @@ function SourceMap(options) {
|
|
88
88
|
source : source,
|
89
89
|
name : name
|
90
90
|
});
|
91
|
-
}
|
91
|
+
}
|
92
92
|
return {
|
93
93
|
add : add,
|
94
|
-
get : function() { return generator },
|
94
|
+
get : function() { return generator; },
|
95
95
|
toString : function() { return JSON.stringify(generator.toJSON()); }
|
96
96
|
};
|
97
|
-
}
|
97
|
+
}
|
package/lib/transform.js
CHANGED
@@ -52,10 +52,10 @@ function TreeTransformer(before, after) {
|
|
52
52
|
}
|
53
53
|
TreeTransformer.prototype = new TreeWalker;
|
54
54
|
|
55
|
-
(function(undefined){
|
55
|
+
(function(undefined) {
|
56
56
|
|
57
57
|
function _(node, descend) {
|
58
|
-
node.DEFMETHOD("transform", function(tw, in_list){
|
58
|
+
node.DEFMETHOD("transform", function(tw, in_list) {
|
59
59
|
var x, y;
|
60
60
|
tw.push(this);
|
61
61
|
if (tw.before) x = tw.before(this, descend, in_list);
|
@@ -70,97 +70,97 @@ TreeTransformer.prototype = new TreeWalker;
|
|
70
70
|
tw.pop();
|
71
71
|
return x;
|
72
72
|
});
|
73
|
-
}
|
73
|
+
}
|
74
74
|
|
75
75
|
function do_list(list, tw) {
|
76
|
-
return MAP(list, function(node){
|
76
|
+
return MAP(list, function(node) {
|
77
77
|
return node.transform(tw, true);
|
78
78
|
});
|
79
|
-
}
|
79
|
+
}
|
80
80
|
|
81
81
|
_(AST_Node, noop);
|
82
82
|
|
83
|
-
_(AST_LabeledStatement, function(self, tw){
|
83
|
+
_(AST_LabeledStatement, function(self, tw) {
|
84
84
|
self.label = self.label.transform(tw);
|
85
85
|
self.body = self.body.transform(tw);
|
86
86
|
});
|
87
87
|
|
88
|
-
_(AST_SimpleStatement, function(self, tw){
|
88
|
+
_(AST_SimpleStatement, function(self, tw) {
|
89
89
|
self.body = self.body.transform(tw);
|
90
90
|
});
|
91
91
|
|
92
|
-
_(AST_Block, function(self, tw){
|
92
|
+
_(AST_Block, function(self, tw) {
|
93
93
|
self.body = do_list(self.body, tw);
|
94
94
|
});
|
95
95
|
|
96
|
-
_(AST_Do, function(self, tw){
|
96
|
+
_(AST_Do, function(self, tw) {
|
97
97
|
self.body = self.body.transform(tw);
|
98
98
|
self.condition = self.condition.transform(tw);
|
99
99
|
});
|
100
100
|
|
101
|
-
_(AST_While, function(self, tw){
|
101
|
+
_(AST_While, function(self, tw) {
|
102
102
|
self.condition = self.condition.transform(tw);
|
103
103
|
self.body = self.body.transform(tw);
|
104
104
|
});
|
105
105
|
|
106
|
-
_(AST_For, function(self, tw){
|
106
|
+
_(AST_For, function(self, tw) {
|
107
107
|
if (self.init) self.init = self.init.transform(tw);
|
108
108
|
if (self.condition) self.condition = self.condition.transform(tw);
|
109
109
|
if (self.step) self.step = self.step.transform(tw);
|
110
110
|
self.body = self.body.transform(tw);
|
111
111
|
});
|
112
112
|
|
113
|
-
_(AST_ForIn, function(self, tw){
|
113
|
+
_(AST_ForIn, function(self, tw) {
|
114
114
|
self.init = self.init.transform(tw);
|
115
115
|
self.object = self.object.transform(tw);
|
116
116
|
self.body = self.body.transform(tw);
|
117
117
|
});
|
118
118
|
|
119
|
-
_(AST_With, function(self, tw){
|
119
|
+
_(AST_With, function(self, tw) {
|
120
120
|
self.expression = self.expression.transform(tw);
|
121
121
|
self.body = self.body.transform(tw);
|
122
122
|
});
|
123
123
|
|
124
|
-
_(AST_Exit, function(self, tw){
|
124
|
+
_(AST_Exit, function(self, tw) {
|
125
125
|
if (self.value) self.value = self.value.transform(tw);
|
126
126
|
});
|
127
127
|
|
128
|
-
_(AST_LoopControl, function(self, tw){
|
128
|
+
_(AST_LoopControl, function(self, tw) {
|
129
129
|
if (self.label) self.label = self.label.transform(tw);
|
130
130
|
});
|
131
131
|
|
132
|
-
_(AST_If, function(self, tw){
|
132
|
+
_(AST_If, function(self, tw) {
|
133
133
|
self.condition = self.condition.transform(tw);
|
134
134
|
self.body = self.body.transform(tw);
|
135
135
|
if (self.alternative) self.alternative = self.alternative.transform(tw);
|
136
136
|
});
|
137
137
|
|
138
|
-
_(AST_Switch, function(self, tw){
|
138
|
+
_(AST_Switch, function(self, tw) {
|
139
139
|
self.expression = self.expression.transform(tw);
|
140
140
|
self.body = do_list(self.body, tw);
|
141
141
|
});
|
142
142
|
|
143
|
-
_(AST_Case, function(self, tw){
|
143
|
+
_(AST_Case, function(self, tw) {
|
144
144
|
self.expression = self.expression.transform(tw);
|
145
145
|
self.body = do_list(self.body, tw);
|
146
146
|
});
|
147
147
|
|
148
|
-
_(AST_Try, function(self, tw){
|
148
|
+
_(AST_Try, function(self, tw) {
|
149
149
|
self.body = do_list(self.body, tw);
|
150
150
|
if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
|
151
151
|
if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
|
152
152
|
});
|
153
153
|
|
154
|
-
_(AST_Catch, function(self, tw){
|
154
|
+
_(AST_Catch, function(self, tw) {
|
155
155
|
self.argname = self.argname.transform(tw);
|
156
156
|
self.body = do_list(self.body, tw);
|
157
157
|
});
|
158
158
|
|
159
|
-
_(AST_Definitions, function(self, tw){
|
159
|
+
_(AST_Definitions, function(self, tw) {
|
160
160
|
self.definitions = do_list(self.definitions, tw);
|
161
161
|
});
|
162
162
|
|
163
|
-
_(AST_VarDef, function(self, tw){
|
163
|
+
_(AST_VarDef, function(self, tw) {
|
164
164
|
self.name = self.name.transform(tw);
|
165
165
|
if (self.value) self.value = self.value.transform(tw);
|
166
166
|
});
|
@@ -169,7 +169,7 @@ TreeTransformer.prototype = new TreeWalker;
|
|
169
169
|
self.names = do_list(self.names, tw);
|
170
170
|
});
|
171
171
|
|
172
|
-
_(AST_Lambda, function(self, tw){
|
172
|
+
_(AST_Lambda, function(self, tw) {
|
173
173
|
if (self.name) self.name = self.name.transform(tw);
|
174
174
|
self.argnames = do_list(self.argnames, tw);
|
175
175
|
if (self.body instanceof AST_Node) {
|
@@ -179,69 +179,69 @@ TreeTransformer.prototype = new TreeWalker;
|
|
179
179
|
}
|
180
180
|
});
|
181
181
|
|
182
|
-
_(AST_Call, function(self, tw){
|
182
|
+
_(AST_Call, function(self, tw) {
|
183
183
|
self.expression = self.expression.transform(tw);
|
184
184
|
self.args = do_list(self.args, tw);
|
185
185
|
});
|
186
186
|
|
187
|
-
_(AST_Sequence, function(self, tw){
|
187
|
+
_(AST_Sequence, function(self, tw) {
|
188
188
|
self.expressions = do_list(self.expressions, tw);
|
189
189
|
});
|
190
190
|
|
191
|
-
_(AST_Dot, function(self, tw){
|
191
|
+
_(AST_Dot, function(self, tw) {
|
192
192
|
self.expression = self.expression.transform(tw);
|
193
193
|
});
|
194
194
|
|
195
|
-
_(AST_Sub, function(self, tw){
|
195
|
+
_(AST_Sub, function(self, tw) {
|
196
196
|
self.expression = self.expression.transform(tw);
|
197
197
|
self.property = self.property.transform(tw);
|
198
198
|
});
|
199
199
|
|
200
|
-
_(AST_Yield, function(self, tw){
|
200
|
+
_(AST_Yield, function(self, tw) {
|
201
201
|
if (self.expression) self.expression = self.expression.transform(tw);
|
202
202
|
});
|
203
203
|
|
204
|
-
_(AST_Await, function(self, tw){
|
204
|
+
_(AST_Await, function(self, tw) {
|
205
205
|
self.expression = self.expression.transform(tw);
|
206
206
|
});
|
207
207
|
|
208
|
-
_(AST_Unary, function(self, tw){
|
208
|
+
_(AST_Unary, function(self, tw) {
|
209
209
|
self.expression = self.expression.transform(tw);
|
210
210
|
});
|
211
211
|
|
212
|
-
_(AST_Binary, function(self, tw){
|
212
|
+
_(AST_Binary, function(self, tw) {
|
213
213
|
self.left = self.left.transform(tw);
|
214
214
|
self.right = self.right.transform(tw);
|
215
215
|
});
|
216
216
|
|
217
|
-
_(AST_Conditional, function(self, tw){
|
217
|
+
_(AST_Conditional, function(self, tw) {
|
218
218
|
self.condition = self.condition.transform(tw);
|
219
219
|
self.consequent = self.consequent.transform(tw);
|
220
220
|
self.alternative = self.alternative.transform(tw);
|
221
221
|
});
|
222
222
|
|
223
|
-
_(AST_Array, function(self, tw){
|
223
|
+
_(AST_Array, function(self, tw) {
|
224
224
|
self.elements = do_list(self.elements, tw);
|
225
225
|
});
|
226
226
|
|
227
|
-
_(AST_Object, function(self, tw){
|
227
|
+
_(AST_Object, function(self, tw) {
|
228
228
|
self.properties = do_list(self.properties, tw);
|
229
229
|
});
|
230
230
|
|
231
|
-
_(AST_ObjectProperty, function(self, tw){
|
231
|
+
_(AST_ObjectProperty, function(self, tw) {
|
232
232
|
if (self.key instanceof AST_Node) {
|
233
233
|
self.key = self.key.transform(tw);
|
234
234
|
}
|
235
235
|
self.value = self.value.transform(tw);
|
236
236
|
});
|
237
237
|
|
238
|
-
_(AST_Class, function(self, tw){
|
238
|
+
_(AST_Class, function(self, tw) {
|
239
239
|
if (self.name) self.name = self.name.transform(tw);
|
240
240
|
if (self.extends) self.extends = self.extends.transform(tw);
|
241
241
|
self.properties = do_list(self.properties, tw);
|
242
242
|
});
|
243
243
|
|
244
|
-
_(AST_Expansion, function(self, tw){
|
244
|
+
_(AST_Expansion, function(self, tw) {
|
245
245
|
self.expression = self.expression.transform(tw);
|
246
246
|
});
|
247
247
|
|
package/lib/utils.js
CHANGED
@@ -45,18 +45,18 @@
|
|
45
45
|
|
46
46
|
function characters(str) {
|
47
47
|
return str.split("");
|
48
|
-
}
|
48
|
+
}
|
49
49
|
|
50
50
|
function member(name, array) {
|
51
51
|
return array.indexOf(name) >= 0;
|
52
|
-
}
|
52
|
+
}
|
53
53
|
|
54
54
|
function find_if(func, array) {
|
55
55
|
for (var i = 0, n = array.length; i < n; ++i) {
|
56
56
|
if (func(array[i]))
|
57
57
|
return array[i];
|
58
58
|
}
|
59
|
-
}
|
59
|
+
}
|
60
60
|
|
61
61
|
function repeat_string(str, i) {
|
62
62
|
if (i <= 0) return "";
|
@@ -65,7 +65,7 @@ function repeat_string(str, i) {
|
|
65
65
|
d += d;
|
66
66
|
if (i & 1) d += str;
|
67
67
|
return d;
|
68
|
-
}
|
68
|
+
}
|
69
69
|
|
70
70
|
function configure_error_stack(fn) {
|
71
71
|
Object.defineProperty(fn.prototype, "stack", {
|
@@ -84,7 +84,7 @@ function configure_error_stack(fn) {
|
|
84
84
|
function DefaultsError(msg, defs) {
|
85
85
|
this.message = msg;
|
86
86
|
this.defs = defs;
|
87
|
-
}
|
87
|
+
}
|
88
88
|
DefaultsError.prototype = Object.create(Error.prototype);
|
89
89
|
DefaultsError.prototype.constructor = DefaultsError;
|
90
90
|
DefaultsError.prototype.name = "DefaultsError";
|
@@ -104,7 +104,7 @@ function defaults(args, defs, croak) {
|
|
104
104
|
ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
|
105
105
|
}
|
106
106
|
return ret;
|
107
|
-
}
|
107
|
+
}
|
108
108
|
|
109
109
|
function merge(obj, ext) {
|
110
110
|
var count = 0;
|
@@ -113,7 +113,7 @@ function merge(obj, ext) {
|
|
113
113
|
count++;
|
114
114
|
}
|
115
115
|
return count;
|
116
|
-
}
|
116
|
+
}
|
117
117
|
|
118
118
|
function noop() {}
|
119
119
|
function return_false() { return false; }
|
@@ -121,7 +121,7 @@ function return_true() { return true; }
|
|
121
121
|
function return_this() { return this; }
|
122
122
|
function return_null() { return null; }
|
123
123
|
|
124
|
-
var MAP = (function(){
|
124
|
+
var MAP = (function() {
|
125
125
|
function MAP(a, f, backwards) {
|
126
126
|
var ret = [], top = [], i;
|
127
127
|
function doit() {
|
@@ -144,7 +144,7 @@ var MAP = (function(){
|
|
144
144
|
}
|
145
145
|
}
|
146
146
|
return is_last;
|
147
|
-
}
|
147
|
+
}
|
148
148
|
if (a instanceof Array) {
|
149
149
|
if (backwards) {
|
150
150
|
for (i = a.length; --i >= 0;) if (doit()) break;
|
@@ -158,33 +158,33 @@ var MAP = (function(){
|
|
158
158
|
for (i in a) if (HOP(a, i)) if (doit()) break;
|
159
159
|
}
|
160
160
|
return top.concat(ret);
|
161
|
-
}
|
162
|
-
MAP.at_top = function(val) { return new AtTop(val) };
|
163
|
-
MAP.splice = function(val) { return new Splice(val) };
|
164
|
-
MAP.last = function(val) { return new Last(val) };
|
161
|
+
}
|
162
|
+
MAP.at_top = function(val) { return new AtTop(val); };
|
163
|
+
MAP.splice = function(val) { return new Splice(val); };
|
164
|
+
MAP.last = function(val) { return new Last(val); };
|
165
165
|
var skip = MAP.skip = {};
|
166
|
-
function AtTop(val) { this.v = val }
|
167
|
-
function Splice(val) { this.v = val }
|
168
|
-
function Last(val) { this.v = val }
|
166
|
+
function AtTop(val) { this.v = val; }
|
167
|
+
function Splice(val) { this.v = val; }
|
168
|
+
function Last(val) { this.v = val; }
|
169
169
|
return MAP;
|
170
170
|
})();
|
171
171
|
|
172
172
|
function push_uniq(array, el) {
|
173
173
|
if (array.indexOf(el) < 0)
|
174
174
|
array.push(el);
|
175
|
-
}
|
175
|
+
}
|
176
176
|
|
177
177
|
function string_template(text, props) {
|
178
|
-
return text.replace(/\{(.+?)\}/g, function(str, p){
|
178
|
+
return text.replace(/\{(.+?)\}/g, function(str, p) {
|
179
179
|
return props && props[p];
|
180
180
|
});
|
181
|
-
}
|
181
|
+
}
|
182
182
|
|
183
183
|
function remove(array, el) {
|
184
184
|
for (var i = array.length; --i >= 0;) {
|
185
185
|
if (array[i] === el) array.splice(i, 1);
|
186
186
|
}
|
187
|
-
}
|
187
|
+
}
|
188
188
|
|
189
189
|
function mergeSort(array, cmp) {
|
190
190
|
if (array.length < 2) return array.slice();
|
@@ -198,7 +198,7 @@ function mergeSort(array, cmp) {
|
|
198
198
|
if (ai < a.length) r.push.apply(r, a.slice(ai));
|
199
199
|
if (bi < b.length) r.push.apply(r, b.slice(bi));
|
200
200
|
return r;
|
201
|
-
}
|
201
|
+
}
|
202
202
|
function _ms(a) {
|
203
203
|
if (a.length <= 1)
|
204
204
|
return a;
|
@@ -206,9 +206,9 @@ function mergeSort(array, cmp) {
|
|
206
206
|
left = _ms(left);
|
207
207
|
right = _ms(right);
|
208
208
|
return merge(left, right);
|
209
|
-
}
|
209
|
+
}
|
210
210
|
return _ms(array);
|
211
|
-
}
|
211
|
+
}
|
212
212
|
|
213
213
|
// this function is taken from Acorn [1], written by Marijn Haverbeke
|
214
214
|
// [1] https://github.com/marijnh/acorn
|
@@ -254,19 +254,19 @@ function makePredicate(words) {
|
|
254
254
|
compareTo(words);
|
255
255
|
}
|
256
256
|
return new Function("str", f);
|
257
|
-
}
|
257
|
+
}
|
258
258
|
|
259
259
|
function all(array, predicate) {
|
260
260
|
for (var i = array.length; --i >= 0;)
|
261
261
|
if (!predicate(array[i]))
|
262
262
|
return false;
|
263
263
|
return true;
|
264
|
-
}
|
264
|
+
}
|
265
265
|
|
266
266
|
function Dictionary() {
|
267
267
|
this._values = Object.create(null);
|
268
268
|
this._size = 0;
|
269
|
-
}
|
269
|
+
}
|
270
270
|
Dictionary.prototype = {
|
271
271
|
set: function(key, val) {
|
272
272
|
if (!this.has(key)) ++this._size;
|
@@ -281,7 +281,7 @@ Dictionary.prototype = {
|
|
281
281
|
}
|
282
282
|
return this;
|
283
283
|
},
|
284
|
-
get: function(key) { return this._values["$" + key] },
|
284
|
+
get: function(key) { return this._values["$" + key]; },
|
285
285
|
del: function(key) {
|
286
286
|
if (this.has(key)) {
|
287
287
|
--this._size;
|
@@ -289,7 +289,7 @@ Dictionary.prototype = {
|
|
289
289
|
}
|
290
290
|
return this;
|
291
291
|
},
|
292
|
-
has: function(key) { return ("$" + key) in this._values },
|
292
|
+
has: function(key) { return ("$" + key) in this._values; },
|
293
293
|
each: function(f) {
|
294
294
|
for (var i in this._values)
|
295
295
|
f(this._values[i], i.substr(1));
|
@@ -310,7 +310,7 @@ Dictionary.prototype = {
|
|
310
310
|
ret._size = this._size;
|
311
311
|
return ret;
|
312
312
|
},
|
313
|
-
toObject: function() { return this._values }
|
313
|
+
toObject: function() { return this._values; }
|
314
314
|
};
|
315
315
|
Dictionary.fromObject = function(obj) {
|
316
316
|
var dict = new Dictionary();
|