Skip to content

Commit

Permalink
Updating rollup config such that ecma module is '.js' and UMD is 'umd…
Browse files Browse the repository at this point in the history
….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
avoidwork committed Apr 7, 2023
1 parent eddeef3 commit 6a284e6
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 61 deletions.
18 changes: 9 additions & 9 deletions dist/tiny-lru.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -75,7 +79,7 @@ class LRU {
expiresAt (key) {
let result;

if (this.#has(key)) {
if (has(this.items, key)) {
result = this.items[key].expiry;
}

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

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

This file was deleted.

1 change: 0 additions & 1 deletion dist/tiny-lru.esm.min.js.map

This file was deleted.

20 changes: 9 additions & 11 deletions dist/tiny-lru.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -26,7 +28,7 @@
}

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

delete this.items[key];
Expand Down Expand Up @@ -73,7 +75,7 @@
expiresAt (key) {
let result;

if (this.#has(key)) {
if (has(this.items, key)) {
result = this.items[key].expiry;
}

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

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

return new LRU(max, ttl, resetTtl);
}exports.lru=lru;}));
}export{lru};
4 changes: 2 additions & 2 deletions dist/tiny-lru.min.js

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

Loading

0 comments on commit 6a284e6

Please sign in to comment.