Skip to content

Commit 6a284e6

Browse files
committed
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
1 parent eddeef3 commit 6a284e6

15 files changed

+60
-61
lines changed

dist/tiny-lru.cjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
*
44
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
55
* @license BSD-3-Clause
6-
* @version 10.4.1
6+
* @version 11.0.0
77
*/
88
'use strict';
99

10+
function has (items, key) {
11+
return key in items;
12+
}
13+
1014
class LRU {
1115
constructor (max = 0, ttl = 0, resetTtl = false) {
1216
this.first = null;
@@ -28,7 +32,7 @@ class LRU {
2832
}
2933

3034
delete (key) {
31-
if (this.#has(key)) {
35+
if (has(this.items, key)) {
3236
const item = this.items[key];
3337

3438
delete this.items[key];
@@ -75,7 +79,7 @@ class LRU {
7579
expiresAt (key) {
7680
let result;
7781

78-
if (this.#has(key)) {
82+
if (has(this.items, key)) {
7983
result = this.items[key].expiry;
8084
}
8185

@@ -85,7 +89,7 @@ class LRU {
8589
get (key) {
8690
let result;
8791

88-
if (this.#has(key)) {
92+
if (has(this.items, key)) {
8993
const item = this.items[key];
9094

9195
if (this.ttl > 0 && item.expiry <= Date.now()) {
@@ -99,18 +103,14 @@ class LRU {
99103
return result;
100104
}
101105

102-
#has (key) {
103-
return key in this.items;
104-
}
105-
106106
keys () {
107107
return Object.keys(this.items);
108108
}
109109

110110
set (key, value, bypass = false, resetTtl = this.resetTtl) {
111111
let item;
112112

113-
if (bypass || this.#has(key)) {
113+
if (bypass || has(this.items, key)) {
114114
item = this.items[key];
115115
item.value = value;
116116

dist/tiny-lru.esm.min.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

dist/tiny-lru.esm.min.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/tiny-lru.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
*
44
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
55
* @license BSD-3-Clause
6-
* @version 10.4.1
6+
* @version 11.0.0
77
*/
8-
(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 {
8+
function has (items, key) {
9+
return key in items;
10+
}class LRU {
911
constructor (max = 0, ttl = 0, resetTtl = false) {
1012
this.first = null;
1113
this.items = Object.create(null);
@@ -26,7 +28,7 @@
2628
}
2729

2830
delete (key) {
29-
if (this.#has(key)) {
31+
if (has(this.items, key)) {
3032
const item = this.items[key];
3133

3234
delete this.items[key];
@@ -73,7 +75,7 @@
7375
expiresAt (key) {
7476
let result;
7577

76-
if (this.#has(key)) {
78+
if (has(this.items, key)) {
7779
result = this.items[key].expiry;
7880
}
7981

@@ -83,7 +85,7 @@
8385
get (key) {
8486
let result;
8587

86-
if (this.#has(key)) {
88+
if (has(this.items, key)) {
8789
const item = this.items[key];
8890

8991
if (this.ttl > 0 && item.expiry <= Date.now()) {
@@ -97,18 +99,14 @@
9799
return result;
98100
}
99101

100-
#has (key) {
101-
return key in this.items;
102-
}
103-
104102
keys () {
105103
return Object.keys(this.items);
106104
}
107105

108106
set (key, value, bypass = false, resetTtl = this.resetTtl) {
109107
let item;
110108

111-
if (bypass || this.#has(key)) {
109+
if (bypass || has(this.items, key)) {
112110
item = this.items[key];
113111
item.value = value;
114112

@@ -177,4 +175,4 @@ function lru (max = 1000, ttl = 0, resetTtl = false) {
177175
}
178176

179177
return new LRU(max, ttl, resetTtl);
180-
}exports.lru=lru;}));
178+
}export{lru};

dist/tiny-lru.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)