localforage-driver-memory
Version:
in-memory localforage driver that resets on page reload
41 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var stores = {};
/** @internal */
var Store = /** @class */ (function () {
function Store(kp) {
this.kp = kp;
this.data = {};
}
Store.resolve = function (kp) {
if (!stores[kp]) {
stores[kp] = new Store(kp);
}
return stores[kp];
};
Store.prototype.clear = function () {
this.data = {};
};
Store.prototype.drop = function () {
this.clear();
delete stores[this.kp];
};
Store.prototype.get = function (key) {
return this.data[key];
};
Store.prototype.key = function (idx) {
return this.keys()[idx];
};
Store.prototype.keys = function () {
return Object.keys(this.data);
};
Store.prototype.rm = function (k) {
delete this.data[k];
};
Store.prototype.set = function (k, v) {
this.data[k] = v;
};
return Store;
}());
exports.Store = Store;
//# sourceMappingURL=Store.js.map