radashi 12.2.1 → 12.2.3
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/radashi.cjs +30 -32
- package/dist/radashi.d.cts +46 -24
- package/dist/radashi.d.ts +46 -24
- package/dist/radashi.js +30 -32
- package/package.json +2 -1
package/dist/radashi.cjs
CHANGED
|
@@ -358,43 +358,41 @@ function zipToObject(keys2, values) {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// src/async/AggregateError.ts
|
|
361
|
-
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() =>
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
371
|
-
this.errors = errors;
|
|
372
|
-
}
|
|
361
|
+
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError ?? class AggregateError extends Error {
|
|
362
|
+
constructor(errors = []) {
|
|
363
|
+
var _a, _b;
|
|
364
|
+
super();
|
|
365
|
+
const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
|
|
366
|
+
this.name = `AggregateError(${name}...)`;
|
|
367
|
+
this.message = `AggregateError with ${errors.length} errors`;
|
|
368
|
+
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
369
|
+
this.errors = errors;
|
|
373
370
|
}
|
|
374
|
-
)
|
|
371
|
+
})();
|
|
375
372
|
|
|
376
373
|
// src/async/all.ts
|
|
377
|
-
async function all(
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
)
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
374
|
+
async function all(input) {
|
|
375
|
+
const errors = [];
|
|
376
|
+
const onError = (err) => {
|
|
377
|
+
errors.push(err);
|
|
378
|
+
};
|
|
379
|
+
let output;
|
|
380
|
+
if (isArray(input)) {
|
|
381
|
+
output = await Promise.all(
|
|
382
|
+
input.map((value) => Promise.resolve(value).catch(onError))
|
|
383
|
+
);
|
|
384
|
+
} else {
|
|
385
|
+
output = { ...input };
|
|
386
|
+
await Promise.all(
|
|
387
|
+
Object.keys(output).map(async (key) => {
|
|
388
|
+
output[key] = await Promise.resolve(output[key]).catch(onError);
|
|
389
|
+
})
|
|
390
|
+
);
|
|
387
391
|
}
|
|
388
|
-
if (
|
|
389
|
-
|
|
392
|
+
if (errors.length > 0) {
|
|
393
|
+
throw new AggregateErrorOrPolyfill(errors);
|
|
390
394
|
}
|
|
391
|
-
return
|
|
392
|
-
(acc, item) => {
|
|
393
|
-
acc[item.key] = item.result;
|
|
394
|
-
return acc;
|
|
395
|
-
},
|
|
396
|
-
{}
|
|
397
|
-
);
|
|
395
|
+
return output;
|
|
398
396
|
}
|
|
399
397
|
|
|
400
398
|
// src/async/defer.ts
|
package/dist/radashi.d.cts
CHANGED
|
@@ -125,8 +125,7 @@ declare function diff<T>(root: readonly T[], other: readonly T[], identity?: (it
|
|
|
125
125
|
* ```
|
|
126
126
|
* @version 12.1.0
|
|
127
127
|
*/
|
|
128
|
-
declare function first<
|
|
129
|
-
declare function first<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
128
|
+
declare function first<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [infer TFirst, ...any[]] ? TFirst : TArray[number] | TDefault;
|
|
130
129
|
|
|
131
130
|
/**
|
|
132
131
|
* Given an array of arrays, returns a single dimensional array with
|
|
@@ -220,8 +219,7 @@ declare function iterate<T>(count: number, func: (currentValue: T, iteration: nu
|
|
|
220
219
|
* ```
|
|
221
220
|
* @version 12.1.0
|
|
222
221
|
*/
|
|
223
|
-
declare function last<
|
|
224
|
-
declare function last<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
222
|
+
declare function last<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [...any[], infer TLast] ? TLast : TArray[number] | TDefault;
|
|
225
223
|
|
|
226
224
|
/**
|
|
227
225
|
* Creates a list of given start, end, value, and step parameters.
|
|
@@ -532,6 +530,14 @@ declare function zip<T1, T2>(array1: readonly T1[], array2: readonly T2[]): [T1,
|
|
|
532
530
|
*/
|
|
533
531
|
declare function zipToObject<K extends string | number | symbol, V>(keys: readonly K[], values: V | ((key: K, idx: number) => V) | readonly V[]): Record<K, V>;
|
|
534
532
|
|
|
533
|
+
interface AggregateError extends Error {
|
|
534
|
+
errors: any[];
|
|
535
|
+
}
|
|
536
|
+
interface AggregateErrorConstructor {
|
|
537
|
+
new (errors: Iterable<any>, message?: string): AggregateError;
|
|
538
|
+
(errors: Iterable<any>, message?: string): AggregateError;
|
|
539
|
+
readonly prototype: AggregateError;
|
|
540
|
+
}
|
|
535
541
|
/**
|
|
536
542
|
* The `AggregateError` object represents an error when several errors
|
|
537
543
|
* need to be wrapped in a single error.
|
|
@@ -545,13 +551,9 @@ declare function zipToObject<K extends string | number | symbol, V>(keys: readon
|
|
|
545
551
|
*/
|
|
546
552
|
declare const AggregateErrorOrPolyfill: AggregateErrorConstructor;
|
|
547
553
|
|
|
548
|
-
type PromiseValues<T extends Promise<any>[]> = {
|
|
549
|
-
[K in keyof T]: T[K] extends Promise<infer U> ? U : never;
|
|
550
|
-
};
|
|
551
554
|
/**
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
* `AggregateError`.
|
|
555
|
+
* Wait for all promises to resolve. Errors from rejected promises are
|
|
556
|
+
* collected into an `AggregateError`.
|
|
555
557
|
*
|
|
556
558
|
* @see https://radashi.js.org/reference/async/all
|
|
557
559
|
* @example
|
|
@@ -564,12 +566,20 @@ type PromiseValues<T extends Promise<any>[]> = {
|
|
|
564
566
|
* ```
|
|
565
567
|
* @version 12.1.0
|
|
566
568
|
*/
|
|
567
|
-
declare function all<T extends [
|
|
568
|
-
|
|
569
|
+
declare function all<T extends readonly [unknown, ...unknown[]]>(input: T): Promise<{
|
|
570
|
+
-readonly [I in keyof T]: Awaited<T[I]>;
|
|
571
|
+
}>;
|
|
572
|
+
declare function all<T extends readonly unknown[]>(input: T): Promise<{
|
|
573
|
+
-readonly [I in keyof T]: Awaited<T[I]>;
|
|
574
|
+
}>;
|
|
569
575
|
/**
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* `AggregateError`.
|
|
576
|
+
* Check each property in the given object for a promise value. Wait
|
|
577
|
+
* for all promises to resolve. Errors from rejected promises are
|
|
578
|
+
* collected into an `AggregateError`.
|
|
579
|
+
*
|
|
580
|
+
* The returned promise will resolve with an object whose keys are
|
|
581
|
+
* identical to the keys of the input object. The values are the
|
|
582
|
+
* resolved values of the promises.
|
|
573
583
|
*
|
|
574
584
|
* @see https://radashi.js.org/reference/async/all
|
|
575
585
|
* @example
|
|
@@ -581,8 +591,8 @@ declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValu
|
|
|
581
591
|
* })
|
|
582
592
|
* ```
|
|
583
593
|
*/
|
|
584
|
-
declare function all<T extends Record<string,
|
|
585
|
-
[K in keyof T]: Awaited<T[K]>;
|
|
594
|
+
declare function all<T extends Record<string, unknown>>(input: T): Promise<{
|
|
595
|
+
-readonly [K in keyof T]: Awaited<T[K]>;
|
|
586
596
|
}>;
|
|
587
597
|
|
|
588
598
|
/**
|
|
@@ -1978,7 +1988,7 @@ declare function upperize<T extends Record<string, any>>(obj: T): UppercaseKeys<
|
|
|
1978
1988
|
* ```
|
|
1979
1989
|
* @version 12.1.0
|
|
1980
1990
|
*/
|
|
1981
|
-
declare function draw<T>(array: readonly T[]
|
|
1991
|
+
declare function draw<const T extends readonly any[]>(array: T): T extends readonly [any, ...any[]] ? T[number] : T[number] | null;
|
|
1982
1992
|
|
|
1983
1993
|
/**
|
|
1984
1994
|
* Generates a random integer between min and max. Both min and max
|
|
@@ -2238,15 +2248,14 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2238
2248
|
|
|
2239
2249
|
/**
|
|
2240
2250
|
* Return true if the given value is empty.
|
|
2251
|
+
* This function also uses [Type Guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards) to ensure type safety
|
|
2241
2252
|
*
|
|
2242
2253
|
* Empty values include:
|
|
2243
2254
|
* - `null`
|
|
2244
2255
|
* - `undefined`
|
|
2245
2256
|
* - `0`
|
|
2246
|
-
* -
|
|
2247
|
-
* -
|
|
2248
|
-
* - `[]`
|
|
2249
|
-
* - `{}`
|
|
2257
|
+
* - empty string
|
|
2258
|
+
* - empty array
|
|
2250
2259
|
* - invalid `Date` time
|
|
2251
2260
|
* - object with `length` property of `0`
|
|
2252
2261
|
* - object with `size` property of `0`
|
|
@@ -2263,7 +2272,20 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2263
2272
|
* ```
|
|
2264
2273
|
* @version 12.1.0
|
|
2265
2274
|
*/
|
|
2266
|
-
declare function isEmpty(value:
|
|
2275
|
+
declare function isEmpty<T extends ToEmptyAble>(value: T): value is ToEmpty<T>;
|
|
2276
|
+
declare function isEmpty(value: unknown): boolean;
|
|
2277
|
+
type NeverEmpty = symbol | Function;
|
|
2278
|
+
/**
|
|
2279
|
+
* A type that can be narrowed by `isEmpty`.
|
|
2280
|
+
*/
|
|
2281
|
+
type ToEmptyAble = NeverEmpty | boolean | number | string | readonly any[] | null | undefined;
|
|
2282
|
+
/**
|
|
2283
|
+
* Narrow a type to an empty value.
|
|
2284
|
+
*
|
|
2285
|
+
* Due to TypeScript limitations, object types cannot be narrowed,
|
|
2286
|
+
* except for arrays and functions.
|
|
2287
|
+
*/
|
|
2288
|
+
type ToEmpty<T extends ToEmptyAble> = (T extends any[] ? never[] : Extract<false | 0 | '' | readonly never[] | null | undefined, T>) extends infer U ? Extract<U, T> : never;
|
|
2267
2289
|
|
|
2268
2290
|
/**
|
|
2269
2291
|
* Return true if the given values are equal.
|
|
@@ -3361,4 +3383,4 @@ type GlobalObjectType<Identifier extends string> = [Identifier] extends [Any] ?
|
|
|
3361
3383
|
[P in Identifier]: any;
|
|
3362
3384
|
} ? InstanceType<(typeof globalThis)[Identifier]> : never;
|
|
3363
3385
|
|
|
3364
|
-
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
|
3386
|
+
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type PromiseWithResolvers, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
package/dist/radashi.d.ts
CHANGED
|
@@ -125,8 +125,7 @@ declare function diff<T>(root: readonly T[], other: readonly T[], identity?: (it
|
|
|
125
125
|
* ```
|
|
126
126
|
* @version 12.1.0
|
|
127
127
|
*/
|
|
128
|
-
declare function first<
|
|
129
|
-
declare function first<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
128
|
+
declare function first<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [infer TFirst, ...any[]] ? TFirst : TArray[number] | TDefault;
|
|
130
129
|
|
|
131
130
|
/**
|
|
132
131
|
* Given an array of arrays, returns a single dimensional array with
|
|
@@ -220,8 +219,7 @@ declare function iterate<T>(count: number, func: (currentValue: T, iteration: nu
|
|
|
220
219
|
* ```
|
|
221
220
|
* @version 12.1.0
|
|
222
221
|
*/
|
|
223
|
-
declare function last<
|
|
224
|
-
declare function last<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
222
|
+
declare function last<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [...any[], infer TLast] ? TLast : TArray[number] | TDefault;
|
|
225
223
|
|
|
226
224
|
/**
|
|
227
225
|
* Creates a list of given start, end, value, and step parameters.
|
|
@@ -532,6 +530,14 @@ declare function zip<T1, T2>(array1: readonly T1[], array2: readonly T2[]): [T1,
|
|
|
532
530
|
*/
|
|
533
531
|
declare function zipToObject<K extends string | number | symbol, V>(keys: readonly K[], values: V | ((key: K, idx: number) => V) | readonly V[]): Record<K, V>;
|
|
534
532
|
|
|
533
|
+
interface AggregateError extends Error {
|
|
534
|
+
errors: any[];
|
|
535
|
+
}
|
|
536
|
+
interface AggregateErrorConstructor {
|
|
537
|
+
new (errors: Iterable<any>, message?: string): AggregateError;
|
|
538
|
+
(errors: Iterable<any>, message?: string): AggregateError;
|
|
539
|
+
readonly prototype: AggregateError;
|
|
540
|
+
}
|
|
535
541
|
/**
|
|
536
542
|
* The `AggregateError` object represents an error when several errors
|
|
537
543
|
* need to be wrapped in a single error.
|
|
@@ -545,13 +551,9 @@ declare function zipToObject<K extends string | number | symbol, V>(keys: readon
|
|
|
545
551
|
*/
|
|
546
552
|
declare const AggregateErrorOrPolyfill: AggregateErrorConstructor;
|
|
547
553
|
|
|
548
|
-
type PromiseValues<T extends Promise<any>[]> = {
|
|
549
|
-
[K in keyof T]: T[K] extends Promise<infer U> ? U : never;
|
|
550
|
-
};
|
|
551
554
|
/**
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
* `AggregateError`.
|
|
555
|
+
* Wait for all promises to resolve. Errors from rejected promises are
|
|
556
|
+
* collected into an `AggregateError`.
|
|
555
557
|
*
|
|
556
558
|
* @see https://radashi.js.org/reference/async/all
|
|
557
559
|
* @example
|
|
@@ -564,12 +566,20 @@ type PromiseValues<T extends Promise<any>[]> = {
|
|
|
564
566
|
* ```
|
|
565
567
|
* @version 12.1.0
|
|
566
568
|
*/
|
|
567
|
-
declare function all<T extends [
|
|
568
|
-
|
|
569
|
+
declare function all<T extends readonly [unknown, ...unknown[]]>(input: T): Promise<{
|
|
570
|
+
-readonly [I in keyof T]: Awaited<T[I]>;
|
|
571
|
+
}>;
|
|
572
|
+
declare function all<T extends readonly unknown[]>(input: T): Promise<{
|
|
573
|
+
-readonly [I in keyof T]: Awaited<T[I]>;
|
|
574
|
+
}>;
|
|
569
575
|
/**
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* `AggregateError`.
|
|
576
|
+
* Check each property in the given object for a promise value. Wait
|
|
577
|
+
* for all promises to resolve. Errors from rejected promises are
|
|
578
|
+
* collected into an `AggregateError`.
|
|
579
|
+
*
|
|
580
|
+
* The returned promise will resolve with an object whose keys are
|
|
581
|
+
* identical to the keys of the input object. The values are the
|
|
582
|
+
* resolved values of the promises.
|
|
573
583
|
*
|
|
574
584
|
* @see https://radashi.js.org/reference/async/all
|
|
575
585
|
* @example
|
|
@@ -581,8 +591,8 @@ declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValu
|
|
|
581
591
|
* })
|
|
582
592
|
* ```
|
|
583
593
|
*/
|
|
584
|
-
declare function all<T extends Record<string,
|
|
585
|
-
[K in keyof T]: Awaited<T[K]>;
|
|
594
|
+
declare function all<T extends Record<string, unknown>>(input: T): Promise<{
|
|
595
|
+
-readonly [K in keyof T]: Awaited<T[K]>;
|
|
586
596
|
}>;
|
|
587
597
|
|
|
588
598
|
/**
|
|
@@ -1978,7 +1988,7 @@ declare function upperize<T extends Record<string, any>>(obj: T): UppercaseKeys<
|
|
|
1978
1988
|
* ```
|
|
1979
1989
|
* @version 12.1.0
|
|
1980
1990
|
*/
|
|
1981
|
-
declare function draw<T>(array: readonly T[]
|
|
1991
|
+
declare function draw<const T extends readonly any[]>(array: T): T extends readonly [any, ...any[]] ? T[number] : T[number] | null;
|
|
1982
1992
|
|
|
1983
1993
|
/**
|
|
1984
1994
|
* Generates a random integer between min and max. Both min and max
|
|
@@ -2238,15 +2248,14 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2238
2248
|
|
|
2239
2249
|
/**
|
|
2240
2250
|
* Return true if the given value is empty.
|
|
2251
|
+
* This function also uses [Type Guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards) to ensure type safety
|
|
2241
2252
|
*
|
|
2242
2253
|
* Empty values include:
|
|
2243
2254
|
* - `null`
|
|
2244
2255
|
* - `undefined`
|
|
2245
2256
|
* - `0`
|
|
2246
|
-
* -
|
|
2247
|
-
* -
|
|
2248
|
-
* - `[]`
|
|
2249
|
-
* - `{}`
|
|
2257
|
+
* - empty string
|
|
2258
|
+
* - empty array
|
|
2250
2259
|
* - invalid `Date` time
|
|
2251
2260
|
* - object with `length` property of `0`
|
|
2252
2261
|
* - object with `size` property of `0`
|
|
@@ -2263,7 +2272,20 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2263
2272
|
* ```
|
|
2264
2273
|
* @version 12.1.0
|
|
2265
2274
|
*/
|
|
2266
|
-
declare function isEmpty(value:
|
|
2275
|
+
declare function isEmpty<T extends ToEmptyAble>(value: T): value is ToEmpty<T>;
|
|
2276
|
+
declare function isEmpty(value: unknown): boolean;
|
|
2277
|
+
type NeverEmpty = symbol | Function;
|
|
2278
|
+
/**
|
|
2279
|
+
* A type that can be narrowed by `isEmpty`.
|
|
2280
|
+
*/
|
|
2281
|
+
type ToEmptyAble = NeverEmpty | boolean | number | string | readonly any[] | null | undefined;
|
|
2282
|
+
/**
|
|
2283
|
+
* Narrow a type to an empty value.
|
|
2284
|
+
*
|
|
2285
|
+
* Due to TypeScript limitations, object types cannot be narrowed,
|
|
2286
|
+
* except for arrays and functions.
|
|
2287
|
+
*/
|
|
2288
|
+
type ToEmpty<T extends ToEmptyAble> = (T extends any[] ? never[] : Extract<false | 0 | '' | readonly never[] | null | undefined, T>) extends infer U ? Extract<U, T> : never;
|
|
2267
2289
|
|
|
2268
2290
|
/**
|
|
2269
2291
|
* Return true if the given values are equal.
|
|
@@ -3361,4 +3383,4 @@ type GlobalObjectType<Identifier extends string> = [Identifier] extends [Any] ?
|
|
|
3361
3383
|
[P in Identifier]: any;
|
|
3362
3384
|
} ? InstanceType<(typeof globalThis)[Identifier]> : never;
|
|
3363
3385
|
|
|
3364
|
-
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
|
3386
|
+
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type PromiseWithResolvers, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
package/dist/radashi.js
CHANGED
|
@@ -356,43 +356,41 @@ function zipToObject(keys2, values) {
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
// src/async/AggregateError.ts
|
|
359
|
-
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() =>
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
369
|
-
this.errors = errors;
|
|
370
|
-
}
|
|
359
|
+
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError ?? class AggregateError extends Error {
|
|
360
|
+
constructor(errors = []) {
|
|
361
|
+
var _a, _b;
|
|
362
|
+
super();
|
|
363
|
+
const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
|
|
364
|
+
this.name = `AggregateError(${name}...)`;
|
|
365
|
+
this.message = `AggregateError with ${errors.length} errors`;
|
|
366
|
+
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
367
|
+
this.errors = errors;
|
|
371
368
|
}
|
|
372
|
-
)
|
|
369
|
+
})();
|
|
373
370
|
|
|
374
371
|
// src/async/all.ts
|
|
375
|
-
async function all(
|
|
376
|
-
const
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
372
|
+
async function all(input) {
|
|
373
|
+
const errors = [];
|
|
374
|
+
const onError = (err) => {
|
|
375
|
+
errors.push(err);
|
|
376
|
+
};
|
|
377
|
+
let output;
|
|
378
|
+
if (isArray(input)) {
|
|
379
|
+
output = await Promise.all(
|
|
380
|
+
input.map((value) => Promise.resolve(value).catch(onError))
|
|
381
|
+
);
|
|
382
|
+
} else {
|
|
383
|
+
output = { ...input };
|
|
384
|
+
await Promise.all(
|
|
385
|
+
Object.keys(output).map(async (key) => {
|
|
386
|
+
output[key] = await Promise.resolve(output[key]).catch(onError);
|
|
387
|
+
})
|
|
388
|
+
);
|
|
385
389
|
}
|
|
386
|
-
if (
|
|
387
|
-
|
|
390
|
+
if (errors.length > 0) {
|
|
391
|
+
throw new AggregateErrorOrPolyfill(errors);
|
|
388
392
|
}
|
|
389
|
-
return
|
|
390
|
-
(acc, item) => {
|
|
391
|
-
acc[item.key] = item.result;
|
|
392
|
-
return acc;
|
|
393
|
-
},
|
|
394
|
-
{}
|
|
395
|
-
);
|
|
393
|
+
return output;
|
|
396
394
|
}
|
|
397
395
|
|
|
398
396
|
// src/async/defer.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "radashi",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The modern, community-first TypeScript toolkit with all of the fast, readable, and minimal utility functions you need. Type-safe, dependency-free, tree-shakeable, fully tested.",
|
|
6
6
|
"repository": {
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@types/node": "^22.7.5",
|
|
51
51
|
"@vitest/coverage-v8": "2.0.5",
|
|
52
52
|
"cspell": "^8.13.3",
|
|
53
|
+
"execa": "^9.5.1",
|
|
53
54
|
"prettier": "^3.3.2",
|
|
54
55
|
"prettier-plugin-pkg": "^0.18.1",
|
|
55
56
|
"prettier-plugin-sh": "^0.14.0",
|