noodl-loader
Version:
Loader for noodl applications
40 lines • 1.33 kB
JavaScript
;
var _KeyValueCache_data;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
class KeyValueCache {
constructor() {
_KeyValueCache_data.set(this, new Map());
}
clear() {
tslib_1.__classPrivateFieldGet(this, _KeyValueCache_data, "f").clear();
return this;
}
has(key) {
return tslib_1.__classPrivateFieldGet(this, _KeyValueCache_data, "f").has(key);
}
get(key) {
if (key)
return tslib_1.__classPrivateFieldGet(this, _KeyValueCache_data, "f").get(key);
return [...tslib_1.__classPrivateFieldGet(this, _KeyValueCache_data, "f").entries()].reduce((acc, [k, v]) => {
acc[k] = v;
return acc;
}, {});
}
set(key, value) {
tslib_1.__classPrivateFieldGet(this, _KeyValueCache_data, "f").set(key, value);
return this;
}
merge(obj) {
for (const [key, value] of Object.entries(obj))
this.set(key, value);
return this;
}
remove(key) {
tslib_1.__classPrivateFieldGet(this, _KeyValueCache_data, "f").delete(key);
return this;
}
}
_KeyValueCache_data = new WeakMap();
exports.default = KeyValueCache;
//# sourceMappingURL=key-value-cache.js.map