lru-cache
Advanced tools
Comparing version 7.6.0 to 7.6.1
22
index.js
@@ -64,3 +64,6 @@ const perf = typeof performance === 'object' && performance && | ||
constructor (max) { | ||
const UintArray = max ? getUintArray(max) : Array | ||
if (max === 0) { | ||
return [] | ||
} | ||
const UintArray = getUintArray(max) | ||
this.heap = new UintArray(max) | ||
@@ -129,3 +132,2 @@ this.length = 0 | ||
this.keyMap = new Map() | ||
@@ -279,3 +281,3 @@ this.keyList = new Array(max).fill(null) | ||
while (this.calculatedSize > maxSize) { | ||
this.evict() | ||
this.evict(true) | ||
} | ||
@@ -496,4 +498,4 @@ this.calculatedSize += this.sizes[index] | ||
} | ||
if (this.size === this.max) { | ||
return this.evict() | ||
if (this.size === this.max && this.max !== 0) { | ||
return this.evict(false) | ||
} | ||
@@ -510,3 +512,3 @@ if (this.free.length !== 0) { | ||
const val = this.valList[this.head] | ||
this.evict() | ||
this.evict(true) | ||
return val | ||
@@ -516,3 +518,3 @@ } | ||
evict () { | ||
evict (free) { | ||
const head = this.head | ||
@@ -526,2 +528,8 @@ const k = this.keyList[head] | ||
this.removeItemSize(head) | ||
// if we aren't about to use the index, then null these out | ||
if (free) { | ||
this.keyList[head] = null | ||
this.valList[head] = null | ||
this.free.push(head) | ||
} | ||
this.head = this.next[head] | ||
@@ -528,0 +536,0 @@ this.keyMap.delete(k) |
{ | ||
"name": "lru-cache", | ||
"description": "A cache object that deletes the least-recently-used items.", | ||
"version": "7.6.0", | ||
"version": "7.6.1", | ||
"publishConfig": { | ||
"tag": "v7.6-backport" | ||
}, | ||
"author": "Isaac Z. Schlueter <i@izs.me>", | ||
@@ -25,5 +28,6 @@ "keywords": [ | ||
"benchmark": "^2.1.4", | ||
"clock-mock": "^1.0.3", | ||
"clock-mock": "^1.0.4", | ||
"heapdump": "^0.3.15", | ||
"size-limit": "^7.0.8", | ||
"tap": "^15.1.6" | ||
"tap": "^16.0.1" | ||
}, | ||
@@ -38,3 +42,6 @@ "license": "ISC", | ||
"tap": { | ||
"coverage-map": "map.js" | ||
"coverage-map": "map.js", | ||
"node-arg": [ | ||
"--expose-gc" | ||
] | ||
}, | ||
@@ -41,0 +48,0 @@ "size-limit": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
46709
689
0
6