Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

basic-lru

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-lru - npm Package Compare versions

Comparing version
0.0.1
to
0.1.0
+1
-1
cjs/index.js

@@ -91,2 +91,2 @@ 'use strict';

}
}
};

@@ -99,2 +99,2 @@ var LRU = (function (exports) {

}({}));
}({}).default);
+1
-1

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

var LRU=function(e){"use strict";const{now:t}=Date,{defineProperties:i}=Object,{iterator:r}=Symbol;class s extends Map{constructor(e){const t="number"==typeof e,r=(t?e:e.max||e.maxSize)||1/0,s=t?0:e.maxAge||0;i(super(),{_dropExpired:{value:this._dropExpired.bind(this)},_timer:{writable:!0,value:0},_count:{writable:!0,value:0},_max:{value:r},_maxAge:{value:s}})}get(e){const i=super.get(e);if(void 0!==i)return i.time=t(),i.value}set(e,i){const{_max:r,_maxAge:s}=this,o=0!==s;return this.size!==r||this.has(e)||(o&&this._dropExpired(),o&&this.size!==r||this._dropCount()),o&&(clearTimeout(this._timer),this._timer=setTimeout(this._dropExpired,s+1)),super.set(e,{count:this._count++,time:t(),value:i})}forEach(e,t){return super.forEach(({value:i},r)=>e.call(t,i,r,this))}peek(e){const t=super.get(e);if(void 0!==t)return t.value}*entries(){yield*this[r]()}*values(){for(const[e,{value:t}]of super[r].call(this))yield t}*[r](){for(const[e,{value:t}]of super[r].call(this))yield[e,t]}_dropCount(){const e=[...super[r].call(this)],[[t]]=e.sort(([e,t],[i,r])=>{const s=t.time===r.time?"count":"time";return t[s]-r[s]});this.delete(t)}_dropExpired(){const e=t()-this._maxAge;super.forEach(({time:t},i)=>{t<e&&this.delete(i)})}}return e.default=s,e}({});
var LRU=function(e){"use strict";const{now:t}=Date,{defineProperties:i}=Object,{iterator:r}=Symbol;class s extends Map{constructor(e){const t="number"==typeof e,r=(t?e:e.max||e.maxSize)||1/0,s=t?0:e.maxAge||0;i(super(),{_dropExpired:{value:this._dropExpired.bind(this)},_timer:{writable:!0,value:0},_count:{writable:!0,value:0},_max:{value:r},_maxAge:{value:s}})}get(e){const i=super.get(e);if(void 0!==i)return i.time=t(),i.value}set(e,i){const{_max:r,_maxAge:s}=this,o=0!==s;return this.size!==r||this.has(e)||(o&&this._dropExpired(),o&&this.size!==r||this._dropCount()),o&&(clearTimeout(this._timer),this._timer=setTimeout(this._dropExpired,s+1)),super.set(e,{count:this._count++,time:t(),value:i})}forEach(e,t){return super.forEach(({value:i},r)=>e.call(t,i,r,this))}peek(e){const t=super.get(e);if(void 0!==t)return t.value}*entries(){yield*this[r]()}*values(){for(const[e,{value:t}]of super[r].call(this))yield t}*[r](){for(const[e,{value:t}]of super[r].call(this))yield[e,t]}_dropCount(){const e=[...super[r].call(this)],[[t]]=e.sort(([e,t],[i,r])=>{const s=t.time===r.time?"count":"time";return t[s]-r[s]});this.delete(t)}_dropExpired(){const e=t()-this._maxAge;super.forEach(({time:t},i)=>{t<e&&this.delete(i)})}}return e.default=s,e}({}).default;
{
"name": "basic-lru",
"version": "0.0.1",
"version": "0.1.0",
"description": "A lightweight Map based LRU implementation",
"main": "cjs/index.js",
"scripts": {
"build": "npm run cjs && npm run rollup:new && npm run rollup:index && npm run test",
"build": "npm run cjs && npm run rollup:new && npm run rollup:index && npm run fix && npm run test",
"cjs": "ascjs --no-default esm cjs",
"fix": "sed -i 's/({})/({}).default/' index.js && sed -i 's/({})/({}).default/' new.js",
"rollup:new": "rollup --config rollup/new.config.js",

@@ -10,0 +11,0 @@ "rollup:index": "rollup --config rollup/index.config.js",