-
-
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.
Merge pull request #57 from avoidwork/privateMethods
Changing `has()` to be private as `#has()`, updating eslint rules
- Loading branch information
Showing
11 changed files
with
29 additions
and
29 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
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,7 +3,7 @@ | |
* | ||
* @copyright 2022 Jason Mulligan <[email protected]> | ||
* @license BSD-3-Clause | ||
* @version 9.0.3 | ||
* @version 10.0.0 | ||
*/ | ||
'use strict'; | ||
|
||
|
@@ -19,7 +19,7 @@ class LRU { | |
this.ttl = ttl; | ||
} | ||
|
||
has (key) { | ||
#has (key) { | ||
return key in this.items; | ||
} | ||
|
||
|
@@ -33,7 +33,7 @@ class LRU { | |
} | ||
|
||
delete (key) { | ||
if (this.has(key)) { | ||
if (this.#has(key)) { | ||
const item = this.items[key]; | ||
|
||
delete this.items[key]; | ||
|
@@ -81,7 +81,7 @@ class LRU { | |
get (key) { | ||
let result; | ||
|
||
if (this.has(key)) { | ||
if (this.#has(key)) { | ||
const item = this.items[key]; | ||
|
||
if (this.ttl > 0 && item.expiry <= new Date().getTime()) { | ||
|
@@ -102,7 +102,7 @@ class LRU { | |
set (key, value, bypass = false) { | ||
let item; | ||
|
||
if (bypass || this.has(key)) { | ||
if (bypass || this.#has(key)) { | ||
item = this.items[key]; | ||
item.value = value; | ||
|
||
|
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,7 +3,7 @@ | |
* | ||
* @copyright 2022 Jason Mulligan <[email protected]> | ||
* @license BSD-3-Clause | ||
* @version 9.0.3 | ||
* @version 10.0.0 | ||
*/ | ||
class LRU { | ||
constructor (max = 0, ttl = 0) { | ||
|
@@ -15,7 +15,7 @@ class LRU { | |
this.ttl = ttl; | ||
} | ||
|
||
has (key) { | ||
#has (key) { | ||
return key in this.items; | ||
} | ||
|
||
|
@@ -29,7 +29,7 @@ class LRU { | |
} | ||
|
||
delete (key) { | ||
if (this.has(key)) { | ||
if (this.#has(key)) { | ||
const item = this.items[key]; | ||
|
||
delete this.items[key]; | ||
|
@@ -77,7 +77,7 @@ class LRU { | |
get (key) { | ||
let result; | ||
|
||
if (this.has(key)) { | ||
if (this.#has(key)) { | ||
const item = this.items[key]; | ||
|
||
if (this.ttl > 0 && item.expiry <= new Date().getTime()) { | ||
|
@@ -98,7 +98,7 @@ class LRU { | |
set (key, value, bypass = false) { | ||
let item; | ||
|
||
if (bypass || this.has(key)) { | ||
if (bypass || this.#has(key)) { | ||
item = this.items[key]; | ||
item.value = value; | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,7 +3,7 @@ | |
* | ||
* @copyright 2022 Jason Mulligan <[email protected]> | ||
* @license BSD-3-Clause | ||
* @version 9.0.3 | ||
* @version 10.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 { | ||
constructor (max = 0, ttl = 0) { | ||
|
@@ -15,7 +15,7 @@ | |
this.ttl = ttl; | ||
} | ||
|
||
has (key) { | ||
#has (key) { | ||
return key in this.items; | ||
} | ||
|
||
|
@@ -29,7 +29,7 @@ | |
} | ||
|
||
delete (key) { | ||
if (this.has(key)) { | ||
if (this.#has(key)) { | ||
const item = this.items[key]; | ||
|
||
delete this.items[key]; | ||
|
@@ -77,7 +77,7 @@ | |
get (key) { | ||
let result; | ||
|
||
if (this.has(key)) { | ||
if (this.#has(key)) { | ||
const item = this.items[key]; | ||
|
||
if (this.ttl > 0 && item.expiry <= new Date().getTime()) { | ||
|
@@ -98,7 +98,7 @@ | |
set (key, value, bypass = false) { | ||
let item; | ||
|
||
if (bypass || this.has(key)) { | ||
if (bypass || this.#has(key)) { | ||
item = this.items[key]; | ||
item.value = value; | ||
|
||
|
Oops, something went wrong.