diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-11-06 11:39:41 +0200 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-11-06 18:19:51 +0200 |
commit | a4f6d46118c0d9d1d84a9238d8ef4e57279caac3 (patch) | |
tree | 4e6f35eaaba2d860ae6f86d0e2e691ef9e73bc40 /lib/utils.js | |
parent | 7f5f4d60b70909d21e0111d2c900ba0f5993b374 (diff) | |
download | tracifyjs-a4f6d46118c0d9d1d84a9238d8ef4e57279caac3.tar.gz tracifyjs-a4f6d46118c0d9d1d84a9238d8ef4e57279caac3.zip |
add option to mangle names even if eval/with is in use
(for more fair comparison to Closure compiler)
Diffstat (limited to 'lib/utils.js')
-rw-r--r-- | lib/utils.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/utils.js b/lib/utils.js index 27b79753..15eed9ba 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -247,16 +247,30 @@ function makePredicate(words) { function Dictionary() { this._values = Object.create(null); + this._size = 0; }; Dictionary.prototype = { - set: function(key, val) { return this._values["$" + key] = val, this }, + set: function(key, val) { + if (!this.has(key)) ++this._size; + this._values["$" + key] = val; + return this; + }, get: function(key) { return this._values["$" + key] }, - del: function(key) { return delete this._values["$" + key], this }, + del: function(key) { + if (this.has(key)) { + --this._size; + delete this._values["$" + key]; + } + return this; + }, has: function(key) { return ("$" + key) in this._values }, each: function(f) { for (var i in this._values) f(this._values[i], i.substr(1)); }, + size: function() { + return this._size; + }, map: function(f) { var ret = []; for (var i in this._values) |