File: /home/frenchy/www/french-american.org/current/node_modules/uglyfly-js/lib/Dictionary.js
/***********************************************************************
Copyright 2014 (c) Saair Quaderi <saair.quaderi@gmail.com>
Copyright 2012-2013 (c) Mihai Bazon <mihai.bazon@gmail.com>
UglyflyJS sourcecode can be found here:
https://github.com/quaderi/uglyflyjs
UglyflyJS (by Saair) is a fork of UglifyJS2 (by Mihai Bazon)
Both libraries are released under the BSD 2-Clause License.
***********************************************************************/
/*globals define, module, require */
((typeof define === "function") ? define :
function () { "use strict"; require('./nd').apply(module, arguments); })(
"Dictionary",
[
//no dependencies
],
function () {
"use strict";
/*jslint plusplus: true, nomen: true */
function Dictionary() {
this._values = Object.create(null);
this._size = 0;
}
Dictionary.prototype = {
set: function (key, val) {
if (!this.has(key)) {
++this._size;
}
this._values["$" + key] = val;
return this;
},
add: function (key, val) {
if (this.has(key)) {
this.get(key).push(val);
} else {
this.set(key, [ val ]);
}
return this;
},
get: function (key) { return this._values["$" + key]; },
del: function (key) {
if (this.has(key)) {
--this._size;
delete this._values["$" + key];
}
return this;
},
has: function (key) {
return Object.prototype.hasOwnProperty.call(this._values, "$" + key);
},
each: function (f) {
var i;
for (i in this._values) {
if (Object.prototype.hasOwnProperty.call(this._values, i)) {
f(this._values[i], i.substr(1));
}
}
},
size: function () {
return this._size;
},
map: function (f) {
var ret = [],
i;
for (i in this._values) {
if (Object.prototype.hasOwnProperty.call(this._values, i)) {
ret.push(f(this._values[i], i.substr(1)));
}
}
return ret;
}
};
return Dictionary;
}
);