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 6.0.0-canary.3 to 6.0.0-canary.4

2

dist/index.js

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

var x=Object.create;var f=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var k=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of w(e))!L.call(s,a)&&a!==t&&f(s,a,{get:()=>e[a],enumerable:!(n=A(e,a))||n.enumerable});return s};var v=(s,e,t)=>(t=s!=null?x(g(s)):{},k(e||!s||!s.__esModule?f(t,"default",{value:s,enumerable:!0}):t,s));var y=M((S,b)=>{var i=1e3,o=i*60,u=o*60,r=u*24,P=r*7,D=r*365.25;b.exports=function(s,e){e=e||{};var t=typeof s;if(t==="string"&&s.length>0)return E(s);if(t==="number"&&isFinite(s))return e.long?O(s):z(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))};function E(s){if(s=String(s),!(s.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!!e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*D;case"weeks":case"week":case"w":return t*P;case"days":case"day":case"d":return t*r;case"hours":case"hour":case"hrs":case"hr":case"h":return t*u;case"minutes":case"minute":case"mins":case"min":case"m":return t*o;case"seconds":case"second":case"secs":case"sec":case"s":return t*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function z(s){var e=Math.abs(s);return e>=r?Math.round(s/r)+"d":e>=u?Math.round(s/u)+"h":e>=o?Math.round(s/o)+"m":e>=i?Math.round(s/i)+"s":s+"ms"}function O(s){var e=Math.abs(s);return e>=r?h(s,e,r,"day"):e>=u?h(s,e,u,"hour"):e>=o?h(s,e,o,"minute"):e>=i?h(s,e,i,"second"):s+" ms"}function h(s,e,t,n){var a=e>=t*1.5;return Math.round(s/t)+" "+n+(a?"s":"")}});var m=v(y(),1);var c=v(y(),1),d=class{__eventListeners;__recentEntry;__maxAge;__maxAmount;__webhook;__autoclear;constructor(e){e=e??{},this.__eventListeners={},this.__maxAge=typeof e.maxAge=="number"?e.maxAge*1e3:typeof e.maxAge=="string"?(0,c.default)(e.maxAge):(0,c.default)("10m"),this.__maxAmount=e.maxAmount??1e4,this.__autoclear=e.autoclear??!1,typeof e.webhook=="string"&&(this.__webhook=e.webhook)}},p=d;var l=class extends p{store;consumedMemory;constructor(e){super(e),this.store=new Map,this.consumedMemory=0}async deleteOutdated(e){}async set(e,t,n){this.__eventListeners.set&&await this.__eventListeners.set(e,t,n),this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated(),this.__autoclear&&this.store.size+1>this.__maxAmount&&await this.deleteOutdated(1);let a={value:t,...typeof n=="string"?{expiresAt:Date.now()+(0,m.default)(n)}:typeof n=="number"?{expiresAt:Date.now()+n*1e3}:this.__maxAge!==1/0&&{expiresAt:Date.now()+this.__maxAge}};this.store.set(e,a),this.__recentEntry={key:e,...a}}async setMany(e){this.__eventListeners.setMany&&await this.__eventListeners.setMany(e),this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated(),this.__autoclear&&this.store.size+e.length>this.__maxAmount&&await this.deleteOutdated(this.store.size+e.length-this.__maxAmount);for(let t of e){if(this.store.has(t[0]))continue;let n={value:t[1],...typeof t[2]=="string"?{expiresAt:Date.now()+(0,m.default)(t[2])}:typeof t[2]=="number"?{expiresAt:Date.now()+t[2]*1e3}:this.__maxAge!==1/0&&{expiresAt:Date.now()+this.__maxAge}};this.store.set(t[0],n),this.__recentEntry={key:t[0],...n}}}async get(e,t){t=t??{},this.__eventListeners.get&&await this.__eventListeners.get(e,t);let n=this.store.get(e);if(!!n){if(t.validate&&n.expiresAt&&Date.now()>=n.expiresAt){this.store.delete(e);return}return t.delete&&this.store.delete(e),n.value}}async getMany(e,t){t=t??{},this.__eventListeners.getMany&&await this.__eventListeners.getMany(e,t);let n=[];for(let a of e){let _=this.store.get(a);if(!_){n=[...n,void 0];continue}if(t.validate&&_.expiresAt&&Date.now()>=_.expiresAt){this.store.delete(a),n=[...n,void 0];continue}t.delete&&this.store.delete(a),n=[...n,_.value]}return n}async update(e,t){this.__eventListeners.update&&await this.__eventListeners.update(e,t),this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated();let n=this.store.get(e);if(!n)return;let a={value:t,...n.expiresAt&&{expiresAt:n.expiresAt}};this.store.set(e,a),this.__recentEntry={key:e,...a}}async updateMany(e){this.__eventListeners.updateMany&&await this.__eventListeners.updateMany(e);for(let t of e){let n=this.store.get(t[0]);if(!n)continue;let a={value:t[1],...n.expiresAt&&{expiresAt:n.expiresAt}};this.store.set(t[0],a),this.__recentEntry={key:t[0],...a}}}async delete(e){this.__eventListeners.delete&&await this.__eventListeners.delete(e),this.store.delete(e)}async deleteMany(e){this.__eventListeners.deleteMany&&await this.__eventListeners.deleteMany(e),e.length===0&&this.store.clear();for(let t of e)this.store.delete(t)}async has(e){return this.__eventListeners.has&&await this.__eventListeners.has(e),this.store.has(e)}async size(){return this.__eventListeners.size&&await this.__eventListeners.size(),this.store.size}async keys(){return this.__eventListeners.keys&&await this.__eventListeners.keys(),[...this.store.keys()]}async values(){this.__eventListeners.values&&await this.__eventListeners.values();let e=[];for(let[t,n]of this.store)e=[...e,n.value];return e}async clear(){this.__eventListeners.clear&&await this.__eventListeners.clear();for(let[e,t]of this.store)t.expiresAt&&Date.now()>=t.expiresAt&&this.store.delete(e)}async memory(){this.__eventListeners.memory&&await this.__eventListeners.memory();let e=[...this.store.keys()].toString()+[...this.store.values()].toString(),t=Buffer.from(e);return Buffer.byteLength(t)}async recent(){return this.__eventListeners.recent&&await this.__eventListeners.recent(),this.__recentEntry}async maxAge(e){return this.__eventListeners.maxAge&&await this.__eventListeners.maxAge(),e?(this.__maxAge=typeof e=="number"?e*1e3:(0,m.default)(e),this.__maxAge):this.__maxAge}async maxAmount(e){return this.__eventListeners.maxAmount&&await this.__eventListeners.maxAmount(),e?(this.__maxAmount=e,e):this.__maxAmount}async on(e,t){this.__eventListeners[e]=t}},F=l;export{F as MemoryCache};
"use strict";var x=Object.create;var f=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var k=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of w(e))!L.call(s,a)&&a!==t&&f(s,a,{get:()=>e[a],enumerable:!(n=A(e,a))||n.enumerable});return s};var v=(s,e,t)=>(t=s!=null?x(g(s)):{},k(e||!s||!s.__esModule?f(t,"default",{value:s,enumerable:!0}):t,s));var y=M((S,b)=>{var i=1e3,o=i*60,u=o*60,r=u*24,P=r*7,D=r*365.25;b.exports=function(s,e){e=e||{};var t=typeof s;if(t==="string"&&s.length>0)return E(s);if(t==="number"&&isFinite(s))return e.long?O(s):z(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))};function E(s){if(s=String(s),!(s.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!!e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*D;case"weeks":case"week":case"w":return t*P;case"days":case"day":case"d":return t*r;case"hours":case"hour":case"hrs":case"hr":case"h":return t*u;case"minutes":case"minute":case"mins":case"min":case"m":return t*o;case"seconds":case"second":case"secs":case"sec":case"s":return t*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function z(s){var e=Math.abs(s);return e>=r?Math.round(s/r)+"d":e>=u?Math.round(s/u)+"h":e>=o?Math.round(s/o)+"m":e>=i?Math.round(s/i)+"s":s+"ms"}function O(s){var e=Math.abs(s);return e>=r?h(s,e,r,"day"):e>=u?h(s,e,u,"hour"):e>=o?h(s,e,o,"minute"):e>=i?h(s,e,i,"second"):s+" ms"}function h(s,e,t,n){var a=e>=t*1.5;return Math.round(s/t)+" "+n+(a?"s":"")}});var m=v(y(),1);var c=v(y(),1),d=class{__eventListeners;__recentEntry;__maxAge;__maxAmount;__webhook;__autoclear;constructor(e){e=e??{},this.__eventListeners={},this.__maxAge=typeof e.maxAge=="number"?e.maxAge*1e3:typeof e.maxAge=="string"?(0,c.default)(e.maxAge):(0,c.default)("10m"),this.__maxAmount=e.maxAmount??1e4,this.__autoclear=e.autoclear??!1,typeof e.webhook=="string"&&(this.__webhook=e.webhook)}},p=d;var l=class extends p{store;consumedMemory;constructor(e){super(e),this.store=new Map,this.consumedMemory=0}async deleteOutdated(e){}async set(e,t,n){this.__eventListeners.set&&await this.__eventListeners.set(e,t,n),this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated(),this.__autoclear&&this.store.size+1>this.__maxAmount&&await this.deleteOutdated(1);let a={value:t,...typeof n=="string"?{expiresAt:Date.now()+(0,m.default)(n)}:typeof n=="number"?{expiresAt:Date.now()+n*1e3}:this.__maxAge!==1/0&&{expiresAt:Date.now()+this.__maxAge}};this.store.set(e,a),this.__recentEntry={key:e,...a}}async setMany(e){this.__eventListeners.setMany&&await this.__eventListeners.setMany(e),this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated(),this.__autoclear&&this.store.size+e.length>this.__maxAmount&&await this.deleteOutdated(this.store.size+e.length-this.__maxAmount);for(let t of e){if(this.store.has(t[0]))continue;let n={value:t[1],...typeof t[2]=="string"?{expiresAt:Date.now()+(0,m.default)(t[2])}:typeof t[2]=="number"?{expiresAt:Date.now()+t[2]*1e3}:this.__maxAge!==1/0&&{expiresAt:Date.now()+this.__maxAge}};this.store.set(t[0],n),this.__recentEntry={key:t[0],...n}}}async get(e,t){t=t??{},this.__eventListeners.get&&await this.__eventListeners.get(e,t);let n=this.store.get(e);if(!!n){if(t.validate&&n.expiresAt&&Date.now()>=n.expiresAt){this.store.delete(e);return}return t.delete&&this.store.delete(e),n.value}}async getMany(e,t){t=t??{},this.__eventListeners.getMany&&await this.__eventListeners.getMany(e,t);let n=[];for(let a of e){let _=this.store.get(a);if(!_){n=[...n,void 0];continue}if(t.validate&&_.expiresAt&&Date.now()>=_.expiresAt){this.store.delete(a),n=[...n,void 0];continue}t.delete&&this.store.delete(a),n=[...n,_.value]}return n}async update(e,t){this.__eventListeners.update&&await this.__eventListeners.update(e,t),this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated();let n=this.store.get(e);if(!n)return;let a={value:t,...n.expiresAt&&{expiresAt:n.expiresAt}};this.store.set(e,a),this.__recentEntry={key:e,...a}}async updateMany(e){this.__eventListeners.updateMany&&await this.__eventListeners.updateMany(e);for(let t of e){let n=this.store.get(t[0]);if(!n)continue;let a={value:t[1],...n.expiresAt&&{expiresAt:n.expiresAt}};this.store.set(t[0],a),this.__recentEntry={key:t[0],...a}}}async delete(e){this.__eventListeners.delete&&await this.__eventListeners.delete(e),this.store.delete(e)}async deleteMany(e){this.__eventListeners.deleteMany&&await this.__eventListeners.deleteMany(e),e.length===0&&this.store.clear();for(let t of e)this.store.delete(t)}async has(e){return this.__eventListeners.has&&await this.__eventListeners.has(e),this.store.has(e)}async size(){return this.__eventListeners.size&&await this.__eventListeners.size(),this.store.size}async keys(){return this.__eventListeners.keys&&await this.__eventListeners.keys(),[...this.store.keys()]}async values(){this.__eventListeners.values&&await this.__eventListeners.values();let e=[];for(let[t,n]of this.store)e=[...e,n.value];return e}async clear(){this.__eventListeners.clear&&await this.__eventListeners.clear();for(let[e,t]of this.store)t.expiresAt&&Date.now()>=t.expiresAt&&this.store.delete(e)}async memory(){this.__eventListeners.memory&&await this.__eventListeners.memory();let e=[...this.store.keys()].toString()+[...this.store.values()].toString(),t=Buffer.from(e);return Buffer.byteLength(t)}async recent(){return this.__eventListeners.recent&&await this.__eventListeners.recent(),this.__recentEntry}async maxAge(e){return this.__eventListeners.maxAge&&await this.__eventListeners.maxAge(),e?(this.__maxAge=typeof e=="number"?e*1e3:(0,m.default)(e),this.__maxAge):this.__maxAge}async maxAmount(e){return this.__eventListeners.maxAmount&&await this.__eventListeners.maxAmount(),e?(this.__maxAmount=e,e):this.__maxAmount}async on(e,t){this.__eventListeners[e]=t}},F=l;export{F as MemoryCache};
{
"name": "cachu",
"version": "6.0.0-canary.3",
"version": "6.0.0-canary.4",
"description": "A modern and simple key-value cache for Node.js.",

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

"build": "rimraf dist && rimraf types && tsc && esbuild src/index.ts --bundle --minify --format=esm --legal-comments=none --platform=node --outfile=dist/index.js",
"publish:canary": "npm run build && npm version prerelease --preid=canary && npm publish --tag canary",
"publish:patch": "npm run build && npm version patch && npm publish",
"publish:minor": "npm run build && npm version minor && npm publish",
"publish:major": "npm run build && npm version major && npm publish",
"version:canary": "npm version prerelease --preid=canary",
"version:patch": "npm version patch",
"version:minor": "npm version minor",
"version:major": "npm version major",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js"

@@ -35,9 +35,9 @@ },

"devDependencies": {
"@types/jest": "^28.1.1",
"@types/jest": "^28.1.2",
"@types/ms": "^0.7.31",
"@types/node": "^17.0.44",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"esbuild": "^0.14.43",
"eslint": "^8.17.0",
"esbuild": "^0.14.46",
"eslint": "^8.18.0",
"eslint-plugin-import": "^2.26.0",

@@ -49,3 +49,3 @@ "eslint-plugin-unused-imports": "^2.0.0",

"ts-jest": "^28.0.5",
"typescript": "^4.7.2"
"typescript": "^4.7.4"
},

@@ -52,0 +52,0 @@ "engines": {

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