Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

incache

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

incache - npm Package Compare versions

Comparing version 4.1.2 to 4.2.0

3

CHANGELOG.md

@@ -7,2 +7,5 @@ # Change Log

## [4.2.0] - 2017-09-01
- Added new property to configuration: `share`, now is possible disable global storage
## [4.1.2] - 2017-08-30

@@ -9,0 +12,0 @@ - Fixed `record.createdOn` is null, it happened when record was updated

25

dist/incache.js

@@ -1,2 +0,2 @@

// [AIV] InCache Build version: 4.1.2
// [AIV] InCache Build version: 4.2.0
var incache =

@@ -275,3 +275,3 @@ /******/ (function(modules) { // webpackBootstrap

"use strict";
/* WEBPACK VAR INJECTION */(function(global, process) {
/* WEBPACK VAR INJECTION */(function(process, global) {

@@ -296,2 +296,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

* @param [opts.storeName] {string} store name
* @param [opts.share=true] {boolean} if true use global object as storage
* @param [opts.global] {Object} **deprecated:** global record configuration

@@ -318,8 +319,2 @@ * @param [opts.global.silent=false] {boolean} **deprecated:** if true no event will be triggered, use `silent` instead

/**
* Root object
* @ignore
*/
this._root = helper.isServer() ? global : window;
/**
* InCache default configuration

@@ -336,2 +331,3 @@ * @ignore

silent: false,
share: true,
global: {

@@ -398,2 +394,11 @@ silent: false,

helper.defaults(opts, this.DEFAULT_CONFIG);
/**
* Root object
* @ignore
*/
this._root = opts.share ? helper.isServer() ? global : window : {};
if (opts.storeName) this.GLOBAL_KEY += opts.storeName;

@@ -416,3 +421,3 @@

this._root[this.GLOBAL_KEY].config = helper.defaults(opts, this.DEFAULT_CONFIG);
this._root[this.GLOBAL_KEY].config = opts;

@@ -918,3 +923,3 @@ this._memory = this._root[this.GLOBAL_KEY];

module.exports = InCache;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3), __webpack_require__(0)))
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(3)))

@@ -921,0 +926,0 @@ /***/ }),

@@ -1,2 +0,2 @@

// [AIV] InCache Build version: 4.1.2
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(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function a(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 s(){p&&v&&(p=!1,v.length?y=v.concat(y):m=-1,y.length&&u())}function u(){if(!p){var e=o(s);p=!0;for(var t=y.length;t;){for(v=y,y=[];++m<t;)v&&v[m].run();m=-1,t=y.length}v=null,p=!1,a(e)}}function l(e,t){this.fun=e,this.array=t}function c(){}var f,h,d=e.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=n}try{h="function"==typeof clearTimeout?clearTimeout:i}catch(e){h=i}}();var v,y=[],p=!1,m=-1;d.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)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.prependListener=c,d.prependOnceListener=c,d.listeners=function(e){return[]},d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.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}}(),a=r(4),s=r(5),u=function(){function e(){var r=this,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this.GLOBAL_KEY="___InCache___storage___global___key___",this._root=a.isServer()?t:window,this.DEFAULT_CONFIG={storeName:"",save:!0,filePath:".incache",maxAge:0,expires:null,silent:!1,global:{silent:!1,life:0}},this._onRemoved=function(){},this._onCreated=function(){},this._onUpdated=function(){},a.isServer()&&(n.stdin.resume(),n.on("exit",function(){r._write()}),n.on("SIGINT",function(){r._write()})),this.setConfig(o)}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);s.writeFileSync(t.filePath,n)}}},{key:"_read",value:function(){var e=this._memory.config;if(e.save&&s.existsSync(e.filePath)){var t=s.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=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.storeName&&(this.GLOBAL_KEY+=e.storeName),this._root[this.GLOBAL_KEY]||(this._root[this.GLOBAL_KEY]={metadata:{lastSave:null},data:{},config:this.DEFAULT_CONFIG}),e.global&&(a.deprecated(e.global.life,"global.life is deprecated use maxAge instead"),a.deprecated(e.global.silent,"global.silent is deprecated use silent instead")),this._root[this.GLOBAL_KEY].config=a.defaults(e,this.DEFAULT_CONFIG),this._memory=this._root[this.GLOBAL_KEY],this._storage=this._memory.data,a.isServer()&&this._read()}},{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]:{},n={isNew:!0,createdOn:null,updatedOn:null,expiresOn:null,value:t};return r=a.defaults(r,this.DEFAULT_CONFIG),r.expires&&(a.is(r.expires,"date")||a.is(r.expires,"string"))?n.expiresOn=new Date(r.expires):r.maxAge&&a.is(r.maxAge,"number")?n.expiresOn=a.addMSToNow(r.maxAge):r.life&&a.is(r.life,"number")&&(a.deprecated(r.life,"life is deprecated use maxAge instead"),n.expiresOn=a.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)):(n.createdOn=new Date,r.silent||this._onCreated.call(this,e,n)),this._storage[e]=n,n}},{key:"get",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.has(e)?this.expired(e)?(this.remove(e,!0),null):t?this._storage[e].value:this._storage[e]:null}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];delete this._storage[e],t||this._onRemoved.call(this,e)}},{key:"removeFrom",value:function(e,t){if(!this.has(e))return null;if(a.is(t,"undefined"))throw new Error("where cannot be undefined");var r=this.get(e);if(!a.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 s in t)t.hasOwnProperty(s)&&(a.is(t,"object")?o.push(void 0!==r[i][s]&&r[i][s]===t[s]):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(){for(var e in this._storage)this._storage.hasOwnProperty(e)&&this.expired(e)&&this.remove(e,!0)}},{key:"addTo",value:function(e,t){if(!this.has(e))return null;var r=this.get(e);if(!a.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(!a.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(a.is(t,"undefined"))throw new Error("value cannot be undefined");if(a.is(r,"undefined"))throw new Error("where cannot be undefined");var n=this.get(e);if(!a.is(n,"array"))throw new Error("value must be an array");var i=!1;for(var o in n)if(n.hasOwnProperty(o)){var s=[];for(var u in r)r.hasOwnProperty(u)&&(a.is(r,"object")?s.push(void 0!==n[o][u]&&n[o][u]===r[u]):s.push(n[o]===r));s.length&&-1===s.indexOf(!1)&&(i=!0,n[o]=t)}i&&this.set(e,n)}},{key:"bulkSet",value:function(e){if(!a.is(e,"array"))throw new Error("records must be an array of object, e.g. {key: foo, value: bar}");for(var t=0;t<e.length;t++){if(a.is(e[t].key,"undefined")||a.is(e[t].value,"undefined"))throw new Error("key and value properties are required");this.set(e[t].key,e[t].value,{silent:!0,fromBulk:!0})}}},{key:"bulkRemove",value:function(e){if(!a.is(e,"array"))throw new Error("keys must be an array of keys");for(var t=0;t<e.length;t++)this.remove(e[t],!0)}},{key:"clean",value:function(e){if(!a.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.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:"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=u}).call(t,r(3),r(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";(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"}]);
// [AIV] InCache Build version: 4.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=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(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function a(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 s(){p&&v&&(p=!1,v.length?y=v.concat(y):m=-1,y.length&&u())}function u(){if(!p){var e=o(s);p=!0;for(var t=y.length;t;){for(v=y,y=[];++m<t;)v&&v[m].run();m=-1,t=y.length}v=null,p=!1,a(e)}}function l(e,t){this.fun=e,this.array=t}function c(){}var f,h,d=e.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=n}try{h="function"==typeof clearTimeout?clearTimeout:i}catch(e){h=i}}();var v,y=[],p=!1,m=-1;d.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)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.prependListener=c,d.prependOnceListener=c,d.listeners=function(e){return[]},d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.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}}(),a=r(4),s=r(5),u=function(){function e(){var r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this.GLOBAL_KEY="___InCache___storage___global___key___",this.DEFAULT_CONFIG={storeName:"",save:!0,filePath:".incache",maxAge:0,expires:null,silent:!1,share:!0,global:{silent:!1,life:0}},this._onRemoved=function(){},this._onCreated=function(){},this._onUpdated=function(){},a.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);s.writeFileSync(t.filePath,n)}}},{key:"_read",value:function(){var e=this._memory.config;if(e.save&&s.existsSync(e.filePath)){var t=s.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=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a.defaults(e,this.DEFAULT_CONFIG),this._root=e.share?a.isServer()?n:window:{},e.storeName&&(this.GLOBAL_KEY+=e.storeName),this._root[this.GLOBAL_KEY]||(this._root[this.GLOBAL_KEY]={metadata:{lastSave:null},data:{},config:this.DEFAULT_CONFIG}),e.global&&(a.deprecated(e.global.life,"global.life is deprecated use maxAge instead"),a.deprecated(e.global.silent,"global.silent is deprecated use silent instead")),this._root[this.GLOBAL_KEY].config=e,this._memory=this._root[this.GLOBAL_KEY],this._storage=this._memory.data,a.isServer()&&this._read()}},{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]:{},n={isNew:!0,createdOn:null,updatedOn:null,expiresOn:null,value:t};return r=a.defaults(r,this.DEFAULT_CONFIG),r.expires&&(a.is(r.expires,"date")||a.is(r.expires,"string"))?n.expiresOn=new Date(r.expires):r.maxAge&&a.is(r.maxAge,"number")?n.expiresOn=a.addMSToNow(r.maxAge):r.life&&a.is(r.life,"number")&&(a.deprecated(r.life,"life is deprecated use maxAge instead"),n.expiresOn=a.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)):(n.createdOn=new Date,r.silent||this._onCreated.call(this,e,n)),this._storage[e]=n,n}},{key:"get",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.has(e)?this.expired(e)?(this.remove(e,!0),null):t?this._storage[e].value:this._storage[e]:null}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];delete this._storage[e],t||this._onRemoved.call(this,e)}},{key:"removeFrom",value:function(e,t){if(!this.has(e))return null;if(a.is(t,"undefined"))throw new Error("where cannot be undefined");var r=this.get(e);if(!a.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 s in t)t.hasOwnProperty(s)&&(a.is(t,"object")?o.push(void 0!==r[i][s]&&r[i][s]===t[s]):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(){for(var e in this._storage)this._storage.hasOwnProperty(e)&&this.expired(e)&&this.remove(e,!0)}},{key:"addTo",value:function(e,t){if(!this.has(e))return null;var r=this.get(e);if(!a.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(!a.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(a.is(t,"undefined"))throw new Error("value cannot be undefined");if(a.is(r,"undefined"))throw new Error("where cannot be undefined");var n=this.get(e);if(!a.is(n,"array"))throw new Error("value must be an array");var i=!1;for(var o in n)if(n.hasOwnProperty(o)){var s=[];for(var u in r)r.hasOwnProperty(u)&&(a.is(r,"object")?s.push(void 0!==n[o][u]&&n[o][u]===r[u]):s.push(n[o]===r));s.length&&-1===s.indexOf(!1)&&(i=!0,n[o]=t)}i&&this.set(e,n)}},{key:"bulkSet",value:function(e){if(!a.is(e,"array"))throw new Error("records must be an array of object, e.g. {key: foo, value: bar}");for(var t=0;t<e.length;t++){if(a.is(e[t].key,"undefined")||a.is(e[t].value,"undefined"))throw new Error("key and value properties are required");this.set(e[t].key,e[t].value,{silent:!0,fromBulk:!0})}}},{key:"bulkRemove",value:function(e){if(!a.is(e,"array"))throw new Error("keys must be an array of keys");for(var t=0;t<e.length;t++)this.remove(e[t],!0)}},{key:"clean",value:function(e){if(!a.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.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:"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=u}).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"}]);
{
"name": "incache",
"version": "4.1.2",
"version": "4.2.0",
"description": "Simple key/value in-memory storage or on disk to persist some data",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,2 +15,3 @@ const helper = require('./helper');

* @param [opts.storeName] {string} store name
* @param [opts.share=true] {boolean} if true use global object as storage
* @param [opts.global] {Object} **deprecated:** global record configuration

@@ -32,8 +33,2 @@ * @param [opts.global.silent=false] {boolean} **deprecated:** if true no event will be triggered, use `silent` instead

/**
* Root object
* @ignore
*/
this._root = helper.isServer() ? global : window;
/**
* InCache default configuration

@@ -50,2 +45,3 @@ * @ignore

silent: false,
share: true,
global: {

@@ -58,7 +54,10 @@ silent: false,

// Defines callback private
this._onRemoved = () => {};
this._onCreated = () => {};
this._onUpdated = () => {};
this._onRemoved = () => {
};
this._onCreated = () => {
};
this._onUpdated = () => {
};
if(helper.isServer()) {
if (helper.isServer()) {
process.stdin.resume();

@@ -102,2 +101,15 @@ process.on('exit', () => {

setConfig(opts = {}) {
helper.defaults(opts, this.DEFAULT_CONFIG);
/**
* Root object
* @ignore
*/
this._root = opts.share
? helper.isServer()
? global
: window
: {};
if (opts.storeName)

@@ -116,3 +128,3 @@ this.GLOBAL_KEY += opts.storeName;

if(opts.global) {
if (opts.global) {
helper.deprecated(opts.global.life, 'global.life is deprecated use maxAge instead');

@@ -122,3 +134,3 @@ helper.deprecated(opts.global.silent, 'global.silent is deprecated use silent instead');

this._root[this.GLOBAL_KEY].config = helper.defaults(opts, this.DEFAULT_CONFIG);
this._root[this.GLOBAL_KEY].config = opts;

@@ -434,4 +446,4 @@ this._memory = this._root[this.GLOBAL_KEY];

*/
clean(key){
if(!helper.is(key, 'string'))
clean(key) {
if (!helper.is(key, 'string'))
throw new Error('key must be a string');

@@ -438,0 +450,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc