Huge News!Announcing our $40M Series B led by Abstract Ventures.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.4.1 to 2.4.2

2

build/index.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cachu=void 0;class Cachu{constructor(t){this.set=async(t,s)=>{if(-1!==this.store.findIndex((s=>s[0]===t)))return!1;if(this.store=this.store.filter((t=>Date.now()-t[2]<1e3*this.maxAge.valueOf())),this.store.length===this.maxAmount){const t=this.store.reduce(((t,s)=>t[2]<s[2]?t:s));this.store.splice(this.store.findIndex((s=>s[0]===t[0])),1)}return this.store.push([t,s,Date.now()]),!0},this.get=async t=>{this.store=this.store.filter((t=>Date.now()-t[2]<1e3*this.maxAge.valueOf()));const s=this.store.findIndex((s=>s[0]===t));return-1===s?null:this.store[s][1]},this.view=async t=>{this.store=this.store.filter((s=>Date.now()-s[2]<1e3*this.maxAge.valueOf()||s[0]===t));const s=this.store.findIndex((s=>s[0]===t));return-1===s?null:this.store[s][1]},this.update=async(t,s)=>{const e=this.store.findIndex((s=>s[0]===t));return-1!==e&&(this.store[e]=[t,s,Date.now()],!0)},this.has=async t=>-1!==this.store.findIndex((s=>s[0]===t)),this.purge=async t=>{const s=this.store.findIndex((s=>s[0]===t));return-1!==s&&(this.store.splice(s,1),!0)},this.prune=async()=>(this.store.length>0&&(this.store=this.store.filter((t=>Date.now()-t[2]<1e3*this.maxAge.valueOf()))),!0),this.destroy=async()=>(this.store=[],!0),this.purgeMany=async t=>{for(const s of t)await this.purge(s);return!0},this.getMany=async t=>{const s=[];for(const e of t){const t=await this.get(e);null===t&&void 0===t||s.push(t)}return s},this.purgeManyByCondition=async t=>(this.store=this.store.filter((s=>!t(s[0],s[1],s[2]))),!0),this.getManyByCondition=async t=>{const s=this.store.filter((s=>t(s[0],s[1],s[2]))),e=[];for(const t of s)e.push(t[1]);return e},this.getAmountOfItems=async()=>this.store.length,this.getValuesOfItems=async()=>{if(0!==this.store.length)return this.store.map((t=>t[1]))},this.getKeysOfItems=async()=>{if(0!==this.store.length)return this.store.map((t=>t[0]))},this.each=async t=>(this.store.forEach((async s=>{await t(s)})),!0),t||(t={}),this.maxAmount=t.maxAmount??1/0,this.maxAge=t.maxAge??1/0,this.store=[]}}exports.Cachu=Cachu;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cachu=void 0;class Cachu{constructor(t){this.set=async(t,s)=>{if(-1!==this.store.findIndex((s=>s[0]===t)))return!1;if(this.store=this.store.filter((t=>Date.now()-t[2]<1e3*this.maxAge.valueOf())),this.store.length===this.maxAmount){const t=this.store.reduce(((t,s)=>t[2]<s[2]?t:s));this.store.splice(this.store.findIndex((s=>s[0]===t[0])),1)}return this.store.push([t,s,Date.now()]),!0},this.get=async t=>{this.store=this.store.filter((t=>Date.now()-t[2]<1e3*this.maxAge.valueOf()));const s=this.store.findIndex((s=>s[0]===t));if(-1===s)return null;return this.store[s][1]},this.view=async t=>{this.store=this.store.filter((s=>Date.now()-s[2]<1e3*this.maxAge.valueOf()||s[0]===t));const s=this.store.findIndex((s=>s[0]===t));if(-1===s)return null;return this.store[s][1]},this.update=async(t,s)=>{const e=this.store.findIndex((s=>s[0]===t));return-1!==e&&(this.store[e]=[t,s,Date.now()],!0)},this.has=async t=>-1!==this.store.findIndex((s=>s[0]===t)),this.purge=async t=>{const s=this.store.findIndex((s=>s[0]===t));return-1!==s&&(this.store.splice(s,1),!0)},this.prune=async()=>(this.store.length>0&&(this.store=this.store.filter((t=>Date.now()-t[2]<1e3*this.maxAge.valueOf()))),!0),this.destroy=async()=>(this.store=[],!0),this.purgeMany=async t=>{for(const s of t)await this.purge(s);return!0},this.getMany=async t=>{const s=[];for(const e of t){const t=await this.get(e);null===t&&void 0===t||s.push(t)}return s},this.purgeManyByCondition=async t=>(this.store=this.store.filter((s=>!t(s[0],s[1],s[2]))),!0),this.getManyByCondition=async t=>{const s=this.store.filter((s=>t(s[0],s[1],s[2]))),e=[];for(const t of s)e.push(t[1]);return e},this.getAmountOfItems=async()=>this.store.length,this.getValuesOfItems=async()=>{if(0!==this.store.length)return this.store.map((t=>t[1]))},this.getKeysOfItems=async()=>{if(0!==this.store.length)return this.store.map((t=>t[0]))},this.each=async t=>(this.store.forEach((async s=>{await t(s)})),!0),t||(t={}),this.maxAmount=t.maxAmount??1/0,this.maxAge=t.maxAge??1/0,this.store=[]}}exports.Cachu=Cachu;
{
"name": "cachu",
"version": "2.4.1",
"description": "Simple, minimalistic key-value cache.",
"version": "2.4.2",
"description": "Simple, Minimalistic KV Cache",
"main": "build/index.js",

@@ -6,0 +6,0 @@ "types": "types/index.d.ts",

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