Update dist folder

This commit is contained in:
Riccardo Rigutini 2024-08-16 19:48:44 +00:00 committed by GitHub
parent 7e2c8987e4
commit 838b6794c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 148 additions and 45 deletions

191
dist/index.js generated vendored
View File

@ -3656,7 +3656,12 @@ exports.Ignore = Ignore;
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.glob = exports.sync = exports.iterate = exports.iterateSync = exports.stream = exports.streamSync = exports.globIterate = exports.globIterateSync = exports.globSync = exports.globStream = exports.globStreamSync = exports.Ignore = exports.hasMagic = exports.Glob = exports.unescape = exports.escape = void 0; exports.glob = exports.sync = exports.iterate = exports.iterateSync = exports.stream = exports.streamSync = exports.Ignore = exports.hasMagic = exports.Glob = exports.unescape = exports.escape = void 0;
exports.globStreamSync = globStreamSync;
exports.globStream = globStream;
exports.globSync = globSync;
exports.globIterateSync = globIterateSync;
exports.globIterate = globIterate;
const minimatch_1 = __nccwpck_require__(658); const minimatch_1 = __nccwpck_require__(658);
const glob_js_1 = __nccwpck_require__(2487); const glob_js_1 = __nccwpck_require__(2487);
const has_magic_js_1 = __nccwpck_require__(3133); const has_magic_js_1 = __nccwpck_require__(3133);
@ -3672,26 +3677,21 @@ Object.defineProperty(exports, "Ignore", ({ enumerable: true, get: function () {
function globStreamSync(pattern, options = {}) { function globStreamSync(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).streamSync(); return new glob_js_1.Glob(pattern, options).streamSync();
} }
exports.globStreamSync = globStreamSync;
function globStream(pattern, options = {}) { function globStream(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).stream(); return new glob_js_1.Glob(pattern, options).stream();
} }
exports.globStream = globStream;
function globSync(pattern, options = {}) { function globSync(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).walkSync(); return new glob_js_1.Glob(pattern, options).walkSync();
} }
exports.globSync = globSync;
async function glob_(pattern, options = {}) { async function glob_(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).walk(); return new glob_js_1.Glob(pattern, options).walk();
} }
function globIterateSync(pattern, options = {}) { function globIterateSync(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).iterateSync(); return new glob_js_1.Glob(pattern, options).iterateSync();
} }
exports.globIterateSync = globIterateSync;
function globIterate(pattern, options = {}) { function globIterate(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).iterate(); return new glob_js_1.Glob(pattern, options).iterate();
} }
exports.globIterate = globIterate;
// aliases: glob.sync.stream() glob.stream.sync() glob.sync() etc // aliases: glob.sync.stream() glob.stream.sync() glob.sync() etc
exports.streamSync = globStreamSync; exports.streamSync = globStreamSync;
exports.stream = Object.assign(globStream, { sync: globStreamSync }); exports.stream = Object.assign(globStream, { sync: globStreamSync });
@ -5998,10 +5998,11 @@ class Minimatch {
for (let i = 0; i < globParts.length - 1; i++) { for (let i = 0; i < globParts.length - 1; i++) {
for (let j = i + 1; j < globParts.length; j++) { for (let j = i + 1; j < globParts.length; j++) {
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes); const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
if (!matched) if (matched) {
continue; globParts[i] = [];
globParts[i] = matched; globParts[j] = matched;
globParts[j] = []; break;
}
} }
} }
return globParts.filter(gs => gs.length); return globParts.filter(gs => gs.length);
@ -7858,6 +7859,8 @@ class PathBase {
/** /**
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively, * Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
* this property refers to the *parent* path, not the path object itself. * this property refers to the *parent* path, not the path object itself.
*
* @deprecated
*/ */
get path() { get path() {
return this.parentPath; return this.parentPath;
@ -9707,21 +9710,26 @@ class Stack {
/** /**
* Default export, the thing you're using this module to get. * Default export, the thing you're using this module to get.
* *
* All properties from the options object (with the exception of * The `K` and `V` types define the key and value types, respectively. The
* {@link OptionsBase.max} and {@link OptionsBase.maxSize}) are added as * optional `FC` type defines the type of the `context` object passed to
* normal public members. (`max` and `maxBase` are read-only getters.) * `cache.fetch()` and `cache.memo()`.
* Changing any of these will alter the defaults for subsequent method calls, *
* but is otherwise safe. * Keys and values **must not** be `null` or `undefined`.
*
* All properties from the options object (with the exception of `max`,
* `maxSize`, `fetchMethod`, `memoMethod`, `dispose` and `disposeAfter`) are
* added as normal public members. (The listed options are read-only getters.)
*
* Changing any of these will alter the defaults for subsequent method calls.
*/ */
class LRUCache { class LRUCache {
// properties coming in from the options of these, only max and maxSize // options that cannot be changed without disaster
// really *need* to be protected. The rest can be modified, as they just
// set defaults for various methods.
#max; #max;
#maxSize; #maxSize;
#dispose; #dispose;
#disposeAfter; #disposeAfter;
#fetchMethod; #fetchMethod;
#memoMethod;
/** /**
* {@link LRUCache.OptionsBase.ttl} * {@link LRUCache.OptionsBase.ttl}
*/ */
@ -9867,6 +9875,9 @@ class LRUCache {
get fetchMethod() { get fetchMethod() {
return this.#fetchMethod; return this.#fetchMethod;
} }
get memoMethod() {
return this.#memoMethod;
}
/** /**
* {@link LRUCache.OptionsBase.dispose} (read-only) * {@link LRUCache.OptionsBase.dispose} (read-only)
*/ */
@ -9880,7 +9891,7 @@ class LRUCache {
return this.#disposeAfter; return this.#disposeAfter;
} }
constructor(options) { constructor(options) {
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options; const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options;
if (max !== 0 && !isPosInt(max)) { if (max !== 0 && !isPosInt(max)) {
throw new TypeError('max option must be a nonnegative integer'); throw new TypeError('max option must be a nonnegative integer');
} }
@ -9900,6 +9911,11 @@ class LRUCache {
throw new TypeError('sizeCalculation set to non-function'); throw new TypeError('sizeCalculation set to non-function');
} }
} }
if (memoMethod !== undefined &&
typeof memoMethod !== 'function') {
throw new TypeError('memoMethod must be a function if defined');
}
this.#memoMethod = memoMethod;
if (fetchMethod !== undefined && if (fetchMethod !== undefined &&
typeof fetchMethod !== 'function') { typeof fetchMethod !== 'function') {
throw new TypeError('fetchMethod must be a function if specified'); throw new TypeError('fetchMethod must be a function if specified');
@ -9978,7 +9994,8 @@ class LRUCache {
} }
} }
/** /**
* Return the remaining TTL time for a given entry key * Return the number of ms left in the item's TTL. If item is not in cache,
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
*/ */
getRemainingTTL(key) { getRemainingTTL(key) {
return this.#keyMap.has(key) ? Infinity : 0; return this.#keyMap.has(key) ? Infinity : 0;
@ -9994,7 +10011,7 @@ class LRUCache {
if (ttl !== 0 && this.ttlAutopurge) { if (ttl !== 0 && this.ttlAutopurge) {
const t = setTimeout(() => { const t = setTimeout(() => {
if (this.#isStale(index)) { if (this.#isStale(index)) {
this.delete(this.#keyList[index]); this.#delete(this.#keyList[index], 'expire');
} }
}, ttl + 1); }, ttl + 1);
// unref() not supported on all platforms // unref() not supported on all platforms
@ -10251,13 +10268,14 @@ class LRUCache {
return this.entries(); return this.entries();
} }
/** /**
* A String value that is used in the creation of the default string description of an object. * A String value that is used in the creation of the default string
* Called by the built-in method Object.prototype.toString. * description of an object. Called by the built-in method
* `Object.prototype.toString`.
*/ */
[Symbol.toStringTag] = 'LRUCache'; [Symbol.toStringTag] = 'LRUCache';
/** /**
* Find a value for which the supplied fn method returns a truthy value, * Find a value for which the supplied fn method returns a truthy value,
* similar to Array.find(). fn is called as fn(value, key, cache). * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
*/ */
find(fn, getOptions = {}) { find(fn, getOptions = {}) {
for (const i of this.#indexes()) { for (const i of this.#indexes()) {
@ -10273,10 +10291,15 @@ class LRUCache {
} }
} }
/** /**
* Call the supplied function on each item in the cache, in order from * Call the supplied function on each item in the cache, in order from most
* most recently used to least recently used. fn is called as * recently used to least recently used.
* fn(value, key, cache). Does not update age or recenty of use. *
* Does not iterate over stale values. * `fn` is called as `fn(value, key, cache)`.
*
* If `thisp` is provided, function will be called in the `this`-context of
* the provided object, or the cache if no `thisp` object is provided.
*
* Does not update age or recenty of use, or iterate over stale values.
*/ */
forEach(fn, thisp = this) { forEach(fn, thisp = this) {
for (const i of this.#indexes()) { for (const i of this.#indexes()) {
@ -10312,7 +10335,7 @@ class LRUCache {
let deleted = false; let deleted = false;
for (const i of this.#rindexes({ allowStale: true })) { for (const i of this.#rindexes({ allowStale: true })) {
if (this.#isStale(i)) { if (this.#isStale(i)) {
this.delete(this.#keyList[i]); this.#delete(this.#keyList[i], 'expire');
deleted = true; deleted = true;
} }
} }
@ -10320,9 +10343,15 @@ class LRUCache {
} }
/** /**
* Get the extended info about a given entry, to get its value, size, and * Get the extended info about a given entry, to get its value, size, and
* TTL info simultaneously. Like {@link LRUCache#dump}, but just for a * TTL info simultaneously. Returns `undefined` if the key is not present.
* single key. Always returns stale values, if their info is found in the *
* cache, so be sure to check for expired TTLs if relevant. * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
* serialization, the `start` value is always the current timestamp, and the
* `ttl` is a calculated remaining time to live (negative if expired).
*
* Always returns stale values, if their info is found in the cache, so be
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
* if relevant.
*/ */
info(key) { info(key) {
const i = this.#keyMap.get(key); const i = this.#keyMap.get(key);
@ -10351,7 +10380,16 @@ class LRUCache {
} }
/** /**
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
* passed to cache.load() * passed to {@link LRLUCache#load}.
*
* The `start` fields are calculated relative to a portable `Date.now()`
* timestamp, even if `performance.now()` is available.
*
* Stale entries are always included in the `dump`, even if
* {@link LRUCache.OptionsBase.allowStale} is false.
*
* Note: this returns an actual array, not a generator, so it can be more
* easily passed around.
*/ */
dump() { dump() {
const arr = []; const arr = [];
@ -10380,8 +10418,12 @@ class LRUCache {
} }
/** /**
* Reset the cache and load in the items in entries in the order listed. * Reset the cache and load in the items in entries in the order listed.
* Note that the shape of the resulting cache may be different if the *
* same options are not used in both caches. * The shape of the resulting cache may be different if the same options are
* not used in both caches.
*
* The `start` fields are assumed to be calculated relative to a portable
* `Date.now()` timestamp, even if `performance.now()` is available.
*/ */
load(arr) { load(arr) {
this.clear(); this.clear();
@ -10404,6 +10446,30 @@ class LRUCache {
* *
* Note: if `undefined` is specified as a value, this is an alias for * Note: if `undefined` is specified as a value, this is an alias for
* {@link LRUCache#delete} * {@link LRUCache#delete}
*
* Fields on the {@link LRUCache.SetOptions} options param will override
* their corresponding values in the constructor options for the scope
* of this single `set()` operation.
*
* If `start` is provided, then that will set the effective start
* time for the TTL calculation. Note that this must be a previous
* value of `performance.now()` if supported, or a previous value of
* `Date.now()` if not.
*
* Options object may also include `size`, which will prevent
* calling the `sizeCalculation` function and just use the specified
* number if it is a positive integer, and `noDisposeOnSet` which
* will prevent calling a `dispose` function in the case of
* overwrites.
*
* If the `size` (or return value of `sizeCalculation`) for a given
* entry is greater than `maxEntrySize`, then the item will not be
* added to the cache.
*
* Will update the recency of the entry.
*
* If the value is `undefined`, then this is an alias for
* `cache.delete(key)`. `undefined` is never stored in the cache.
*/ */
set(k, v, setOptions = {}) { set(k, v, setOptions = {}) {
if (v === undefined) { if (v === undefined) {
@ -10421,7 +10487,7 @@ class LRUCache {
status.maxEntrySizeExceeded = true; status.maxEntrySizeExceeded = true;
} }
// have to delete, in case something is there already. // have to delete, in case something is there already.
this.delete(k); this.#delete(k, 'set');
return this; return this;
} }
let index = this.#size === 0 ? undefined : this.#keyMap.get(k); let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
@ -10573,6 +10639,14 @@ class LRUCache {
* Will return false if the item is stale, even though it is technically * Will return false if the item is stale, even though it is technically
* in the cache. * in the cache.
* *
* Check if a key is in the cache, without updating the recency of
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
* to `true` in either the options or the constructor.
*
* Will return `false` if the item is stale, even though it is technically in
* the cache. The difference can be determined (if it matters) by using a
* `status` argument, and inspecting the `has` field.
*
* Will not update item age unless * Will not update item age unless
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set. * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
*/ */
@ -10664,7 +10738,7 @@ class LRUCache {
this.#valList[index] = bf.__staleWhileFetching; this.#valList[index] = bf.__staleWhileFetching;
} }
else { else {
this.delete(k); this.#delete(k, 'fetch');
} }
} }
else { else {
@ -10693,7 +10767,7 @@ class LRUCache {
// the stale value is not removed from the cache when the fetch fails. // the stale value is not removed from the cache when the fetch fails.
const del = !noDelete || bf.__staleWhileFetching === undefined; const del = !noDelete || bf.__staleWhileFetching === undefined;
if (del) { if (del) {
this.delete(k); this.#delete(k, 'fetch');
} }
else if (!allowStaleAborted) { else if (!allowStaleAborted) {
// still replace the *promise* with the stale value, // still replace the *promise* with the stale value,
@ -10839,6 +10913,28 @@ class LRUCache {
return staleVal ? p.__staleWhileFetching : (p.__returned = p); return staleVal ? p.__staleWhileFetching : (p.__returned = p);
} }
} }
async forceFetch(k, fetchOptions = {}) {
const v = await this.fetch(k, fetchOptions);
if (v === undefined)
throw new Error('fetch() returned undefined');
return v;
}
memo(k, memoOptions = {}) {
const memoMethod = this.#memoMethod;
if (!memoMethod) {
throw new Error('no memoMethod provided to constructor');
}
const { context, forceRefresh, ...options } = memoOptions;
const v = this.get(k, options);
if (!forceRefresh && v !== undefined)
return v;
const vv = memoMethod(k, v, {
options,
context,
});
this.set(k, vv, options);
return vv;
}
/** /**
* Return a value from the cache. Will update the recency of the cache * Return a value from the cache. Will update the recency of the cache
* entry found. * entry found.
@ -10859,7 +10955,7 @@ class LRUCache {
// delete only if not an in-flight background fetch // delete only if not an in-flight background fetch
if (!fetching) { if (!fetching) {
if (!noDeleteOnStaleGet) { if (!noDeleteOnStaleGet) {
this.delete(k); this.#delete(k, 'expire');
} }
if (status && allowStale) if (status && allowStale)
status.returnedStale = true; status.returnedStale = true;
@ -10922,16 +11018,20 @@ class LRUCache {
} }
/** /**
* Deletes a key out of the cache. * Deletes a key out of the cache.
*
* Returns true if the key was deleted, false otherwise. * Returns true if the key was deleted, false otherwise.
*/ */
delete(k) { delete(k) {
return this.#delete(k, 'delete');
}
#delete(k, reason) {
let deleted = false; let deleted = false;
if (this.#size !== 0) { if (this.#size !== 0) {
const index = this.#keyMap.get(k); const index = this.#keyMap.get(k);
if (index !== undefined) { if (index !== undefined) {
deleted = true; deleted = true;
if (this.#size === 1) { if (this.#size === 1) {
this.clear(); this.#clear(reason);
} }
else { else {
this.#removeItemSize(index); this.#removeItemSize(index);
@ -10941,10 +11041,10 @@ class LRUCache {
} }
else if (this.#hasDispose || this.#hasDisposeAfter) { else if (this.#hasDispose || this.#hasDisposeAfter) {
if (this.#hasDispose) { if (this.#hasDispose) {
this.#dispose?.(v, k, 'delete'); this.#dispose?.(v, k, reason);
} }
if (this.#hasDisposeAfter) { if (this.#hasDisposeAfter) {
this.#disposed?.push([v, k, 'delete']); this.#disposed?.push([v, k, reason]);
} }
} }
this.#keyMap.delete(k); this.#keyMap.delete(k);
@ -10980,6 +11080,9 @@ class LRUCache {
* Clear the cache entirely, throwing away all values. * Clear the cache entirely, throwing away all values.
*/ */
clear() { clear() {
return this.#clear('delete');
}
#clear(reason) {
for (const index of this.#rindexes({ allowStale: true })) { for (const index of this.#rindexes({ allowStale: true })) {
const v = this.#valList[index]; const v = this.#valList[index];
if (this.#isBackgroundFetch(v)) { if (this.#isBackgroundFetch(v)) {
@ -10988,10 +11091,10 @@ class LRUCache {
else { else {
const k = this.#keyList[index]; const k = this.#keyList[index];
if (this.#hasDispose) { if (this.#hasDispose) {
this.#dispose?.(v, k, 'delete'); this.#dispose?.(v, k, reason);
} }
if (this.#hasDisposeAfter) { if (this.#hasDisposeAfter) {
this.#disposed?.push([v, k, 'delete']); this.#disposed?.push([v, k, reason]);
} }
} }
} }

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long