File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ class LRUCache {
127
127
throw new TypeError ( 'cannot set sizeCalculation without setting maxSize' )
128
128
}
129
129
if ( typeof this . sizeCalculation !== 'function' ) {
130
- throw new TypeError ( 'sizeCalculating set to non-function' )
130
+ throw new TypeError ( 'sizeCalculation set to non-function' )
131
131
}
132
132
}
133
133
@@ -273,11 +273,18 @@ class LRUCache {
273
273
this . sizes = new ZeroArray ( this . max )
274
274
this . removeItemSize = index => this . calculatedSize -= this . sizes [ index ]
275
275
this . requireSize = ( k , v , size , sizeCalculation ) => {
276
- if ( sizeCalculation && ! size ) {
277
- size = sizeCalculation ( v , k )
278
- }
279
276
if ( ! isPosInt ( size ) ) {
280
- throw new TypeError ( 'size must be positive integer' )
277
+ if ( sizeCalculation ) {
278
+ if ( typeof sizeCalculation !== 'function' ) {
279
+ throw new TypeError ( 'sizeCalculation must be a function' )
280
+ }
281
+ size = sizeCalculation ( v , k )
282
+ if ( ! isPosInt ( size ) ) {
283
+ throw new TypeError ( 'sizeCalculation return invalid (expect positive integer)' )
284
+ }
285
+ } else {
286
+ throw new TypeError ( 'invalid size value (must be positive integer)' )
287
+ }
281
288
}
282
289
return size
283
290
}
@@ -559,7 +566,7 @@ class LRUCache {
559
566
if ( this . isBackgroundFetch ( v ) ) {
560
567
return v
561
568
}
562
- const ac = new AbortController ( )
569
+ const ac = new AC ( )
563
570
const fetchOpts = {
564
571
signal : ac . signal ,
565
572
options,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " lru-cache" ,
3
3
"description" : " A cache object that deletes the least-recently-used items." ,
4
- "version" : " 7.7.1 " ,
4
+ "version" : " 7.7.3 " ,
5
5
"author" : " Isaac Z. Schlueter <i@izs.me>" ,
6
6
"keywords" : [
7
7
" mru" ,
22
22
"devDependencies" : {
23
23
"@size-limit/preset-small-lib" : " ^7.0.8" ,
24
24
"benchmark" : " ^2.1.4" ,
25
- "clock-mock" : " ^1.0.3 " ,
25
+ "clock-mock" : " ^1.0.4 " ,
26
26
"size-limit" : " ^7.0.8" ,
27
27
"tap" : " ^15.1.6"
28
28
},
Original file line number Diff line number Diff line change 4605
4605
}
4606
4606
},
4607
4607
"node_modules/lru-cache" : {
4608
- "version" : " 7.7.1" ,
4608
+ "version" : " 7.7.3" ,
4609
+ "resolved" : " https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz" ,
4610
+ "integrity" : " sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==" ,
4609
4611
"inBundle" : true ,
4610
- "license" : " ISC" ,
4611
4612
"engines" : {
4612
4613
"node" : " >=12"
4613
4614
}
13040
13041
"peer" : true
13041
13042
},
13042
13043
"lru-cache" : {
13043
- "version" : " 7.7.1"
13044
+ "version" : " 7.7.3" ,
13045
+ "resolved" : " https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz" ,
13046
+ "integrity" : " sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw=="
13044
13047
},
13045
13048
"make-dir" : {
13046
13049
"version" : " 3.1.0" ,
You can’t perform that action at this time.
0 commit comments