New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cachu

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cachu - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

minify.mjs

2

build/global.js

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

"use strict";var __awaiter=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.each=exports.getKeysOfItems=exports.getValuesOfItems=exports.getAmountOfItems=exports.getManyByCondition=exports.purgeManyByCondition=exports.getMany=exports.purgeMany=exports.destroy=exports.prune=exports.purge=exports.has=exports.update=exports.view=exports.get=exports.set=void 0;var store=[],maxAmount=1/0,maxAge=1/0;exports.default=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e,r;return __generator(this,(function(n){return maxAmount=null!==(e=t.maxAmount)&&void 0!==e?e:1/0,maxAge=null!==(r=t.maxAge)&&void 0!==r?r:1/0,[2]}))}))};var set=function(t,e){return __awaiter(void 0,void 0,void 0,(function(){var r;return __generator(this,(function(n){return-1!==store.findIndex((function(e){return e[0]===t}))?[2,!1]:((store=store.filter((function(t){return Date.now()-t[2]<1e3*maxAge}))).length===maxAmount&&(r=store.reduce((function(t,e){return t[2]<e[2]?t:e})),store.splice(store.findIndex((function(t){return t[0]===r[0]})),1)),store.push([t,e,Date.now()]),[2,!0])}))}))};exports.set=set;var get=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){return store=store.filter((function(t){return Date.now()-t[2]<1e3*maxAge})),-1===(e=store.findIndex((function(e){return e[0]===t})))?[2,null]:[2,store[e][1]]}))}))};exports.get=get;var view=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){return store=store.filter((function(e){return Date.now()-e[2]<1e3*maxAge||e[0]===t})),-1===(e=store.findIndex((function(e){return e[0]===t})))?[2,null]:[2,store[e][1]]}))}))};exports.view=view;var update=function(t,e){return __awaiter(void 0,void 0,void 0,(function(){var r;return __generator(this,(function(n){return-1===(r=store.findIndex((function(e){return e[0]===t})))?[2,!1]:(store[r]=[t,e,Date.now()],[2,!0])}))}))};exports.update=update;var has=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return-1===store.findIndex((function(e){return e[0]===t}))?[2,!1]:[2,!0]}))}))};exports.has=has;var purge=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){return-1===(e=store.findIndex((function(e){return e[0]===t})))?[2,!1]:(store.splice(e,1),[2,!0])}))}))};exports.purge=purge;var prune=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return store.length>0&&(store=store.filter((function(t){return Date.now()-t[2]<1e3*maxAge}))),[2,!0]}))}))};exports.prune=prune;var destroy=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return store=[],[2,!0]}))}))};exports.destroy=destroy;var purgeMany=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(o){switch(o.label){case 0:e=0,r=t,o.label=1;case 1:return e<r.length?(n=r[e],[4,(0,exports.purge)(n)]):[3,4];case 2:o.sent(),o.label=3;case 3:return e++,[3,1];case 4:return[2,!0]}}))}))};exports.purgeMany=purgeMany;var getMany=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e,r,n,o,i;return __generator(this,(function(u){switch(u.label){case 0:e=[],r=0,n=t,u.label=1;case 1:return r<n.length?(o=n[r],[4,(0,exports.get)(o)]):[3,4];case 2:null===(i=u.sent())&&void 0===i||e.push(i),u.label=3;case 3:return r++,[3,1];case 4:return[2,e]}}))}))};exports.getMany=getMany;var purgeManyByCondition=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return store=store.filter((function(e){return!t(e)})),[2,!0]}))}))};exports.purgeManyByCondition=purgeManyByCondition;var getManyByCondition=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return[2,store.filter((function(e){return t(e)}))]}))}))};exports.getManyByCondition=getManyByCondition;var getAmountOfItems=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,store.length]}))}))};exports.getAmountOfItems=getAmountOfItems;var getValuesOfItems=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return 0===store.length?[2]:[2,store.map((function(t){return t[1]}))]}))}))};exports.getValuesOfItems=getValuesOfItems;var getKeysOfItems=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return 0===store.length?[2]:[2,store.map((function(t){return t[0]}))]}))}))};exports.getKeysOfItems=getKeysOfItems;var each=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return store.forEach((function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,t(e)];case 1:return r.sent(),[2]}}))}))})),[2,!0]}))}))};exports.each=each;
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.each=exports.getKeysOfItems=exports.getValuesOfItems=exports.getAmountOfItems=exports.getManyByCondition=exports.purgeManyByCondition=exports.getMany=exports.purgeMany=exports.destroy=exports.prune=exports.purge=exports.has=exports.update=exports.view=exports.get=exports.set=void 0;var store=[],maxAmount=1/0,maxAge=1/0;exports.default=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e,r;return __generator(this,(function(n){return maxAmount=null!==(e=t.maxAmount)&&void 0!==e?e:1/0,maxAge=null!==(r=t.maxAge)&&void 0!==r?r:1/0,[2]}))}))};var set=function(t,e){return __awaiter(void 0,void 0,void 0,(function(){var r;return __generator(this,(function(n){return-1!==store.findIndex((function(e){return e[0]===t}))?[2,!1]:((store=store.filter((function(t){return Date.now()-t[2]<1e3*maxAge}))).length===maxAmount&&(r=store.reduce((function(t,e){return t[2]<e[2]?t:e})),store.splice(store.findIndex((function(t){return t[0]===r[0]})),1)),store.push([t,e,Date.now()]),[2,!0])}))}))};exports.set=set;var get=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){return store=store.filter((function(t){return Date.now()-t[2]<1e3*maxAge})),-1===(e=store.findIndex((function(e){return e[0]===t})))?[2,null]:[2,store[e][1]]}))}))};exports.get=get;var view=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){return store=store.filter((function(e){return Date.now()-e[2]<1e3*maxAge||e[0]===t})),-1===(e=store.findIndex((function(e){return e[0]===t})))?[2,null]:[2,store[e][1]]}))}))};exports.view=view;var update=function(t,e){return __awaiter(void 0,void 0,void 0,(function(){var r;return __generator(this,(function(n){return-1===(r=store.findIndex((function(e){return e[0]===t})))?[2,!1]:(store[r]=[t,e,Date.now()],[2,!0])}))}))};exports.update=update;var has=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return-1===store.findIndex((function(e){return e[0]===t}))?[2,!1]:[2,!0]}))}))};exports.has=has;var purge=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){return-1===(e=store.findIndex((function(e){return e[0]===t})))?[2,!1]:(store.splice(e,1),[2,!0])}))}))};exports.purge=purge;var prune=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return store.length>0&&(store=store.filter((function(t){return Date.now()-t[2]<1e3*maxAge}))),[2,!0]}))}))};exports.prune=prune;var destroy=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return store=[],[2,!0]}))}))};exports.destroy=destroy;var purgeMany=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(o){switch(o.label){case 0:e=0,r=t,o.label=1;case 1:return e<r.length?(n=r[e],[4,(0,exports.purge)(n)]):[3,4];case 2:o.sent(),o.label=3;case 3:return e++,[3,1];case 4:return[2,!0]}}))}))};exports.purgeMany=purgeMany;var getMany=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e,r,n,o,i;return __generator(this,(function(u){switch(u.label){case 0:e=[],r=0,n=t,u.label=1;case 1:return r<n.length?(o=n[r],[4,(0,exports.get)(o)]):[3,4];case 2:null===(i=u.sent())&&void 0===i||e.push(i),u.label=3;case 3:return r++,[3,1];case 4:return[2,e]}}))}))};exports.getMany=getMany;var purgeManyByCondition=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return store=store.filter((function(e){return!t(e)})),[2,!0]}))}))};exports.purgeManyByCondition=purgeManyByCondition;var getManyByCondition=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return[2,store.filter((function(e){return t(e)}))]}))}))};exports.getManyByCondition=getManyByCondition;var getAmountOfItems=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,store.length]}))}))};exports.getAmountOfItems=getAmountOfItems;var getValuesOfItems=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return 0===store.length?[2]:[2,store.map((function(t){return t[1]}))]}))}))};exports.getValuesOfItems=getValuesOfItems;var getKeysOfItems=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return 0===store.length?[2]:[2,store.map((function(t){return t[0]}))]}))}))};exports.getKeysOfItems=getKeysOfItems;var each=function(t){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){return store.forEach((function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,t(e)];case 1:return r.sent(),[2]}}))}))})),[2,!0]}))}))};exports.each=each;

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

"use strict";var __awaiter=this&&this.__awaiter||function(t,n,e,r){return new(e||(e=Promise))((function(i,o){function u(t){try{a(r.next(t))}catch(t){o(t)}}function s(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,s)}a((r=r.apply(t,n||[])).next())}))},__generator=this&&this.__generator||function(t,n){var e,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=n.call(t,u)}catch(t){o=[6,t],r=0}finally{e=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cachu=void 0;var Cachu=function(t){var n,e,r=this;this.set=function(t,n){return __awaiter(r,void 0,void 0,(function(){var e,r=this;return __generator(this,(function(i){return-1!==this.store.findIndex((function(n){return n[0]===t}))?[2,!1]:(this.store=this.store.filter((function(t){return Date.now()-t[2]<1e3*r.maxAge.valueOf()})),this.store.length===this.maxAmount&&(e=this.store.reduce((function(t,n){return t[2]<n[2]?t:n})),this.store.splice(this.store.findIndex((function(t){return t[0]===e[0]})),1)),this.store.push([t,n,Date.now()]),[2,!0])}))}))},this.get=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e=this;return __generator(this,(function(r){return this.store=this.store.filter((function(t){return Date.now()-t[2]<1e3*e.maxAge.valueOf()})),-1===(n=this.store.findIndex((function(n){return n[0]===t})))?[2,null]:[2,this.store[n][1]]}))}))},this.view=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e=this;return __generator(this,(function(r){return this.store=this.store.filter((function(n){return Date.now()-n[2]<1e3*e.maxAge.valueOf()||n[0]===t})),-1===(n=this.store.findIndex((function(n){return n[0]===t})))?[2,null]:[2,this.store[n][1]]}))}))},this.update=function(t,n){return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(r){return-1===(e=this.store.findIndex((function(n){return n[0]===t})))?[2,!1]:(this.store[e]=[t,n,Date.now()],[2,!0])}))}))},this.has=function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(n){return-1===this.store.findIndex((function(n){return n[0]===t}))?[2,!1]:[2,!0]}))}))},this.purge=function(t){return __awaiter(r,void 0,void 0,(function(){var n;return __generator(this,(function(e){return-1===(n=this.store.findIndex((function(n){return n[0]===t})))?[2,!1]:(this.store.splice(n,1),[2,!0])}))}))},this.prune=function(){return __awaiter(r,void 0,void 0,(function(){var t=this;return __generator(this,(function(n){return this.store.length>0&&(this.store=this.store.filter((function(n){return Date.now()-n[2]<1e3*t.maxAge.valueOf()}))),[2,!0]}))}))},this.destroy=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return this.store=[],[2,!0]}))}))},this.purgeMany=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e,r;return __generator(this,(function(i){switch(i.label){case 0:n=0,e=t,i.label=1;case 1:return n<e.length?(r=e[n],[4,this.purge(r)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2,!0]}}))}))},this.getMany=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e,r,i,o;return __generator(this,(function(u){switch(u.label){case 0:n=[],e=0,r=t,u.label=1;case 1:return e<r.length?(i=r[e],[4,this.get(i)]):[3,4];case 2:null===(o=u.sent())&&void 0===o||n.push(o),u.label=3;case 3:return e++,[3,1];case 4:return[2,n]}}))}))},this.purgeManyByCondition=function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(n){return this.store=this.store.filter((function(n){return!t(n)})),[2,!0]}))}))},this.getManyByCondition=function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(n){return[2,this.store.filter((function(n){return t(n)}))]}))}))},this.getAmountOfItems=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.store.length]}))}))},this.getValuesOfItems=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return 0===this.store.length?[2]:[2,this.store.map((function(t){return t[1]}))]}))}))},this.getKeysOfItems=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return 0===this.store.length?[2]:[2,this.store.map((function(t){return t[0]}))]}))}))},this.each=function(t){return __awaiter(r,void 0,void 0,(function(){var n=this;return __generator(this,(function(e){return this.store.forEach((function(e){return __awaiter(n,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4,t(e)];case 1:return n.sent(),[2]}}))}))})),[2,!0]}))}))},this.maxAmount=null!==(n=t.maxAmount)&&void 0!==n?n:1/0,this.maxAge=null!==(e=t.maxAge)&&void 0!==e?e:1/0,this.store=[]};exports.Cachu=Cachu;
"use strict";var __awaiter=this&&this.__awaiter||function(t,n,e,r){return new(e||(e=Promise))((function(i,o){function u(t){try{a(r.next(t))}catch(t){o(t)}}function s(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,s)}a((r=r.apply(t,n||[])).next())}))},__generator=this&&this.__generator||function(t,n){var e,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!((i=(i=u.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=n.call(t,u)}catch(t){o=[6,t],r=0}finally{e=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cachu=void 0;var Cachu=function(t){var n,e,r=this;this.set=function(t,n){return __awaiter(r,void 0,void 0,(function(){var e,r=this;return __generator(this,(function(i){return-1!==this.store.findIndex((function(n){return n[0]===t}))?[2,!1]:(this.store=this.store.filter((function(t){return Date.now()-t[2]<1e3*r.maxAge.valueOf()})),this.store.length===this.maxAmount&&(e=this.store.reduce((function(t,n){return t[2]<n[2]?t:n})),this.store.splice(this.store.findIndex((function(t){return t[0]===e[0]})),1)),this.store.push([t,n,Date.now()]),[2,!0])}))}))},this.get=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e=this;return __generator(this,(function(r){return this.store=this.store.filter((function(t){return Date.now()-t[2]<1e3*e.maxAge.valueOf()})),-1===(n=this.store.findIndex((function(n){return n[0]===t})))?[2,null]:[2,this.store[n][1]]}))}))},this.view=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e=this;return __generator(this,(function(r){return this.store=this.store.filter((function(n){return Date.now()-n[2]<1e3*e.maxAge.valueOf()||n[0]===t})),-1===(n=this.store.findIndex((function(n){return n[0]===t})))?[2,null]:[2,this.store[n][1]]}))}))},this.update=function(t,n){return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(r){return-1===(e=this.store.findIndex((function(n){return n[0]===t})))?[2,!1]:(this.store[e]=[t,n,Date.now()],[2,!0])}))}))},this.has=function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(n){return-1===this.store.findIndex((function(n){return n[0]===t}))?[2,!1]:[2,!0]}))}))},this.purge=function(t){return __awaiter(r,void 0,void 0,(function(){var n;return __generator(this,(function(e){return-1===(n=this.store.findIndex((function(n){return n[0]===t})))?[2,!1]:(this.store.splice(n,1),[2,!0])}))}))},this.prune=function(){return __awaiter(r,void 0,void 0,(function(){var t=this;return __generator(this,(function(n){return this.store.length>0&&(this.store=this.store.filter((function(n){return Date.now()-n[2]<1e3*t.maxAge.valueOf()}))),[2,!0]}))}))},this.destroy=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return this.store=[],[2,!0]}))}))},this.purgeMany=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e,r;return __generator(this,(function(i){switch(i.label){case 0:n=0,e=t,i.label=1;case 1:return n<e.length?(r=e[n],[4,this.purge(r)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2,!0]}}))}))},this.getMany=function(t){return __awaiter(r,void 0,void 0,(function(){var n,e,r,i,o;return __generator(this,(function(u){switch(u.label){case 0:n=[],e=0,r=t,u.label=1;case 1:return e<r.length?(i=r[e],[4,this.get(i)]):[3,4];case 2:null===(o=u.sent())&&void 0===o||n.push(o),u.label=3;case 3:return e++,[3,1];case 4:return[2,n]}}))}))},this.purgeManyByCondition=function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(n){return this.store=this.store.filter((function(n){return!t(n)})),[2,!0]}))}))},this.getManyByCondition=function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(n){return[2,this.store.filter((function(n){return t(n)}))]}))}))},this.getAmountOfItems=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.store.length]}))}))},this.getValuesOfItems=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return 0===this.store.length?[2]:[2,this.store.map((function(t){return t[1]}))]}))}))},this.getKeysOfItems=function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){return 0===this.store.length?[2]:[2,this.store.map((function(t){return t[0]}))]}))}))},this.each=function(t){return __awaiter(r,void 0,void 0,(function(){var n=this;return __generator(this,(function(e){return this.store.forEach((function(e){return __awaiter(n,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4,t(e)];case 1:return n.sent(),[2]}}))}))})),[2,!0]}))}))},this.maxAmount=null!==(n=t.maxAmount)&&void 0!==n?n:1/0,this.maxAge=null!==(e=t.maxAge)&&void 0!==e?e:1/0,this.store=[]};exports.Cachu=Cachu;
{
"name": "cachu",
"version": "2.1.0",
"version": "2.1.1",
"description": "Simple, minimalistic key-value cache.",

@@ -10,3 +10,3 @@ "main": "build/index.js",

"build:dev": "tsc -w",
"minify": "node build.mjs",
"minify": "node minify.mjs",
"release:patch": "npm run minify && npm version patch && npm publish",

@@ -13,0 +13,0 @@ "release:minor": "npm run minify && npm version minor && npm publish",

@@ -67,3 +67,2 @@ # cachu

- [`maxAmount`](https://github.com/azurystudios/cachu/wiki/configuration#max-amount) to set the **maximum size** for the store
- [`store`](https://github.com/azurystudios/cachu/wiki/configuration#store) to set the **method** of storing data

@@ -70,0 +69,0 @@ ### Features

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