@iro/calendar
Version:
lunar is a calendar library for Solar and Chinese Lunar.
71 lines • 1.98 kB
JavaScript
var Dictionary = (function () {
function Dictionary(entries) {
var _this = this;
this.table = {};
if (entries) {
entries.forEach(function (f) {
_this.set(f[0], f[1]);
});
}
}
Dictionary.prototype.clear = function () {
this.table = {};
};
Dictionary.prototype.get = function (key) {
return this.table[key];
};
Dictionary.prototype.remove = function (key) {
var v = this.table[key];
delete this.table[key];
return v;
};
Dictionary.prototype.set = function (key, value) {
this.table[key] = value;
};
Dictionary.prototype.size = function () {
var n = 0;
for (var key in this.table) {
if (this.table.hasOwnProperty(key)) {
n++;
}
}
return n;
};
Dictionary.prototype.isEmpty = function () {
return this.size() < 1;
};
Dictionary.prototype.forEach = function (callback) {
for (var name_1 in this.table) {
if (this.table.hasOwnProperty(name_1)) {
var ret = callback(name_1, this.table[name_1]);
if (ret === false) {
return;
}
}
}
};
Dictionary.prototype.containsKey = function (key) {
return this.table.hasOwnProperty(key);
};
Dictionary.prototype.keys = function () {
var l = [];
for (var key in this.table) {
if (this.table.hasOwnProperty(key)) {
l.push(key);
}
}
return l;
};
Dictionary.prototype.values = function () {
var l = [];
for (var key in this.table) {
if (this.table.hasOwnProperty(key)) {
l.push(this.table[key]);
}
}
return l;
};
return Dictionary;
}());
export { Dictionary };
//# sourceMappingURL=Dictionary.js.map