Skip to content

Commit

Permalink
Merge pull request #57 from avoidwork/privateMethods
Browse files Browse the repository at this point in the history
Changing `has()` to be private as `#has()`, updating eslint rules
  • Loading branch information
avoidwork authored Oct 28, 2022
2 parents d854d0e + 0d08874 commit ec0e5ba
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"amd": true
},
"parserOptions": {
"ecmaVersion": 2020,
"ecmaVersion": "latest",
"sourceType": "module"
},
"globals": {
Expand Down
10 changes: 5 additions & 5 deletions dist/tiny-lru.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2022 Jason Mulligan <[email protected]>
* @license BSD-3-Clause
* @version 9.0.3
* @version 10.0.0
*/
'use strict';

Expand All @@ -19,7 +19,7 @@ class LRU {
this.ttl = ttl;
}

has (key) {
#has (key) {
return key in this.items;
}

Expand All @@ -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];
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions dist/tiny-lru.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -15,7 +15,7 @@ class LRU {
this.ttl = ttl;
}

has (key) {
#has (key) {
return key in this.items;
}

Expand All @@ -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];
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions dist/tiny-lru.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/tiny-lru.esm.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dist/tiny-lru.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -15,7 +15,7 @@
this.ttl = ttl;
}

has (key) {
#has (key) {
return key in this.items;
}

Expand All @@ -29,7 +29,7 @@
}

delete (key) {
if (this.has(key)) {
if (this.#has(key)) {
const item = this.items[key];

delete this.items[key];
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;

Expand Down
Loading

0 comments on commit ec0e5ba

Please sign in to comment.