@jsnw/common-utils 1.1.0 → 1.2.0
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/dist/index.cjs +12 -0
- package/dist/index.d.cts +4 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +12 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -204,11 +204,23 @@ const trySettlePromises = async (promises, onError) => {
|
|
|
204
204
|
return results;
|
|
205
205
|
};
|
|
206
206
|
//#endregion
|
|
207
|
+
//#region src/isAbortError.ts
|
|
208
|
+
const isAbortError = (e, signals) => {
|
|
209
|
+
if (!!e && typeof e === "object" && "name" in e && e.name === "AbortError") return true;
|
|
210
|
+
const filtered = (signals ?? []).filter((v) => v !== void 0 && v !== null);
|
|
211
|
+
for (const signal of filtered) {
|
|
212
|
+
if (!signal.aborted) continue;
|
|
213
|
+
if (e === signal.reason) return true;
|
|
214
|
+
}
|
|
215
|
+
return false;
|
|
216
|
+
};
|
|
217
|
+
//#endregion
|
|
207
218
|
exports.Monitor = Monitor;
|
|
208
219
|
exports.chunk = chunk;
|
|
209
220
|
exports.chunkStr = chunkStr;
|
|
210
221
|
exports.createInFlightDeduper = createInFlightDeduper;
|
|
211
222
|
exports.ignorePromise = ignorePromise;
|
|
223
|
+
exports.isAbortError = isAbortError;
|
|
212
224
|
exports.isObjectEmpty = isObjectEmpty;
|
|
213
225
|
exports.noop = noop;
|
|
214
226
|
exports.resultify = resultify;
|
package/dist/index.d.cts
CHANGED
|
@@ -130,4 +130,7 @@ type ErrorDetails = {
|
|
|
130
130
|
type ErrorCallback = (details: ErrorDetails, index: number) => void;
|
|
131
131
|
declare const trySettlePromises: <T extends (Promise<any> | DescribedPromise<any>)[]>(promises: [...T], onError?: ErrorCallback) => Promise<AwaitedTuple<T>>;
|
|
132
132
|
//#endregion
|
|
133
|
-
|
|
133
|
+
//#region src/isAbortError.d.ts
|
|
134
|
+
declare const isAbortError: (e: unknown, signals?: (AbortSignal | undefined | null)[]) => boolean;
|
|
135
|
+
//#endregion
|
|
136
|
+
export { ErrorResult, InFlightDeduper, Monitor, MonitorMark, MonitorResult, chunk, chunkStr, createInFlightDeduper, ignorePromise, isAbortError, isObjectEmpty, noop, resultify, trySettlePromises, wait };
|
package/dist/index.d.mts
CHANGED
|
@@ -130,4 +130,7 @@ type ErrorDetails = {
|
|
|
130
130
|
type ErrorCallback = (details: ErrorDetails, index: number) => void;
|
|
131
131
|
declare const trySettlePromises: <T extends (Promise<any> | DescribedPromise<any>)[]>(promises: [...T], onError?: ErrorCallback) => Promise<AwaitedTuple<T>>;
|
|
132
132
|
//#endregion
|
|
133
|
-
|
|
133
|
+
//#region src/isAbortError.d.ts
|
|
134
|
+
declare const isAbortError: (e: unknown, signals?: (AbortSignal | undefined | null)[]) => boolean;
|
|
135
|
+
//#endregion
|
|
136
|
+
export { ErrorResult, InFlightDeduper, Monitor, MonitorMark, MonitorResult, chunk, chunkStr, createInFlightDeduper, ignorePromise, isAbortError, isObjectEmpty, noop, resultify, trySettlePromises, wait };
|
package/dist/index.mjs
CHANGED
|
@@ -203,4 +203,15 @@ const trySettlePromises = async (promises, onError) => {
|
|
|
203
203
|
return results;
|
|
204
204
|
};
|
|
205
205
|
//#endregion
|
|
206
|
-
|
|
206
|
+
//#region src/isAbortError.ts
|
|
207
|
+
const isAbortError = (e, signals) => {
|
|
208
|
+
if (!!e && typeof e === "object" && "name" in e && e.name === "AbortError") return true;
|
|
209
|
+
const filtered = (signals ?? []).filter((v) => v !== void 0 && v !== null);
|
|
210
|
+
for (const signal of filtered) {
|
|
211
|
+
if (!signal.aborted) continue;
|
|
212
|
+
if (e === signal.reason) return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
};
|
|
216
|
+
//#endregion
|
|
217
|
+
export { Monitor, chunk, chunkStr, createInFlightDeduper, ignorePromise, isAbortError, isObjectEmpty, noop, resultify, trySettlePromises, wait };
|