@parcel/utils 2.0.0-canary.1820 → 2.0.0-canary.1826
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +50 -50
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -36169,17 +36169,17 @@ $9a7a296607515479$export$fac44ee5b035f737 = (parcelRequire("ib1eJ"));
|
|
|
36169
36169
|
|
|
36170
36170
|
/**
|
|
36171
36171
|
* @module LRUCache
|
|
36172
|
-
*/ const $
|
|
36173
|
-
const $
|
|
36174
|
-
/* c8 ignore start */ const $
|
|
36175
|
-
/* c8 ignore start */ const $
|
|
36176
|
-
typeof $
|
|
36177
|
-
};
|
|
36178
|
-
let $
|
|
36179
|
-
let $
|
|
36180
|
-
/* c8 ignore start */ if (typeof $
|
|
36172
|
+
*/ const $eb1586208fd028d6$var$perf = typeof performance === 'object' && performance && typeof performance.now === 'function' ? performance : Date;
|
|
36173
|
+
const $eb1586208fd028d6$var$warned = new Set();
|
|
36174
|
+
/* c8 ignore start */ const $eb1586208fd028d6$var$PROCESS = typeof process === 'object' && !!process ? process : {};
|
|
36175
|
+
/* c8 ignore start */ const $eb1586208fd028d6$var$emitWarning = (msg, type, code, fn)=>{
|
|
36176
|
+
typeof $eb1586208fd028d6$var$PROCESS.emitWarning === 'function' ? $eb1586208fd028d6$var$PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
36177
|
+
};
|
|
36178
|
+
let $eb1586208fd028d6$var$AC = globalThis.AbortController;
|
|
36179
|
+
let $eb1586208fd028d6$var$AS = globalThis.AbortSignal;
|
|
36180
|
+
/* c8 ignore start */ if (typeof $eb1586208fd028d6$var$AC === 'undefined') {
|
|
36181
36181
|
//@ts-ignore
|
|
36182
|
-
$
|
|
36182
|
+
$eb1586208fd028d6$var$AS = class AbortSignal {
|
|
36183
36183
|
onabort;
|
|
36184
36184
|
_onabort = [];
|
|
36185
36185
|
reason;
|
|
@@ -36189,11 +36189,11 @@ let $34c2e4b61193a7f9$var$AS = globalThis.AbortSignal;
|
|
|
36189
36189
|
}
|
|
36190
36190
|
};
|
|
36191
36191
|
//@ts-ignore
|
|
36192
|
-
$
|
|
36192
|
+
$eb1586208fd028d6$var$AC = class AbortController {
|
|
36193
36193
|
constructor(){
|
|
36194
36194
|
warnACPolyfill();
|
|
36195
36195
|
}
|
|
36196
|
-
signal = new $
|
|
36196
|
+
signal = new $eb1586208fd028d6$var$AS();
|
|
36197
36197
|
abort(reason) {
|
|
36198
36198
|
if (this.signal.aborted) return;
|
|
36199
36199
|
//@ts-ignore
|
|
@@ -36205,16 +36205,16 @@ let $34c2e4b61193a7f9$var$AS = globalThis.AbortSignal;
|
|
|
36205
36205
|
this.signal.onabort?.(reason);
|
|
36206
36206
|
}
|
|
36207
36207
|
};
|
|
36208
|
-
let printACPolyfillWarning = $
|
|
36208
|
+
let printACPolyfillWarning = $eb1586208fd028d6$var$PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
36209
36209
|
const warnACPolyfill = ()=>{
|
|
36210
36210
|
if (!printACPolyfillWarning) return;
|
|
36211
36211
|
printACPolyfillWarning = false;
|
|
36212
|
-
$
|
|
36212
|
+
$eb1586208fd028d6$var$emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
|
|
36213
36213
|
};
|
|
36214
36214
|
}
|
|
36215
|
-
/* c8 ignore stop */ const $
|
|
36216
|
-
const $
|
|
36217
|
-
const $
|
|
36215
|
+
/* c8 ignore stop */ const $eb1586208fd028d6$var$shouldWarn = (code)=>!$eb1586208fd028d6$var$warned.has(code);
|
|
36216
|
+
const $eb1586208fd028d6$var$TYPE = Symbol('type');
|
|
36217
|
+
const $eb1586208fd028d6$var$isPosInt = (n)=>n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
36218
36218
|
/* c8 ignore start */ // This is a little bit ridiculous, tbh.
|
|
36219
36219
|
// The maximum array length is 2^32-1 or thereabouts on most JS impls.
|
|
36220
36220
|
// And well before that point, you're caching the entire world, I mean,
|
|
@@ -36223,28 +36223,28 @@ const $34c2e4b61193a7f9$var$isPosInt = (n)=>n && n === Math.floor(n) && n > 0 &&
|
|
|
36223
36223
|
// zeroes at init time is brutal when you get that big.
|
|
36224
36224
|
// But why not be complete?
|
|
36225
36225
|
// Maybe in the future, these limits will have expanded.
|
|
36226
|
-
const $
|
|
36227
|
-
/* c8 ignore stop */ class $
|
|
36226
|
+
const $eb1586208fd028d6$var$getUintArray = (max)=>!$eb1586208fd028d6$var$isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? $eb1586208fd028d6$var$ZeroArray : null;
|
|
36227
|
+
/* c8 ignore stop */ class $eb1586208fd028d6$var$ZeroArray extends Array {
|
|
36228
36228
|
constructor(size){
|
|
36229
36229
|
super(size);
|
|
36230
36230
|
this.fill(0);
|
|
36231
36231
|
}
|
|
36232
36232
|
}
|
|
36233
|
-
class $
|
|
36233
|
+
class $eb1586208fd028d6$var$Stack {
|
|
36234
36234
|
heap;
|
|
36235
36235
|
length;
|
|
36236
36236
|
// private constructor
|
|
36237
36237
|
static #constructing = false;
|
|
36238
36238
|
static create(max) {
|
|
36239
|
-
const HeapCls = $
|
|
36239
|
+
const HeapCls = $eb1586208fd028d6$var$getUintArray(max);
|
|
36240
36240
|
if (!HeapCls) return [];
|
|
36241
|
-
$
|
|
36242
|
-
const s = new $
|
|
36243
|
-
$
|
|
36241
|
+
$eb1586208fd028d6$var$Stack.#constructing = true;
|
|
36242
|
+
const s = new $eb1586208fd028d6$var$Stack(max, HeapCls);
|
|
36243
|
+
$eb1586208fd028d6$var$Stack.#constructing = false;
|
|
36244
36244
|
return s;
|
|
36245
36245
|
}
|
|
36246
36246
|
constructor(max, HeapCls){
|
|
36247
|
-
/* c8 ignore start */ if (!$
|
|
36247
|
+
/* c8 ignore start */ if (!$eb1586208fd028d6$var$Stack.#constructing) throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
36248
36248
|
/* c8 ignore stop */ this.heap = new HeapCls(max);
|
|
36249
36249
|
this.length = 0;
|
|
36250
36250
|
}
|
|
@@ -36255,7 +36255,7 @@ class $34c2e4b61193a7f9$var$Stack {
|
|
|
36255
36255
|
return this.heap[--this.length];
|
|
36256
36256
|
}
|
|
36257
36257
|
}
|
|
36258
|
-
class $
|
|
36258
|
+
class $eb1586208fd028d6$export$182500e6725aad9a {
|
|
36259
36259
|
// options that cannot be changed without disaster
|
|
36260
36260
|
#max;
|
|
36261
36261
|
#maxSize;
|
|
@@ -36402,8 +36402,8 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36402
36402
|
}
|
|
36403
36403
|
constructor(options){
|
|
36404
36404
|
const { max: max = 0, ttl: ttl, ttlResolution: ttlResolution = 1, ttlAutopurge: ttlAutopurge, updateAgeOnGet: updateAgeOnGet, updateAgeOnHas: updateAgeOnHas, allowStale: allowStale, dispose: dispose, disposeAfter: disposeAfter, noDisposeOnSet: noDisposeOnSet, noUpdateTTL: noUpdateTTL, maxSize: maxSize = 0, maxEntrySize: maxEntrySize = 0, sizeCalculation: sizeCalculation, fetchMethod: fetchMethod, memoMethod: memoMethod, noDeleteOnFetchRejection: noDeleteOnFetchRejection, noDeleteOnStaleGet: noDeleteOnStaleGet, allowStaleOnFetchRejection: allowStaleOnFetchRejection, allowStaleOnFetchAbort: allowStaleOnFetchAbort, ignoreFetchAbort: ignoreFetchAbort } = options;
|
|
36405
|
-
if (max !== 0 && !$
|
|
36406
|
-
const UintArray = max ? $
|
|
36405
|
+
if (max !== 0 && !$eb1586208fd028d6$var$isPosInt(max)) throw new TypeError('max option must be a nonnegative integer');
|
|
36406
|
+
const UintArray = max ? $eb1586208fd028d6$var$getUintArray(max) : Array;
|
|
36407
36407
|
if (!UintArray) throw new Error('invalid max value: ' + max);
|
|
36408
36408
|
this.#max = max;
|
|
36409
36409
|
this.#maxSize = maxSize;
|
|
@@ -36425,7 +36425,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36425
36425
|
this.#prev = new UintArray(max);
|
|
36426
36426
|
this.#head = 0;
|
|
36427
36427
|
this.#tail = 0;
|
|
36428
|
-
this.#free = $
|
|
36428
|
+
this.#free = $eb1586208fd028d6$var$Stack.create(max);
|
|
36429
36429
|
this.#size = 0;
|
|
36430
36430
|
this.#calculatedSize = 0;
|
|
36431
36431
|
if (typeof dispose === 'function') this.#dispose = dispose;
|
|
@@ -36447,30 +36447,30 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36447
36447
|
// NB: maxEntrySize is set to maxSize if it's set
|
|
36448
36448
|
if (this.maxEntrySize !== 0) {
|
|
36449
36449
|
if (this.#maxSize !== 0) {
|
|
36450
|
-
if (!$
|
|
36450
|
+
if (!$eb1586208fd028d6$var$isPosInt(this.#maxSize)) throw new TypeError('maxSize must be a positive integer if specified');
|
|
36451
36451
|
}
|
|
36452
|
-
if (!$
|
|
36452
|
+
if (!$eb1586208fd028d6$var$isPosInt(this.maxEntrySize)) throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
36453
36453
|
this.#initializeSizeTracking();
|
|
36454
36454
|
}
|
|
36455
36455
|
this.allowStale = !!allowStale;
|
|
36456
36456
|
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
36457
36457
|
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
36458
36458
|
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
36459
|
-
this.ttlResolution = $
|
|
36459
|
+
this.ttlResolution = $eb1586208fd028d6$var$isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
|
|
36460
36460
|
this.ttlAutopurge = !!ttlAutopurge;
|
|
36461
36461
|
this.ttl = ttl || 0;
|
|
36462
36462
|
if (this.ttl) {
|
|
36463
|
-
if (!$
|
|
36463
|
+
if (!$eb1586208fd028d6$var$isPosInt(this.ttl)) throw new TypeError('ttl must be a positive integer if specified');
|
|
36464
36464
|
this.#initializeTTLTracking();
|
|
36465
36465
|
}
|
|
36466
36466
|
// do not allow completely unbounded caches
|
|
36467
36467
|
if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
36468
36468
|
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
36469
36469
|
const code = 'LRU_CACHE_UNBOUNDED';
|
|
36470
|
-
if ($
|
|
36471
|
-
$
|
|
36470
|
+
if ($eb1586208fd028d6$var$shouldWarn(code)) {
|
|
36471
|
+
$eb1586208fd028d6$var$warned.add(code);
|
|
36472
36472
|
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
36473
|
-
$
|
|
36473
|
+
$eb1586208fd028d6$var$emitWarning(msg, 'UnboundedCacheWarning', code, $eb1586208fd028d6$export$182500e6725aad9a);
|
|
36474
36474
|
}
|
|
36475
36475
|
}
|
|
36476
36476
|
}
|
|
@@ -36481,11 +36481,11 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36481
36481
|
return this.#keyMap.has(key) ? Infinity : 0;
|
|
36482
36482
|
}
|
|
36483
36483
|
#initializeTTLTracking() {
|
|
36484
|
-
const ttls = new $
|
|
36485
|
-
const starts = new $
|
|
36484
|
+
const ttls = new $eb1586208fd028d6$var$ZeroArray(this.#max);
|
|
36485
|
+
const starts = new $eb1586208fd028d6$var$ZeroArray(this.#max);
|
|
36486
36486
|
this.#ttls = ttls;
|
|
36487
36487
|
this.#starts = starts;
|
|
36488
|
-
this.#setItemTTL = (index, ttl, start = $
|
|
36488
|
+
this.#setItemTTL = (index, ttl, start = $eb1586208fd028d6$var$perf.now())=>{
|
|
36489
36489
|
starts[index] = ttl !== 0 ? start : 0;
|
|
36490
36490
|
ttls[index] = ttl;
|
|
36491
36491
|
if (ttl !== 0 && this.ttlAutopurge) {
|
|
@@ -36497,7 +36497,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36497
36497
|
/* c8 ignore stop */ }
|
|
36498
36498
|
};
|
|
36499
36499
|
this.#updateItemAge = (index)=>{
|
|
36500
|
-
starts[index] = ttls[index] !== 0 ? $
|
|
36500
|
+
starts[index] = ttls[index] !== 0 ? $eb1586208fd028d6$var$perf.now() : 0;
|
|
36501
36501
|
};
|
|
36502
36502
|
this.#statusTTL = (status, index)=>{
|
|
36503
36503
|
if (ttls[index]) {
|
|
@@ -36515,7 +36515,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36515
36515
|
// that costly call repeatedly.
|
|
36516
36516
|
let cachedNow = 0;
|
|
36517
36517
|
const getNow = ()=>{
|
|
36518
|
-
const n = $
|
|
36518
|
+
const n = $eb1586208fd028d6$var$perf.now();
|
|
36519
36519
|
if (this.ttlResolution > 0) {
|
|
36520
36520
|
cachedNow = n;
|
|
36521
36521
|
const t = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
@@ -36545,7 +36545,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36545
36545
|
#setItemTTL = ()=>{};
|
|
36546
36546
|
/* c8 ignore stop */ #isStale = ()=>false;
|
|
36547
36547
|
#initializeSizeTracking() {
|
|
36548
|
-
const sizes = new $
|
|
36548
|
+
const sizes = new $eb1586208fd028d6$var$ZeroArray(this.#max);
|
|
36549
36549
|
this.#calculatedSize = 0;
|
|
36550
36550
|
this.#sizes = sizes;
|
|
36551
36551
|
this.#removeItemSize = (index)=>{
|
|
@@ -36556,11 +36556,11 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36556
36556
|
// provisionally accept background fetches.
|
|
36557
36557
|
// actual value size will be checked when they return.
|
|
36558
36558
|
if (this.#isBackgroundFetch(v)) return 0;
|
|
36559
|
-
if (!$
|
|
36559
|
+
if (!$eb1586208fd028d6$var$isPosInt(size)) {
|
|
36560
36560
|
if (sizeCalculation) {
|
|
36561
36561
|
if (typeof sizeCalculation !== 'function') throw new TypeError('sizeCalculation must be a function');
|
|
36562
36562
|
size = sizeCalculation(v, k);
|
|
36563
|
-
if (!$
|
|
36563
|
+
if (!$eb1586208fd028d6$var$isPosInt(size)) throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
36564
36564
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
36565
36565
|
}
|
|
36566
36566
|
return size;
|
|
@@ -36751,7 +36751,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36751
36751
|
const ttl = this.#ttls[i];
|
|
36752
36752
|
const start = this.#starts[i];
|
|
36753
36753
|
if (ttl && start) {
|
|
36754
|
-
const remain = ttl - ($
|
|
36754
|
+
const remain = ttl - ($eb1586208fd028d6$var$perf.now() - start);
|
|
36755
36755
|
entry.ttl = remain;
|
|
36756
36756
|
entry.start = Date.now();
|
|
36757
36757
|
}
|
|
@@ -36787,7 +36787,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36787
36787
|
entry.ttl = this.#ttls[i];
|
|
36788
36788
|
// always dump the start relative to a portable timestamp
|
|
36789
36789
|
// it's ok for this to be a bit slow, it's a rare operation.
|
|
36790
|
-
const age = $
|
|
36790
|
+
const age = $eb1586208fd028d6$var$perf.now() - this.#starts[i];
|
|
36791
36791
|
entry.start = Math.floor(Date.now() - age);
|
|
36792
36792
|
}
|
|
36793
36793
|
if (this.#sizes) entry.size = this.#sizes[i];
|
|
@@ -36817,7 +36817,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
36817
36817
|
//
|
|
36818
36818
|
// it's ok for this to be a bit slow, it's a rare operation.
|
|
36819
36819
|
const age = Date.now() - entry.start;
|
|
36820
|
-
entry.start = $
|
|
36820
|
+
entry.start = $eb1586208fd028d6$var$perf.now() - age;
|
|
36821
36821
|
}
|
|
36822
36822
|
this.set(key, entry.value, entry);
|
|
36823
36823
|
}
|
|
@@ -37030,7 +37030,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
37030
37030
|
#backgroundFetch(k, index, options, context) {
|
|
37031
37031
|
const v = index === undefined ? undefined : this.#valList[index];
|
|
37032
37032
|
if (this.#isBackgroundFetch(v)) return v;
|
|
37033
|
-
const ac = new $
|
|
37033
|
+
const ac = new $eb1586208fd028d6$var$AC();
|
|
37034
37034
|
const { signal: signal } = options;
|
|
37035
37035
|
// when/if our AC signals, then stop listening to theirs.
|
|
37036
37036
|
signal?.addEventListener('abort', ()=>ac.abort(signal.reason), {
|
|
@@ -37128,7 +37128,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
37128
37128
|
#isBackgroundFetch(p) {
|
|
37129
37129
|
if (!this.#hasFetchMethod) return false;
|
|
37130
37130
|
const b = p;
|
|
37131
|
-
return !!b && b instanceof Promise && b.hasOwnProperty('__staleWhileFetching') && b.__abortController instanceof $
|
|
37131
|
+
return !!b && b instanceof Promise && b.hasOwnProperty('__staleWhileFetching') && b.__abortController instanceof $eb1586208fd028d6$var$AC;
|
|
37132
37132
|
}
|
|
37133
37133
|
async fetch(k, fetchOptions = {}) {
|
|
37134
37134
|
const { allowStale: // get options
|
|
@@ -37365,7 +37365,7 @@ class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
|
37365
37365
|
}
|
|
37366
37366
|
|
|
37367
37367
|
|
|
37368
|
-
const $37dda638e06feff5$var$configCache = new (0, $
|
|
37368
|
+
const $37dda638e06feff5$var$configCache = new (0, $eb1586208fd028d6$export$182500e6725aad9a)({
|
|
37369
37369
|
max: 500
|
|
37370
37370
|
});
|
|
37371
37371
|
const $37dda638e06feff5$var$resolveCache = new Map();
|