+3
-3
@@ -67,7 +67,7 @@ 'use strict'; | ||
| * values() { | ||
| for (const [_, {value}] of super[iterator].call(this)) | ||
| for (const [_, {value}] of super[iterator]()) | ||
| yield value; | ||
| } | ||
| * [iterator]() { | ||
| for (const [key, {value}] of super[iterator].call(this)) | ||
| for (const [key, {value}] of super[iterator]()) | ||
| yield [key, value]; | ||
@@ -78,3 +78,3 @@ } | ||
| _dropCount() { | ||
| const entries = [...super[iterator].call(this)]; | ||
| const entries = [...super[iterator]()]; | ||
| const [[toBeRemoved]] = entries.sort(([_1, entry1], [_2, entry2]) => { | ||
@@ -81,0 +81,0 @@ const prop = entry1.time === entry2.time ? 'count' : 'time'; |
+3
-3
@@ -66,7 +66,7 @@ const {now} = Date; | ||
| * values() { | ||
| for (const [_, {value}] of super[iterator].call(this)) | ||
| for (const [_, {value}] of super[iterator]()) | ||
| yield value; | ||
| } | ||
| * [iterator]() { | ||
| for (const [key, {value}] of super[iterator].call(this)) | ||
| for (const [key, {value}] of super[iterator]()) | ||
| yield [key, value]; | ||
@@ -77,3 +77,3 @@ } | ||
| _dropCount() { | ||
| const entries = [...super[iterator].call(this)]; | ||
| const entries = [...super[iterator]()]; | ||
| const [[toBeRemoved]] = entries.sort(([_1, entry1], [_2, entry2]) => { | ||
@@ -80,0 +80,0 @@ const prop = entry1.time === entry2.time ? 'count' : 'time'; |
+3
-3
@@ -69,7 +69,7 @@ var LRU = (function (exports) { | ||
| * values() { | ||
| for (const [_, {value}] of super[iterator].call(this)) | ||
| for (const [_, {value}] of super[iterator]()) | ||
| yield value; | ||
| } | ||
| * [iterator]() { | ||
| for (const [key, {value}] of super[iterator].call(this)) | ||
| for (const [key, {value}] of super[iterator]()) | ||
| yield [key, value]; | ||
@@ -80,3 +80,3 @@ } | ||
| _dropCount() { | ||
| const entries = [...super[iterator].call(this)]; | ||
| const entries = [...super[iterator]()]; | ||
| const [[toBeRemoved]] = entries.sort(([_1, entry1], [_2, entry2]) => { | ||
@@ -83,0 +83,0 @@ const prop = entry1.time === entry2.time ? 'count' : 'time'; |
+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}({}).default; | ||
| var LRU=function(e){"use strict";const{now:t}=Date,{defineProperties:r}=Object,{iterator:i}=Symbol;class s extends Map{constructor(e){const t="number"==typeof e,i=(t?e:e.max||e.maxSize)||1/0,s=t?0:e.maxAge||0;r(super(),{_dropExpired:{value:this._dropExpired.bind(this)},_timer:{writable:!0,value:0},_count:{writable:!0,value:0},_max:{value:i},_maxAge:{value:s}})}get(e){const r=super.get(e);if(void 0!==r)return r.time=t(),r.value}set(e,r){const{_max:i,_maxAge:s}=this,o=0!==s;return this.size!==i||this.has(e)||(o&&this._dropExpired(),o&&this.size!==i||this._dropCount()),o&&(clearTimeout(this._timer),this._timer=setTimeout(this._dropExpired,s+1)),super.set(e,{count:this._count++,time:t(),value:r})}forEach(e,t){return super.forEach(({value:r},i)=>e.call(t,r,i,this))}peek(e){const t=super.get(e);if(void 0!==t)return t.value}*entries(){yield*this[i]()}*values(){for(const[e,{value:t}]of super[i]())yield t}*[i](){for(const[e,{value:t}]of super[i]())yield[e,t]}_dropCount(){const e=[...super[i]()],[[t]]=e.sort(([e,t],[r,i])=>{const s=t.time===i.time?"count":"time";return t[s]-i[s]});this.delete(t)}_dropExpired(){const e=t()-this._maxAge;super.forEach(({time:t},r)=>{t<e&&this.delete(r)})}}return e.default=s,e}({}).default; |
+1
-1
| { | ||
| "name": "basic-lru", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "A lightweight Map based LRU implementation", | ||
@@ -5,0 +5,0 @@ "main": "cjs/index.js", |
11912
-0.9%