Comparing version 1.1.0 to 1.1.1
18
index.js
@@ -21,3 +21,3 @@ var hash = require('./crc16') | ||
this.size = this.buckets * this.collisions | ||
this.indexedValues = !!opts.indexedValues | ||
this.wrap = !opts.indexedValues | ||
this.cache = new Array(this.size) | ||
@@ -39,3 +39,3 @@ this.hash = this.buckets === 65536 ? hash : maskedHash(this.buckets - 1) | ||
// no exiting version, but we have space to store it | ||
page = this.cache[ptr] = this.indexedValues ? val : new Node(index, val) | ||
page = this.cache[ptr] = this.wrap ? new Node(index, val) : val | ||
move(this.cache, pageStart, ptr, page) | ||
@@ -47,4 +47,4 @@ return | ||
// update existing version and move to head of bucket | ||
if (this.indexedValues) this.cache[ptr] = val | ||
else page.value = val | ||
if (this.wrap) page.value = val | ||
else this.cache[ptr] = val | ||
move(this.cache, pageStart, ptr, page) | ||
@@ -58,9 +58,9 @@ return | ||
// bucket is full, update oldest (last element in bucket) | ||
if (this.indexedValues) { | ||
if (this.evict) this.evict(page.index, page) | ||
this.cache[ptr - 1] = val | ||
} else { | ||
if (this.wrap) { | ||
if (this.evict) this.evict(page.index, page.value) | ||
page.index = index | ||
page.value = val | ||
} else { | ||
if (this.evict) this.evict(page.index, page) | ||
this.cache[ptr - 1] = val | ||
} | ||
@@ -84,3 +84,3 @@ move(this.cache, pageStart, ptr - 1, page) | ||
return this.indexedValues ? page : page.value | ||
return this.wrap ? page.value : page | ||
} | ||
@@ -87,0 +87,0 @@ |
{ | ||
"name": "array-lru", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A really fast LRU cache for array items (numeric keys)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
10720