imc
Version:
IMC is an In-Memory Cache key-value store.
67 lines (58 loc) • 2.59 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.IMC = {}));
}(this, (function (exports) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var Cache = (function () {
function Cache(store) {
if (store === void 0) { store = {}; }
this.store = store;
}
Cache.prototype.set = function (key, value) {
if (typeof key === 'string') {
this.store[key] = value;
}
else if (key instanceof Object && Object.keys(key).length) {
this.store = __assign(__assign({}, key), this.store);
}
};
Cache.prototype.get = function (key) {
return key ? this.store[key] : this.store;
};
Cache.prototype.delete = function (key) {
delete this.store[key];
};
Cache.prototype.clear = function () {
this.store = {};
};
return Cache;
}());
var cache = new Cache();
exports.Cache = Cache;
exports.cache = cache;
exports.default = cache;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=imc.js.map