File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ class LRUCache {
127127 throw new TypeError ( 'cannot set sizeCalculation without setting maxSize' )
128128 }
129129 if ( typeof this . sizeCalculation !== 'function' ) {
130- throw new TypeError ( 'sizeCalculating set to non-function' )
130+ throw new TypeError ( 'sizeCalculation set to non-function' )
131131 }
132132 }
133133
@@ -273,11 +273,18 @@ class LRUCache {
273273 this . sizes = new ZeroArray ( this . max )
274274 this . removeItemSize = index => this . calculatedSize -= this . sizes [ index ]
275275 this . requireSize = ( k , v , size , sizeCalculation ) => {
276- if ( sizeCalculation && ! size ) {
277- size = sizeCalculation ( v , k )
278- }
279276 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+ }
281288 }
282289 return size
283290 }
@@ -559,7 +566,7 @@ class LRUCache {
559566 if ( this . isBackgroundFetch ( v ) ) {
560567 return v
561568 }
562- const ac = new AbortController ( )
569+ const ac = new AC ( )
563570 const fetchOpts = {
564571 signal : ac . signal ,
565572 options,
Original file line number Diff line number Diff line change 11{
22 "name" : " lru-cache" ,
33 "description" : " A cache object that deletes the least-recently-used items." ,
4- "version" : " 7.7.1 " ,
4+ "version" : " 7.7.3 " ,
55 "author" : " Isaac Z. Schlueter <i@izs.me>" ,
66 "keywords" : [
77 " mru" ,
2222 "devDependencies" : {
2323 "@size-limit/preset-small-lib" : " ^7.0.8" ,
2424 "benchmark" : " ^2.1.4" ,
25- "clock-mock" : " ^1.0.3 " ,
25+ "clock-mock" : " ^1.0.4 " ,
2626 "size-limit" : " ^7.0.8" ,
2727 "tap" : " ^15.1.6"
2828 },
Original file line number Diff line number Diff line change 45254525 }
45264526 },
45274527 "node_modules/lru-cache" : {
4528- "version" : " 7.7.1" ,
4528+ "version" : " 7.7.3" ,
4529+ "resolved" : " https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz" ,
4530+ "integrity" : " sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==" ,
45294531 "inBundle" : true ,
4530- "license" : " ISC" ,
45314532 "engines" : {
45324533 "node" : " >=12"
45334534 }
1285912860 "peer" : true
1286012861 },
1286112862 "lru-cache" : {
12862- "version" : " 7.7.1"
12863+ "version" : " 7.7.3" ,
12864+ "resolved" : " https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz" ,
12865+ "integrity" : " sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw=="
1286312866 },
1286412867 "make-dir" : {
1286512868 "version" : " 3.1.0" ,
You can’t perform that action at this time.
0 commit comments