-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating rollup config such that ecma module is '.js' and UMD is 'umd…
….js', replacing private `#has()` with equal `has()`, updating test such that it imports by name, updating package.json such that `exports` key is present for esm and cjs usage
- Loading branch information
Showing
15 changed files
with
60 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,14 @@ | |
* | ||
* @copyright 2023 Jason Mulligan <[email protected]> | ||
* @license BSD-3-Clause | ||
* @version 10.4.1 | ||
* @version 11.0.0 | ||
*/ | ||
'use strict'; | ||
|
||
function has (items, key) { | ||
return key in items; | ||
} | ||
|
||
class LRU { | ||
constructor (max = 0, ttl = 0, resetTtl = false) { | ||
this.first = null; | ||
|
@@ -28,7 +32,7 @@ class LRU { | |
} | ||
|
||
delete (key) { | ||
if (this.#has(key)) { | ||
if (has(this.items, key)) { | ||
const item = this.items[key]; | ||
|
||
delete this.items[key]; | ||
|
@@ -75,7 +79,7 @@ class LRU { | |
expiresAt (key) { | ||
let result; | ||
|
||
if (this.#has(key)) { | ||
if (has(this.items, key)) { | ||
result = this.items[key].expiry; | ||
} | ||
|
||
|
@@ -85,7 +89,7 @@ class LRU { | |
get (key) { | ||
let result; | ||
|
||
if (this.#has(key)) { | ||
if (has(this.items, key)) { | ||
const item = this.items[key]; | ||
|
||
if (this.ttl > 0 && item.expiry <= Date.now()) { | ||
|
@@ -99,18 +103,14 @@ class LRU { | |
return result; | ||
} | ||
|
||
#has (key) { | ||
return key in this.items; | ||
} | ||
|
||
keys () { | ||
return Object.keys(this.items); | ||
} | ||
|
||
set (key, value, bypass = false, resetTtl = this.resetTtl) { | ||
let item; | ||
|
||
if (bypass || this.#has(key)) { | ||
if (bypass || has(this.items, key)) { | ||
item = this.items[key]; | ||
item.value = value; | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,11 @@ | |
* | ||
* @copyright 2023 Jason Mulligan <[email protected]> | ||
* @license BSD-3-Clause | ||
* @version 10.4.1 | ||
* @version 11.0.0 | ||
*/ | ||
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.lru={}));})(this,(function(exports){'use strict';class LRU { | ||
function has (items, key) { | ||
return key in items; | ||
}class LRU { | ||
constructor (max = 0, ttl = 0, resetTtl = false) { | ||
this.first = null; | ||
this.items = Object.create(null); | ||
|
@@ -26,7 +28,7 @@ | |
} | ||
|
||
delete (key) { | ||
if (this.#has(key)) { | ||
if (has(this.items, key)) { | ||
const item = this.items[key]; | ||
|
||
delete this.items[key]; | ||
|
@@ -73,7 +75,7 @@ | |
expiresAt (key) { | ||
let result; | ||
|
||
if (this.#has(key)) { | ||
if (has(this.items, key)) { | ||
result = this.items[key].expiry; | ||
} | ||
|
||
|
@@ -83,7 +85,7 @@ | |
get (key) { | ||
let result; | ||
|
||
if (this.#has(key)) { | ||
if (has(this.items, key)) { | ||
const item = this.items[key]; | ||
|
||
if (this.ttl > 0 && item.expiry <= Date.now()) { | ||
|
@@ -97,18 +99,14 @@ | |
return result; | ||
} | ||
|
||
#has (key) { | ||
return key in this.items; | ||
} | ||
|
||
keys () { | ||
return Object.keys(this.items); | ||
} | ||
|
||
set (key, value, bypass = false, resetTtl = this.resetTtl) { | ||
let item; | ||
|
||
if (bypass || this.#has(key)) { | ||
if (bypass || has(this.items, key)) { | ||
item = this.items[key]; | ||
item.value = value; | ||
|
||
|
@@ -177,4 +175,4 @@ function lru (max = 1000, ttl = 0, resetTtl = false) { | |
} | ||
|
||
return new LRU(max, ttl, resetTtl); | ||
}exports.lru=lru;})); | ||
}export{lru}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.