Skip to content

Commit 9330ff4

Browse files
committed
build: update dist files
1 parent 085e4f3 commit 9330ff4

7 files changed

Lines changed: 100 additions & 88 deletions

File tree

dist/tiny-lru.cjs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,7 @@ class LRU {
9191
delete this.items[key];
9292
this.size--;
9393

94-
if (item.prev !== null) {
95-
item.prev.next = item.next;
96-
}
97-
98-
if (item.next !== null) {
99-
item.next.prev = item.prev;
100-
}
101-
102-
if (this.first === item) {
103-
this.first = item.next;
104-
}
105-
106-
if (this.last === item) {
107-
this.last = item.prev;
108-
}
94+
this.unlink(item);
10995

11096
item.prev = null;
11197
item.next = null;
@@ -173,8 +159,7 @@ class LRU {
173159
this.first = null;
174160
this.last = null;
175161
} else {
176-
this.first = item.next;
177-
this.first.prev = null;
162+
this.unlink(item);
178163
}
179164

180165
item.next = null;
@@ -261,21 +246,17 @@ class LRU {
261246
}
262247

263248
/**
264-
* Efficiently moves an item to the end of the LRU list (most recently used position).
265-
* This is an internal optimization method that avoids the overhead of the full set() operation
266-
* when only LRU position needs to be updated.
249+
* Unlinks an item from the doubly-linked list.
250+
* Updates first/last pointers if needed.
251+
* Does NOT clear the item's prev/next pointers or delete from items map.
267252
*
268-
* @method moveToEnd
253+
* @method unlink
269254
* @memberof LRU
270-
* @param {Object} item - The cache item with prev/next pointers to reposition.
255+
* @param {Object} item - The cache item to unlink.
271256
* @private
272-
* @since 11.3.5
257+
* @since 11.4.8
273258
*/
274-
moveToEnd(item) {
275-
if (this.last === item) {
276-
return;
277-
}
278-
259+
unlink(item) {
279260
if (item.prev !== null) {
280261
item.prev.next = item.next;
281262
}
@@ -288,6 +269,29 @@ class LRU {
288269
this.first = item.next;
289270
}
290271

272+
if (this.last === item) {
273+
this.last = item.prev;
274+
}
275+
}
276+
277+
/**
278+
* Efficiently moves an item to the end of the LRU list (most recently used position).
279+
* This is an internal optimization method that avoids the overhead of the full set() operation
280+
* when only LRU position needs to be updated.
281+
*
282+
* @method moveToEnd
283+
* @memberof LRU
284+
* @param {Object} item - The cache item with prev/next pointers to reposition.
285+
* @private
286+
* @since 11.3.5
287+
*/
288+
moveToEnd(item) {
289+
if (this.last === item) {
290+
return;
291+
}
292+
293+
this.unlink(item);
294+
291295
item.prev = this.last;
292296
item.next = null;
293297
this.last.next = item;

dist/tiny-lru.js

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,7 @@ class LRU {
8989
delete this.items[key];
9090
this.size--;
9191

92-
if (item.prev !== null) {
93-
item.prev.next = item.next;
94-
}
95-
96-
if (item.next !== null) {
97-
item.next.prev = item.prev;
98-
}
99-
100-
if (this.first === item) {
101-
this.first = item.next;
102-
}
103-
104-
if (this.last === item) {
105-
this.last = item.prev;
106-
}
92+
this.unlink(item);
10793

10894
item.prev = null;
10995
item.next = null;
@@ -171,8 +157,7 @@ class LRU {
171157
this.first = null;
172158
this.last = null;
173159
} else {
174-
this.first = item.next;
175-
this.first.prev = null;
160+
this.unlink(item);
176161
}
177162

178163
item.next = null;
@@ -259,21 +244,17 @@ class LRU {
259244
}
260245

261246
/**
262-
* Efficiently moves an item to the end of the LRU list (most recently used position).
263-
* This is an internal optimization method that avoids the overhead of the full set() operation
264-
* when only LRU position needs to be updated.
247+
* Unlinks an item from the doubly-linked list.
248+
* Updates first/last pointers if needed.
249+
* Does NOT clear the item's prev/next pointers or delete from items map.
265250
*
266-
* @method moveToEnd
251+
* @method unlink
267252
* @memberof LRU
268-
* @param {Object} item - The cache item with prev/next pointers to reposition.
253+
* @param {Object} item - The cache item to unlink.
269254
* @private
270-
* @since 11.3.5
255+
* @since 11.4.8
271256
*/
272-
moveToEnd(item) {
273-
if (this.last === item) {
274-
return;
275-
}
276-
257+
unlink(item) {
277258
if (item.prev !== null) {
278259
item.prev.next = item.next;
279260
}
@@ -286,6 +267,29 @@ class LRU {
286267
this.first = item.next;
287268
}
288269

270+
if (this.last === item) {
271+
this.last = item.prev;
272+
}
273+
}
274+
275+
/**
276+
* Efficiently moves an item to the end of the LRU list (most recently used position).
277+
* This is an internal optimization method that avoids the overhead of the full set() operation
278+
* when only LRU position needs to be updated.
279+
*
280+
* @method moveToEnd
281+
* @memberof LRU
282+
* @param {Object} item - The cache item with prev/next pointers to reposition.
283+
* @private
284+
* @since 11.3.5
285+
*/
286+
moveToEnd(item) {
287+
if (this.last === item) {
288+
return;
289+
}
290+
291+
this.unlink(item);
292+
289293
item.prev = this.last;
290294
item.next = null;
291295
this.last.next = item;

dist/tiny-lru.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tiny-lru.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tiny-lru.umd.js

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,7 @@ class LRU {
8989
delete this.items[key];
9090
this.size--;
9191

92-
if (item.prev !== null) {
93-
item.prev.next = item.next;
94-
}
95-
96-
if (item.next !== null) {
97-
item.next.prev = item.prev;
98-
}
99-
100-
if (this.first === item) {
101-
this.first = item.next;
102-
}
103-
104-
if (this.last === item) {
105-
this.last = item.prev;
106-
}
92+
this.unlink(item);
10793

10894
item.prev = null;
10995
item.next = null;
@@ -171,8 +157,7 @@ class LRU {
171157
this.first = null;
172158
this.last = null;
173159
} else {
174-
this.first = item.next;
175-
this.first.prev = null;
160+
this.unlink(item);
176161
}
177162

178163
item.next = null;
@@ -259,21 +244,17 @@ class LRU {
259244
}
260245

261246
/**
262-
* Efficiently moves an item to the end of the LRU list (most recently used position).
263-
* This is an internal optimization method that avoids the overhead of the full set() operation
264-
* when only LRU position needs to be updated.
247+
* Unlinks an item from the doubly-linked list.
248+
* Updates first/last pointers if needed.
249+
* Does NOT clear the item's prev/next pointers or delete from items map.
265250
*
266-
* @method moveToEnd
251+
* @method unlink
267252
* @memberof LRU
268-
* @param {Object} item - The cache item with prev/next pointers to reposition.
253+
* @param {Object} item - The cache item to unlink.
269254
* @private
270-
* @since 11.3.5
255+
* @since 11.4.8
271256
*/
272-
moveToEnd(item) {
273-
if (this.last === item) {
274-
return;
275-
}
276-
257+
unlink(item) {
277258
if (item.prev !== null) {
278259
item.prev.next = item.next;
279260
}
@@ -286,6 +267,29 @@ class LRU {
286267
this.first = item.next;
287268
}
288269

270+
if (this.last === item) {
271+
this.last = item.prev;
272+
}
273+
}
274+
275+
/**
276+
* Efficiently moves an item to the end of the LRU list (most recently used position).
277+
* This is an internal optimization method that avoids the overhead of the full set() operation
278+
* when only LRU position needs to be updated.
279+
*
280+
* @method moveToEnd
281+
* @memberof LRU
282+
* @param {Object} item - The cache item with prev/next pointers to reposition.
283+
* @private
284+
* @since 11.3.5
285+
*/
286+
moveToEnd(item) {
287+
if (this.last === item) {
288+
return;
289+
}
290+
291+
this.unlink(item);
292+
289293
item.prev = this.last;
290294
item.next = null;
291295
this.last.next = item;

dist/tiny-lru.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)