Comparing version 5.1.0 to 5.2.0
@@ -7,4 +7,9 @@ # Change Log | ||
## [5.2.0] - 2017-09-06 | ||
- **Important:** | ||
- changed the default value of `save` option, now is set to "false" | ||
- changed the default value of `share` option, now is set to "false" | ||
## [5.1.0] - 2017-09-05 | ||
- Changed the default value of `nullIfNotFound` option, now is set to "false" | ||
- **Important:** changed the default value of `nullIfNotFound` option, now is set to "false" | ||
@@ -11,0 +16,0 @@ ## [5.0.0] - 2017-09-05 |
@@ -1,2 +0,2 @@ | ||
// [AIV] InCache Build version: 5.1.0 | ||
// [AIV] InCache Build version: 5.2.0 | ||
var incache = | ||
@@ -65,3 +65,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 1); | ||
/******/ return __webpack_require__(__webpack_require__.s = 2); | ||
/******/ }) | ||
@@ -269,4 +269,25 @@ /************************************************************************/ | ||
module.exports = __webpack_require__(2); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var g; | ||
// This works in non-strict mode | ||
g = function () { | ||
return this; | ||
}(); | ||
try { | ||
// This works if eval is allowed (see CSP) | ||
g = g || Function("return this")() || (1, eval)("this"); | ||
} catch (e) { | ||
// This works if the window reference is available | ||
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") g = window; | ||
} | ||
// g can still be undefined, but nothing to do about it... | ||
// We return undefined, instead of nothing here, so it's | ||
// easier to handle this case. if(!global) { ...} | ||
module.exports = g; | ||
/***/ }), | ||
@@ -277,2 +298,11 @@ /* 2 */ | ||
"use strict"; | ||
module.exports = __webpack_require__(3); | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(process, global) { | ||
@@ -287,2 +317,3 @@ | ||
var fs = __webpack_require__(9); | ||
var uuid = __webpack_require__(10); | ||
@@ -297,6 +328,6 @@ var InCache = function () { | ||
* @param [opts.silent=false] {boolean} if true no event will be triggered | ||
* @param [opts.save=true] {boolean} if true saves cache in disk. (server only) | ||
* @param [opts.save=false] {boolean} if true saves cache in disk when the process is terminated. (server only) | ||
* @param [opts.filePath=.incache] {string} cache file path | ||
* @param [opts.storeName] {string} store name | ||
* @param [opts.share=true] {boolean} if true use global object as storage | ||
* @param [opts.share=false] {boolean} if true use global object as storage | ||
* @param [opts.autoRemovePeriod=0] {number} period in seconds to remove expired records. When set, the records will be removed only on check, when 0 it won't run | ||
@@ -335,3 +366,3 @@ * @param [opts.nullIfNotFound=true] {boolean} calling `get` if the key is not found returns `null`. If false returns `undefined` | ||
storeName: '', | ||
save: true, | ||
save: false, | ||
filePath: '.incache', | ||
@@ -341,3 +372,3 @@ maxAge: 0, | ||
silent: false, | ||
share: true, | ||
share: false, | ||
autoRemovePeriod: 0, | ||
@@ -474,2 +505,3 @@ nullIfNotFound: false, | ||
* @typedef {Object} InCache~record | ||
* @property {string} id - uuid | ||
* @property {boolean} isNew - indicates if is a new record | ||
@@ -513,2 +545,3 @@ * @property {Date|null} createdOn - creation date | ||
var record = { | ||
id: null, | ||
isNew: true, | ||
@@ -534,2 +567,3 @@ createdOn: null, | ||
record.isNew = false; | ||
record.id = this._storage[key].id; | ||
record.createdOn = this._storage[key].createdOn; | ||
@@ -542,2 +576,3 @@ record.updatedOn = new Date(); | ||
} else { | ||
record.id = uuid(); | ||
record.createdOn = new Date(); | ||
@@ -1118,35 +1153,5 @@ if (!opts.silent) { | ||
module.exports = InCache; | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(3))) | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1))) | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var g; | ||
// This works in non-strict mode | ||
g = function () { | ||
return this; | ||
}(); | ||
try { | ||
// This works if eval is allowed (see CSP) | ||
g = g || Function("return this")() || (1, eval)("this"); | ||
} catch (e) { | ||
// This works if the window reference is available | ||
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") g = window; | ||
} | ||
// g can still be undefined, but nothing to do about it... | ||
// We return undefined, instead of nothing here, so it's | ||
// easier to handle this case. if(!global) { ...} | ||
module.exports = g; | ||
/***/ }), | ||
/* 4 */ | ||
@@ -1811,3 +1816,175 @@ /***/ (function(module, exports, __webpack_require__) { | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var rng = __webpack_require__(11); | ||
var bytesToUuid = __webpack_require__(12); | ||
// **`v1()` - Generate time-based UUID** | ||
// | ||
// Inspired by https://github.com/LiosK/UUID.js | ||
// and http://docs.python.org/library/uuid.html | ||
// random #'s we need to init node and clockseq | ||
var _seedBytes = rng(); | ||
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) | ||
var _nodeId = [_seedBytes[0] | 0x01, _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]]; | ||
// Per 4.2.2, randomize (14 bit) clockseq | ||
var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; | ||
// Previous uuid creation time | ||
var _lastMSecs = 0, | ||
_lastNSecs = 0; | ||
// See https://github.com/broofa/node-uuid for API details | ||
function v1(options, buf, offset) { | ||
var i = buf && offset || 0; | ||
var b = buf || []; | ||
options = options || {}; | ||
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; | ||
// UUID timestamps are 100 nano-second units since the Gregorian epoch, | ||
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so | ||
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' | ||
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. | ||
var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); | ||
// Per 4.2.1.2, use count of uuid's generated during the current clock | ||
// cycle to simulate higher resolution clock | ||
var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; | ||
// Time since last uuid creation (in msecs) | ||
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; | ||
// Per 4.2.1.2, Bump clockseq on clock regression | ||
if (dt < 0 && options.clockseq === undefined) { | ||
clockseq = clockseq + 1 & 0x3fff; | ||
} | ||
// Reset nsecs if clock regresses (new clockseq) or we've moved onto a new | ||
// time interval | ||
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { | ||
nsecs = 0; | ||
} | ||
// Per 4.2.1.2 Throw error if too many uuids are requested | ||
if (nsecs >= 10000) { | ||
throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); | ||
} | ||
_lastMSecs = msecs; | ||
_lastNSecs = nsecs; | ||
_clockseq = clockseq; | ||
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch | ||
msecs += 12219292800000; | ||
// `time_low` | ||
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; | ||
b[i++] = tl >>> 24 & 0xff; | ||
b[i++] = tl >>> 16 & 0xff; | ||
b[i++] = tl >>> 8 & 0xff; | ||
b[i++] = tl & 0xff; | ||
// `time_mid` | ||
var tmh = msecs / 0x100000000 * 10000 & 0xfffffff; | ||
b[i++] = tmh >>> 8 & 0xff; | ||
b[i++] = tmh & 0xff; | ||
// `time_high_and_version` | ||
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version | ||
b[i++] = tmh >>> 16 & 0xff; | ||
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) | ||
b[i++] = clockseq >>> 8 | 0x80; | ||
// `clock_seq_low` | ||
b[i++] = clockseq & 0xff; | ||
// `node` | ||
var node = options.node || _nodeId; | ||
for (var n = 0; n < 6; ++n) { | ||
b[i + n] = node[n]; | ||
} | ||
return buf ? buf : bytesToUuid(b); | ||
} | ||
module.exports = v1; | ||
/***/ }), | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(global) { | ||
// Unique ID creation requires a high quality random # generator. In the | ||
// browser this is a little complicated due to unknown quality of Math.random() | ||
// and inconsistent support for the `crypto` API. We do the best we can via | ||
// feature-detection | ||
var rng; | ||
var crypto = global.crypto || global.msCrypto; // for IE 11 | ||
if (crypto && crypto.getRandomValues) { | ||
// WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto | ||
var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef | ||
rng = function whatwgRNG() { | ||
crypto.getRandomValues(rnds8); | ||
return rnds8; | ||
}; | ||
} | ||
if (!rng) { | ||
// Math.random()-based (RNG) | ||
// | ||
// If all else fails, use Math.random(). It's fast, but is of unspecified | ||
// quality. | ||
var rnds = new Array(16); | ||
rng = function rng() { | ||
for (var i = 0, r; i < 16; i++) { | ||
if ((i & 0x03) === 0) r = Math.random() * 0x100000000; | ||
rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; | ||
} | ||
return rnds; | ||
}; | ||
} | ||
module.exports = rng; | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) | ||
/***/ }), | ||
/* 12 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/** | ||
* Convert array of 16 byte values to UUID string format of the form: | ||
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | ||
*/ | ||
var byteToHex = []; | ||
for (var i = 0; i < 256; ++i) { | ||
byteToHex[i] = (i + 0x100).toString(16).substr(1); | ||
} | ||
function bytesToUuid(buf, offset) { | ||
var i = offset || 0; | ||
var bth = byteToHex; | ||
return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]]; | ||
} | ||
module.exports = bytesToUuid; | ||
/***/ }) | ||
/******/ ]); |
@@ -1,2 +0,2 @@ | ||
// [AIV] InCache Build version: 5.1.0 | ||
var incache=function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,r){"use strict";function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(h===setTimeout)return setTimeout(e,0);if((h===n||!h)&&setTimeout)return h=setTimeout,setTimeout(e,0);try{return h(e,0)}catch(t){try{return h.call(null,e,0)}catch(t){return h.call(this,e,0)}}}function s(e){if(c===clearTimeout)return clearTimeout(e);if((c===i||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{return c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}function a(){p&&d&&(p=!1,d.length?y=d.concat(y):m=-1,y.length&&u())}function u(){if(!p){var e=o(a);p=!0;for(var t=y.length;t;){for(d=y,y=[];++m<t;)d&&d[m].run();m=-1,t=y.length}d=null,p=!1,s(e)}}function l(e,t){this.fun=e,this.array=t}function f(){}var h,c,v=e.exports={};!function(){try{h="function"==typeof setTimeout?setTimeout:n}catch(e){h=n}try{c="function"==typeof clearTimeout?clearTimeout:i}catch(e){c=i}}();var d,y=[],p=!1,m=-1;v.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];y.push(new l(e,t)),1!==y.length||p||o(u)},l.prototype.run=function(){this.fun.apply(null,this.array)},v.title="browser",v.browser=!0,v.env={},v.argv=[],v.version="",v.versions={},v.on=f,v.addListener=f,v.once=f,v.off=f,v.removeListener=f,v.removeAllListeners=f,v.emit=f,v.prependListener=f,v.prependOnceListener=f,v.listeners=function(e){return[]},v.binding=function(e){throw new Error("process.binding is not supported")},v.cwd=function(){return"/"},v.chdir=function(e){throw new Error("process.chdir is not supported")},v.umask=function(){return 0}},function(e,t,r){"use strict";e.exports=r(2)},function(e,t,r){"use strict";(function(t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=r(4),a=r(5),u=r(9),l=function(){function e(){var r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this._emitter=new a,this._timerExpiryCheck=null,this.GLOBAL_KEY="___InCache___storage___global___key___",this.DEFAULT_CONFIG={storeName:"",save:!0,filePath:".incache",maxAge:0,expires:null,silent:!1,share:!0,autoRemovePeriod:0,nullIfNotFound:!1,global:{silent:!1,life:0}},this._onRemoved=function(){},this._onCreated=function(){},this._onUpdated=function(){},s.isServer()&&(t.stdin.resume(),t.on("exit",function(){r._write()}),t.on("SIGINT",function(){r._write()})),this.setConfig(n)}return o(e,[{key:"_write",value:function(){var e=this._memory,t=e.config,r=e.data;if(t.save){var n=JSON.stringify(r);u.writeFileSync(t.filePath,n)}}},{key:"_read",value:function(){var e=this._memory.config;if(e.save&&u.existsSync(e.filePath)){var t=u.readFileSync(e.filePath);try{this._storage=this._memory.data=JSON.parse(t)}catch(e){this._storage=this._memory.data={}}}}},{key:"setConfig",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.global&&(s.deprecated(t.global.life,"global.life is deprecated use maxAge instead"),s.deprecated(t.global.silent,"global.silent is deprecated use silent instead")),s.defaults(t,this.DEFAULT_CONFIG),this._opts=t,this._root=t.share?s.isServer()?n:window:{},t.storeName&&(this.GLOBAL_KEY+=t.storeName),this._root[this.GLOBAL_KEY]||(this._root[this.GLOBAL_KEY]={metadata:{lastSave:null},data:{},config:this.DEFAULT_CONFIG}),this._root[this.GLOBAL_KEY].config=t,this._memory=this._root[this.GLOBAL_KEY],this._storage=this._memory.data,s.isServer()&&this._read(),this._timerExpiryCheck&&(clearInterval(this._timerExpiryCheck),this._timerExpiryCheck=null),t.autoRemovePeriod&&(this._timerExpiryCheck=setInterval(function(){var t=e.removeExpired();t.length&&e._emitter.fire("expired",t)},1e3*t.autoRemovePeriod))}},{key:"getConfig",value:function(){return this._memory.config}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r.silent||!1!==this._emitter.fireTheFirst("beforeSet",e,t)){var n={isNew:!0,createdOn:null,updatedOn:null,expiresOn:null,value:t};return r=s.defaults(r,this.DEFAULT_CONFIG),r.expires&&(s.is(r.expires,"date")||s.is(r.expires,"string"))?n.expiresOn=new Date(r.expires):r.maxAge&&s.is(r.maxAge,"number")?n.expiresOn=s.addMSToNow(r.maxAge):r.life&&s.is(r.life,"number")&&(s.deprecated(r.life,"life is deprecated use maxAge instead"),n.expiresOn=s.addSecondsToNow(r.life)),this.has(e)?(n.isNew=!1,n.createdOn=this._storage[e].createdOn,n.updatedOn=new Date,r.silent||(this._onUpdated.call(this,e,n),this._emitter.fire("update",e,n))):(n.createdOn=new Date,r.silent||(this._onCreated.call(this,e,n),this._emitter.fire("create",e,n))),this._storage[e]=n,r.silent||this._emitter.fire("set",e,n),n}}},{key:"get",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.has(e)?!this._opts.autoRemovePeriod&&this.expired(e)?(this.remove(e,!0),this._opts.nullIfNotFound?null:void 0):t?this._storage[e].value:this._storage[e]:this._opts.nullIfNotFound?null:void 0}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(t||!1!==this._emitter.fireTheFirst("beforeRemove",e))&&(delete this._storage[e],t||(this._onRemoved.call(this,e),this._emitter.fire("remove",e)))}},{key:"removeFrom",value:function(e,t){if(!this.has(e))return null;if(s.is(t,"undefined"))throw new Error("where cannot be undefined");var r=this.get(e);if(!s.is(r,"array"))throw new Error("value must be an array");var n=r.length;for(var i in r)if(r.hasOwnProperty(i)){var o=[];for(var a in t)t.hasOwnProperty(a)&&(s.is(t,"object")?o.push(void 0!==r[i][a]&&r[i][a]===t[a]):o.push(r[i]===t));o.length&&-1===o.indexOf(!1)&&r.splice(i,1)}n!==r.length&&this.set(e,r)}},{key:"removeExpired",value:function(){var e=[];for(var t in this._storage)this._storage.hasOwnProperty(t)&&this.expired(t)&&(this.remove(t,!0),e.push(t));return e}},{key:"addTo",value:function(e,t){if(!this.has(e))return null;var r=this.get(e);if(!s.is(r,"array"))throw new Error("object must be an array");return r.push(t),this.set(e,r)}},{key:"prependTo",value:function(e,t){if(!this.has(e))return null;var r=this.get(e);if(!s.is(r,"array"))throw new Error("object must be an array");return r.unshift(t),this.set(e,r)}},{key:"updateIn",value:function(e,t,r){if(!this.has(e))return null;if(s.is(t,"undefined"))throw new Error("value cannot be undefined");if(s.is(r,"undefined"))throw new Error("where cannot be undefined");var n=this.get(e);if(!s.is(n,"array"))throw new Error("value must be an array");var i=!1;for(var o in n)if(n.hasOwnProperty(o)){var a=[];for(var u in r)r.hasOwnProperty(u)&&(s.is(r,"object")?a.push(void 0!==n[o][u]&&n[o][u]===r[u]):a.push(n[o]===r));a.length&&-1===a.indexOf(!1)&&(i=!0,n[o]=t)}i&&this.set(e,n)}},{key:"bulkSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!s.is(e,"array"))throw new Error("records must be an array of object, e.g. {key: foo, value: bar}");if(t||!1!==this._emitter.fireTheFirst("beforeBulkSet",e)){for(var r=0;r<e.length;r++){if(s.is(e[r].key,"undefined")||s.is(e[r].value,"undefined"))throw new Error("key and value properties are required");this.set(e[r].key,e[r].value,{silent:!0,fromBulk:!0})}t||this._emitter.fire("bulkSet",e)}}},{key:"bulkRemove",value:function(e,t){if(!s.is(e,"array"))throw new Error("keys must be an array of keys");if(t||!1!==this._emitter.fireTheFirst("beforeBulkRemove",e)){for(var r=0;r<e.length;r++)this.remove(e[r],!0);t||this._emitter.fire("bulkRemove",e)}}},{key:"clean",value:function(e){if(!s.is(e,"string"))throw new Error("key must be a string");for(var t in this._storage)this._storage.hasOwnProperty(t)&&-1!==t.indexOf(e)&&delete this._storage[t]}},{key:"all",value:function(){var e=[];for(var t in this._storage)this._storage.hasOwnProperty(t)&&(!this._opts.autoRemovePeriod&&this.expired(t)?this.remove(t,!0):e.push({key:t,value:this._storage[t].value}));return e}},{key:"expired",value:function(e){if(this._storage[e]&&this._storage[e].expiresOn){return new Date>new Date(this._storage[e].expiresOn)}return!1}},{key:"clear",value:function(){this._storage=this._memory.data={}}},{key:"has",value:function(e){return this._storage.hasOwnProperty(e)}},{key:"destroy",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this.remove.apply(this,t)}},{key:"on",value:function(e,t){this._emitter.on.call(this._emitter,e,t)}},{key:"onRemoved",value:function(e){this._onRemoved=e}},{key:"onCreated",value:function(e){this._onCreated=e}},{key:"onUpdated",value:function(e){this._onUpdated=e}}]),e}();e.exports=l}).call(t,r(0),r(3))},function(e,t,r){"use strict";var n,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":i(window))&&(n=window)}e.exports=n},function(e,t,r){"use strict";(function(t){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n={};n.is=function(e,t){return Object.prototype.toString.call(e).toLowerCase()==="[object "+t+"]".toLowerCase()},n.defaults=function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e.hasOwnProperty(i)?"object"===r(e[i])&&n.defaults(e[i],t[i]):e[i]=t[i]);return e},n.addSecondsToNow=function(e){var t=new Date;return new Date(t.setSeconds(t.getSeconds()+e))},n.addMSToNow=function(e){var t=new Date;return new Date(t.setMilliseconds(t.getMilliseconds()+e))},n.isServer=function(){return"object"===(void 0===t?"undefined":r(t))&&void 0!==t.pid},n.deprecated=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"warn";return void 0!==e&&(console[r](t||e),!0)},e.exports=n}).call(t,r(0))},function(e,t,r){"use strict";e.exports=r(6)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(7),s=r(8),a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e),this.defaultClassOpts={maxListeners:10,asyncDelay:10},this.defaultListenerOpts={maxCalls:0,prepend:!1},this.opts=o.defaults(t,this.defaultClassOpts),this.events={}}return i(e,[{key:"_createEvent",value:function(e,t,r){if(this.events[e]||(this.events[e]=[]),this.opts.maxListeners){var n=this.opts.maxListeners;if(this.events[e].length>=n)throw new Error(s[3]+n)}t.opts=o.defaults(r,this.defaultListenerOpts),t.info={calls:0},r.prepend?this.events[e].unshift(t):this.events[e].push(t),this._created.call(this,e,t,r)}},{key:"_callEvent",value:function(e,t,r){return t.opts.maxCalls&&t.info.calls++>=t.opts.maxCalls?void this.off(e,t):(this._catchAll.call(this,r),t.apply(this,r))}},{key:"_created",value:function(){}},{key:"_removed",value:function(){}},{key:"_catchAll",value:function(){}},{key:"on",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!o.is(e,"string"))throw new Error(s[0]);if(e=e.trim(),!e.length)throw new Error(s[4]);if(o.is(t,"array")){for(var n in t)if(t.hasOwnProperty(n)){if(!o.is(t[n],"function"))throw new Error(s[1]);this._createEvent(e,t[n],r)}}else{if(!o.is(t,"function"))throw new Error(s[1]);this._createEvent(e,t,r)}return this}},{key:"once",value:function(e,t){return this.on(e,t,{maxCalls:1})}},{key:"fire",value:function(e){if(this.exists(e)){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var i=0;i<this.events[e].length;i++)this._callEvent(e,this.events[e][i],r)}return this}},{key:"fireTheFirst",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(this.exists(e))return this._callEvent(e,this.events[e][0],r)}},{key:"fireAsync",value:function(e){for(var t=this,r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.unshift(e),setTimeout(function(){t.fire.apply(t,n)},this.opts.asyncDelay)}},{key:"off",value:function(e,t){if(!o.is(e,"string"))throw new Error(s[0]);if(this.events[e])if("function"==typeof t)for(var r=0;r<this.events[e].length;r++)this.events[e][r]===t&&(this.events[e].splice(r,1),this._removed.call(this,e,t));else delete this.events[e],this._removed.call(this,e);return this}},{key:"prependListener",value:function(e,t){return this.on(e,t,{prepend:!0})}},{key:"prependOnceListener",value:function(e,t){return this.on(e,t,{maxCalls:1,prepend:!0})}},{key:"clear",value:function(){return this.events=[],this}},{key:"getListenersCount",value:function(e){return this.getListeners(e).length}},{key:"getListeners",value:function(e){if(!o.is(e,"string"))throw new Error(s[0]);if(!this.exists(e))throw new Error(s[5]);return this.events[e]}},{key:"getEvents",value:function(){return this.events}},{key:"exists",value:function(e){if(!o.is(e,"string"))throw new Error(s[0]);return!o.is(this.events[e],"undefined")}},{key:"getMaxListeners",value:function(){return this.opts.maxListeners}},{key:"setMaxListeners",value:function(e){if(!o.is(e,"number"))throw new Error(s[2]);return this.opts.maxListeners=e,this}},{key:"onCatchAll",value:function(e){return this._catchAll=e,this}},{key:"onCreated",value:function(e){return this._created=e,this}},{key:"onRemoved",value:function(e){return this._removed=e,this}}]),e}();e.exports=a,e.exports._error=s},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i={};i.is=function(e,t){return Object.prototype.toString.call(e).toLowerCase()==="[object "+t+"]".toLowerCase()},i.defaults=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e.hasOwnProperty(r)?"object"===n(e[r])&&i.defaults(e[r],t[r]):e[r]=t[r]);return e},e.exports=i},function(e,t,r){"use strict";e.exports=["event name is required and must be a string","listener is required and must be a function or an array of function","value must be a number","increase maxListeners per event: ","event name not valid","event not found"]},function(e,t,r){"use strict"}]); | ||
// [AIV] InCache Build version: 5.2.0 | ||
var incache=function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function s(e){if(h===clearTimeout)return clearTimeout(e);if((h===i||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}function a(){p&&d&&(p=!1,d.length?y=d.concat(y):m=-1,y.length&&u())}function u(){if(!p){var e=o(a);p=!0;for(var t=y.length;t;){for(d=y,y=[];++m<t;)d&&d[m].run();m=-1,t=y.length}d=null,p=!1,s(e)}}function l(e,t){this.fun=e,this.array=t}function f(){}var c,h,v=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:n}catch(e){c=n}try{h="function"==typeof clearTimeout?clearTimeout:i}catch(e){h=i}}();var d,y=[],p=!1,m=-1;v.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];y.push(new l(e,t)),1!==y.length||p||o(u)},l.prototype.run=function(){this.fun.apply(null,this.array)},v.title="browser",v.browser=!0,v.env={},v.argv=[],v.version="",v.versions={},v.on=f,v.addListener=f,v.once=f,v.off=f,v.removeListener=f,v.removeAllListeners=f,v.emit=f,v.prependListener=f,v.prependOnceListener=f,v.listeners=function(e){return[]},v.binding=function(e){throw new Error("process.binding is not supported")},v.cwd=function(){return"/"},v.chdir=function(e){throw new Error("process.chdir is not supported")},v.umask=function(){return 0}},function(e,t,r){"use strict";var n,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":i(window))&&(n=window)}e.exports=n},function(e,t,r){"use strict";e.exports=r(3)},function(e,t,r){"use strict";(function(t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=r(4),a=r(5),u=r(9),l=r(10),f=function(){function e(){var r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this._emitter=new a,this._timerExpiryCheck=null,this.GLOBAL_KEY="___InCache___storage___global___key___",this.DEFAULT_CONFIG={storeName:"",save:!1,filePath:".incache",maxAge:0,expires:null,silent:!1,share:!1,autoRemovePeriod:0,nullIfNotFound:!1,global:{silent:!1,life:0}},this._onRemoved=function(){},this._onCreated=function(){},this._onUpdated=function(){},s.isServer()&&(t.stdin.resume(),t.on("exit",function(){r._write()}),t.on("SIGINT",function(){r._write()})),this.setConfig(n)}return o(e,[{key:"_write",value:function(){var e=this._memory,t=e.config,r=e.data;if(t.save){var n=JSON.stringify(r);u.writeFileSync(t.filePath,n)}}},{key:"_read",value:function(){var e=this._memory.config;if(e.save&&u.existsSync(e.filePath)){var t=u.readFileSync(e.filePath);try{this._storage=this._memory.data=JSON.parse(t)}catch(e){this._storage=this._memory.data={}}}}},{key:"setConfig",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.global&&(s.deprecated(t.global.life,"global.life is deprecated use maxAge instead"),s.deprecated(t.global.silent,"global.silent is deprecated use silent instead")),s.defaults(t,this.DEFAULT_CONFIG),this._opts=t,this._root=t.share?s.isServer()?n:window:{},t.storeName&&(this.GLOBAL_KEY+=t.storeName),this._root[this.GLOBAL_KEY]||(this._root[this.GLOBAL_KEY]={metadata:{lastSave:null},data:{},config:this.DEFAULT_CONFIG}),this._root[this.GLOBAL_KEY].config=t,this._memory=this._root[this.GLOBAL_KEY],this._storage=this._memory.data,s.isServer()&&this._read(),this._timerExpiryCheck&&(clearInterval(this._timerExpiryCheck),this._timerExpiryCheck=null),t.autoRemovePeriod&&(this._timerExpiryCheck=setInterval(function(){var t=e.removeExpired();t.length&&e._emitter.fire("expired",t)},1e3*t.autoRemovePeriod))}},{key:"getConfig",value:function(){return this._memory.config}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r.silent||!1!==this._emitter.fireTheFirst("beforeSet",e,t)){var n={id:null,isNew:!0,createdOn:null,updatedOn:null,expiresOn:null,value:t};return r=s.defaults(r,this.DEFAULT_CONFIG),r.expires&&(s.is(r.expires,"date")||s.is(r.expires,"string"))?n.expiresOn=new Date(r.expires):r.maxAge&&s.is(r.maxAge,"number")?n.expiresOn=s.addMSToNow(r.maxAge):r.life&&s.is(r.life,"number")&&(s.deprecated(r.life,"life is deprecated use maxAge instead"),n.expiresOn=s.addSecondsToNow(r.life)),this.has(e)?(n.isNew=!1,n.id=this._storage[e].id,n.createdOn=this._storage[e].createdOn,n.updatedOn=new Date,r.silent||(this._onUpdated.call(this,e,n),this._emitter.fire("update",e,n))):(n.id=l(),n.createdOn=new Date,r.silent||(this._onCreated.call(this,e,n),this._emitter.fire("create",e,n))),this._storage[e]=n,r.silent||this._emitter.fire("set",e,n),n}}},{key:"get",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.has(e)?!this._opts.autoRemovePeriod&&this.expired(e)?(this.remove(e,!0),this._opts.nullIfNotFound?null:void 0):t?this._storage[e].value:this._storage[e]:this._opts.nullIfNotFound?null:void 0}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(t||!1!==this._emitter.fireTheFirst("beforeRemove",e))&&(delete this._storage[e],t||(this._onRemoved.call(this,e),this._emitter.fire("remove",e)))}},{key:"removeFrom",value:function(e,t){if(!this.has(e))return null;if(s.is(t,"undefined"))throw new Error("where cannot be undefined");var r=this.get(e);if(!s.is(r,"array"))throw new Error("value must be an array");var n=r.length;for(var i in r)if(r.hasOwnProperty(i)){var o=[];for(var a in t)t.hasOwnProperty(a)&&(s.is(t,"object")?o.push(void 0!==r[i][a]&&r[i][a]===t[a]):o.push(r[i]===t));o.length&&-1===o.indexOf(!1)&&r.splice(i,1)}n!==r.length&&this.set(e,r)}},{key:"removeExpired",value:function(){var e=[];for(var t in this._storage)this._storage.hasOwnProperty(t)&&this.expired(t)&&(this.remove(t,!0),e.push(t));return e}},{key:"addTo",value:function(e,t){if(!this.has(e))return null;var r=this.get(e);if(!s.is(r,"array"))throw new Error("object must be an array");return r.push(t),this.set(e,r)}},{key:"prependTo",value:function(e,t){if(!this.has(e))return null;var r=this.get(e);if(!s.is(r,"array"))throw new Error("object must be an array");return r.unshift(t),this.set(e,r)}},{key:"updateIn",value:function(e,t,r){if(!this.has(e))return null;if(s.is(t,"undefined"))throw new Error("value cannot be undefined");if(s.is(r,"undefined"))throw new Error("where cannot be undefined");var n=this.get(e);if(!s.is(n,"array"))throw new Error("value must be an array");var i=!1;for(var o in n)if(n.hasOwnProperty(o)){var a=[];for(var u in r)r.hasOwnProperty(u)&&(s.is(r,"object")?a.push(void 0!==n[o][u]&&n[o][u]===r[u]):a.push(n[o]===r));a.length&&-1===a.indexOf(!1)&&(i=!0,n[o]=t)}i&&this.set(e,n)}},{key:"bulkSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!s.is(e,"array"))throw new Error("records must be an array of object, e.g. {key: foo, value: bar}");if(t||!1!==this._emitter.fireTheFirst("beforeBulkSet",e)){for(var r=0;r<e.length;r++){if(s.is(e[r].key,"undefined")||s.is(e[r].value,"undefined"))throw new Error("key and value properties are required");this.set(e[r].key,e[r].value,{silent:!0,fromBulk:!0})}t||this._emitter.fire("bulkSet",e)}}},{key:"bulkRemove",value:function(e,t){if(!s.is(e,"array"))throw new Error("keys must be an array of keys");if(t||!1!==this._emitter.fireTheFirst("beforeBulkRemove",e)){for(var r=0;r<e.length;r++)this.remove(e[r],!0);t||this._emitter.fire("bulkRemove",e)}}},{key:"clean",value:function(e){if(!s.is(e,"string"))throw new Error("key must be a string");for(var t in this._storage)this._storage.hasOwnProperty(t)&&-1!==t.indexOf(e)&&delete this._storage[t]}},{key:"all",value:function(){var e=[];for(var t in this._storage)this._storage.hasOwnProperty(t)&&(!this._opts.autoRemovePeriod&&this.expired(t)?this.remove(t,!0):e.push({key:t,value:this._storage[t].value}));return e}},{key:"expired",value:function(e){if(this._storage[e]&&this._storage[e].expiresOn){return new Date>new Date(this._storage[e].expiresOn)}return!1}},{key:"clear",value:function(){this._storage=this._memory.data={}}},{key:"has",value:function(e){return this._storage.hasOwnProperty(e)}},{key:"destroy",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this.remove.apply(this,t)}},{key:"on",value:function(e,t){this._emitter.on.call(this._emitter,e,t)}},{key:"onRemoved",value:function(e){this._onRemoved=e}},{key:"onCreated",value:function(e){this._onCreated=e}},{key:"onUpdated",value:function(e){this._onUpdated=e}}]),e}();e.exports=f}).call(t,r(0),r(1))},function(e,t,r){"use strict";(function(t){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n={};n.is=function(e,t){return Object.prototype.toString.call(e).toLowerCase()==="[object "+t+"]".toLowerCase()},n.defaults=function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e.hasOwnProperty(i)?"object"===r(e[i])&&n.defaults(e[i],t[i]):e[i]=t[i]);return e},n.addSecondsToNow=function(e){var t=new Date;return new Date(t.setSeconds(t.getSeconds()+e))},n.addMSToNow=function(e){var t=new Date;return new Date(t.setMilliseconds(t.getMilliseconds()+e))},n.isServer=function(){return"object"===(void 0===t?"undefined":r(t))&&void 0!==t.pid},n.deprecated=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"warn";return void 0!==e&&(console[r](t||e),!0)},e.exports=n}).call(t,r(0))},function(e,t,r){"use strict";e.exports=r(6)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(7),s=r(8),a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e),this.defaultClassOpts={maxListeners:10,asyncDelay:10},this.defaultListenerOpts={maxCalls:0,prepend:!1},this.opts=o.defaults(t,this.defaultClassOpts),this.events={}}return i(e,[{key:"_createEvent",value:function(e,t,r){if(this.events[e]||(this.events[e]=[]),this.opts.maxListeners){var n=this.opts.maxListeners;if(this.events[e].length>=n)throw new Error(s[3]+n)}t.opts=o.defaults(r,this.defaultListenerOpts),t.info={calls:0},r.prepend?this.events[e].unshift(t):this.events[e].push(t),this._created.call(this,e,t,r)}},{key:"_callEvent",value:function(e,t,r){return t.opts.maxCalls&&t.info.calls++>=t.opts.maxCalls?void this.off(e,t):(this._catchAll.call(this,r),t.apply(this,r))}},{key:"_created",value:function(){}},{key:"_removed",value:function(){}},{key:"_catchAll",value:function(){}},{key:"on",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!o.is(e,"string"))throw new Error(s[0]);if(e=e.trim(),!e.length)throw new Error(s[4]);if(o.is(t,"array")){for(var n in t)if(t.hasOwnProperty(n)){if(!o.is(t[n],"function"))throw new Error(s[1]);this._createEvent(e,t[n],r)}}else{if(!o.is(t,"function"))throw new Error(s[1]);this._createEvent(e,t,r)}return this}},{key:"once",value:function(e,t){return this.on(e,t,{maxCalls:1})}},{key:"fire",value:function(e){if(this.exists(e)){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var i=0;i<this.events[e].length;i++)this._callEvent(e,this.events[e][i],r)}return this}},{key:"fireTheFirst",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(this.exists(e))return this._callEvent(e,this.events[e][0],r)}},{key:"fireAsync",value:function(e){for(var t=this,r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.unshift(e),setTimeout(function(){t.fire.apply(t,n)},this.opts.asyncDelay)}},{key:"off",value:function(e,t){if(!o.is(e,"string"))throw new Error(s[0]);if(this.events[e])if("function"==typeof t)for(var r=0;r<this.events[e].length;r++)this.events[e][r]===t&&(this.events[e].splice(r,1),this._removed.call(this,e,t));else delete this.events[e],this._removed.call(this,e);return this}},{key:"prependListener",value:function(e,t){return this.on(e,t,{prepend:!0})}},{key:"prependOnceListener",value:function(e,t){return this.on(e,t,{maxCalls:1,prepend:!0})}},{key:"clear",value:function(){return this.events=[],this}},{key:"getListenersCount",value:function(e){return this.getListeners(e).length}},{key:"getListeners",value:function(e){if(!o.is(e,"string"))throw new Error(s[0]);if(!this.exists(e))throw new Error(s[5]);return this.events[e]}},{key:"getEvents",value:function(){return this.events}},{key:"exists",value:function(e){if(!o.is(e,"string"))throw new Error(s[0]);return!o.is(this.events[e],"undefined")}},{key:"getMaxListeners",value:function(){return this.opts.maxListeners}},{key:"setMaxListeners",value:function(e){if(!o.is(e,"number"))throw new Error(s[2]);return this.opts.maxListeners=e,this}},{key:"onCatchAll",value:function(e){return this._catchAll=e,this}},{key:"onCreated",value:function(e){return this._created=e,this}},{key:"onRemoved",value:function(e){return this._removed=e,this}}]),e}();e.exports=a,e.exports._error=s},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i={};i.is=function(e,t){return Object.prototype.toString.call(e).toLowerCase()==="[object "+t+"]".toLowerCase()},i.defaults=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e.hasOwnProperty(r)?"object"===n(e[r])&&i.defaults(e[r],t[r]):e[r]=t[r]);return e},e.exports=i},function(e,t,r){"use strict";e.exports=["event name is required and must be a string","listener is required and must be a function or an array of function","value must be a number","increase maxListeners per event: ","event name not valid","event not found"]},function(e,t,r){"use strict"},function(e,t,r){"use strict";function n(e,t,r){var n=t&&r||0,i=t||[];e=e||{};var s=void 0!==e.clockseq?e.clockseq:u,c=void 0!==e.msecs?e.msecs:(new Date).getTime(),h=void 0!==e.nsecs?e.nsecs:f+1,v=c-l+(h-f)/1e4;if(v<0&&void 0===e.clockseq&&(s=s+1&16383),(v<0||c>l)&&void 0===e.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=c,f=h,u=s,c+=122192928e5;var d=(1e4*(268435455&c)+h)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=255&d;var y=c/4294967296*1e4&268435455;i[n++]=y>>>8&255,i[n++]=255&y,i[n++]=y>>>24&15|16,i[n++]=y>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var p=e.node||a,m=0;m<6;++m)i[n+m]=p[m];return t||o(i)}var i=r(11),o=r(12),s=i(),a=[1|s[0],s[1],s[2],s[3],s[4],s[5]],u=16383&(s[6]<<8|s[7]),l=0,f=0;e.exports=n},function(e,t,r){"use strict";(function(t){var r,n=t.crypto||t.msCrypto;if(n&&n.getRandomValues){var i=new Uint8Array(16);r=function(){return n.getRandomValues(i),i}}if(!r){var o=new Array(16);r=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}e.exports=r}).call(t,r(1))},function(e,t,r){"use strict";function n(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}for(var i=[],o=0;o<256;++o)i[o]=(o+256).toString(16).substr(1);e.exports=n}]); |
{ | ||
"name": "incache", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "Simple key/value in-memory storage or on disk to persist some data", | ||
@@ -54,4 +54,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"flak": "^0.3.0" | ||
"flak": "^0.3.0", | ||
"uuid": "^3.1.0" | ||
} | ||
} |
@@ -24,3 +24,5 @@ <div align="center"> | ||
## Example | ||
## Examples | ||
### Basic | ||
```javascript | ||
@@ -48,5 +50,13 @@ const InCache = require('incache'); | ||
### Some events | ||
### Save on disk | ||
This operation is running when the process is terminated | ||
```javascript | ||
const store = new InCache({ | ||
save: true | ||
}); | ||
``` | ||
### Events | ||
```javascript | ||
// Triggered when a record has been deleted | ||
@@ -57,2 +67,9 @@ incache.on('remove', key => { | ||
// Triggered before create/update | ||
incache.on('beforeSet', (key, value) => { | ||
console.log(key, value); | ||
if(foo) | ||
return false; | ||
}); | ||
// Triggered when a record has been created | ||
@@ -59,0 +76,0 @@ incache.on('create', (key, record) => { |
const helper = require('./helper'); | ||
const Flak = require('flak'); | ||
const fs = require('fs'); | ||
const uuid = require('uuid/v1'); | ||
@@ -13,6 +14,6 @@ class InCache { | ||
* @param [opts.silent=false] {boolean} if true no event will be triggered | ||
* @param [opts.save=true] {boolean} if true saves cache in disk. (server only) | ||
* @param [opts.save=false] {boolean} if true saves cache in disk when the process is terminated. (server only) | ||
* @param [opts.filePath=.incache] {string} cache file path | ||
* @param [opts.storeName] {string} store name | ||
* @param [opts.share=true] {boolean} if true use global object as storage | ||
* @param [opts.share=false] {boolean} if true use global object as storage | ||
* @param [opts.autoRemovePeriod=0] {number} period in seconds to remove expired records. When set, the records will be removed only on check, when 0 it won't run | ||
@@ -46,3 +47,3 @@ * @param [opts.nullIfNotFound=true] {boolean} calling `get` if the key is not found returns `null`. If false returns `undefined` | ||
storeName: '', | ||
save: true, | ||
save: false, | ||
filePath: '.incache', | ||
@@ -52,3 +53,3 @@ maxAge: 0, | ||
silent: false, | ||
share: true, | ||
share: false, | ||
autoRemovePeriod: 0, | ||
@@ -178,2 +179,3 @@ nullIfNotFound: false, | ||
* @typedef {Object} InCache~record | ||
* @property {string} id - uuid | ||
* @property {boolean} isNew - indicates if is a new record | ||
@@ -212,2 +214,3 @@ * @property {Date|null} createdOn - creation date | ||
let record = { | ||
id: null, | ||
isNew: true, | ||
@@ -233,2 +236,3 @@ createdOn: null, | ||
record.isNew = false; | ||
record.id = this._storage[key].id; | ||
record.createdOn = this._storage[key].createdOn; | ||
@@ -241,2 +245,3 @@ record.updatedOn = new Date(); | ||
} else { | ||
record.id = uuid(); | ||
record.createdOn = new Date(); | ||
@@ -243,0 +248,0 @@ if (!opts.silent) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112591
2389
113
2
+ Addeduuid@^3.1.0
+ Addeduuid@3.4.0(transitive)