Comparing version 5.0.7 to 5.1.0
@@ -8,3 +8,3 @@ /** | ||
* @link https://github.com/avoidwork/tiny-lru | ||
* @version 5.0.7 | ||
* @version 5.1.0 | ||
*/ | ||
@@ -33,3 +33,26 @@ "use strict"; | ||
delete (key, bypass = false) { | ||
return this.remove(key, bypass); | ||
if (bypass === true || this.has(key) === true) { | ||
const item = this.cache[key]; | ||
delete this.cache[key]; | ||
this.length--; | ||
if (item.next !== empty) { | ||
this.cache[item.next].prev = item.prev; | ||
} | ||
if (item.prev !== empty) { | ||
this.cache[item.prev].next = item.next; | ||
} | ||
if (this.first === key) { | ||
this.first = item.next; | ||
} | ||
if (this.last === key) { | ||
this.last = item.prev; | ||
} | ||
} | ||
return this; | ||
} | ||
@@ -66,27 +89,8 @@ | ||
keys () { | ||
return Object.keys(this.cache); | ||
} | ||
remove (key, bypass = false) { | ||
if (bypass === true || this.has(key) === true) { | ||
const item = this.cache[key]; | ||
delete this.cache[key]; | ||
this.length--; | ||
if (item.next !== empty) { | ||
this.cache[item.next].prev = item.prev; | ||
} | ||
if (item.prev !== empty) { | ||
this.cache[item.prev].next = item.next; | ||
} | ||
if (this.first === key) { | ||
this.first = item.next; | ||
} | ||
if (this.last === key) { | ||
this.last = item.prev; | ||
} | ||
} | ||
return this; | ||
return this.delete(key, bypass); | ||
} | ||
@@ -93,0 +97,0 @@ |
{ | ||
"name": "tiny-lru", | ||
"description": "Tiny LRU cache for Client or Server", | ||
"version": "5.0.7", | ||
"version": "5.1.0", | ||
"homepage": "https://github.com/avoidwork/tiny-lru", | ||
@@ -6,0 +6,0 @@ "author": "Jason Mulligan <jason.mulligan@avoidwork.com>", |
@@ -88,2 +88,15 @@ # Tiny LRU | ||
## keys | ||
### Method | ||
Returns an `Array` of cache item keys. | ||
return {Array} Array of keys | ||
**Example** | ||
```javascript | ||
console.log(cache.keys()); | ||
``` | ||
## max | ||
@@ -131,3 +144,3 @@ ### Property | ||
Removes item from cache | ||
(Deprecated) Removes item from cache | ||
@@ -134,0 +147,0 @@ param {String} key Item key |
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
8381
127
185