radashi 12.2.2 → 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 +20 -19
- package/dist/radashi.d.cts +17 -13
- package/dist/radashi.d.ts +17 -13
- package/dist/radashi.js +20 -19
- package/package.json +2 -1
package/dist/radashi.cjs
CHANGED
|
@@ -371,27 +371,28 @@ var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError
|
|
|
371
371
|
})();
|
|
372
372
|
|
|
373
373
|
// src/async/all.ts
|
|
374
|
-
async function all(
|
|
375
|
-
const
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
)
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
+
);
|
|
384
391
|
}
|
|
385
|
-
if (
|
|
386
|
-
|
|
392
|
+
if (errors.length > 0) {
|
|
393
|
+
throw new AggregateErrorOrPolyfill(errors);
|
|
387
394
|
}
|
|
388
|
-
return
|
|
389
|
-
(acc, item) => {
|
|
390
|
-
acc[item.key] = item.result;
|
|
391
|
-
return acc;
|
|
392
|
-
},
|
|
393
|
-
{}
|
|
394
|
-
);
|
|
395
|
+
return output;
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
// src/async/defer.ts
|
package/dist/radashi.d.cts
CHANGED
|
@@ -551,13 +551,9 @@ interface AggregateErrorConstructor {
|
|
|
551
551
|
*/
|
|
552
552
|
declare const AggregateErrorOrPolyfill: AggregateErrorConstructor;
|
|
553
553
|
|
|
554
|
-
type PromiseValues<T extends Promise<any>[]> = {
|
|
555
|
-
[K in keyof T]: T[K] extends Promise<infer U> ? U : never;
|
|
556
|
-
};
|
|
557
554
|
/**
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
* `AggregateError`.
|
|
555
|
+
* Wait for all promises to resolve. Errors from rejected promises are
|
|
556
|
+
* collected into an `AggregateError`.
|
|
561
557
|
*
|
|
562
558
|
* @see https://radashi.js.org/reference/async/all
|
|
563
559
|
* @example
|
|
@@ -570,12 +566,20 @@ type PromiseValues<T extends Promise<any>[]> = {
|
|
|
570
566
|
* ```
|
|
571
567
|
* @version 12.1.0
|
|
572
568
|
*/
|
|
573
|
-
declare function all<T extends [
|
|
574
|
-
|
|
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
|
+
}>;
|
|
575
575
|
/**
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
* `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.
|
|
579
583
|
*
|
|
580
584
|
* @see https://radashi.js.org/reference/async/all
|
|
581
585
|
* @example
|
|
@@ -587,8 +591,8 @@ declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValu
|
|
|
587
591
|
* })
|
|
588
592
|
* ```
|
|
589
593
|
*/
|
|
590
|
-
declare function all<T extends Record<string,
|
|
591
|
-
[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]>;
|
|
592
596
|
}>;
|
|
593
597
|
|
|
594
598
|
/**
|
package/dist/radashi.d.ts
CHANGED
|
@@ -551,13 +551,9 @@ interface AggregateErrorConstructor {
|
|
|
551
551
|
*/
|
|
552
552
|
declare const AggregateErrorOrPolyfill: AggregateErrorConstructor;
|
|
553
553
|
|
|
554
|
-
type PromiseValues<T extends Promise<any>[]> = {
|
|
555
|
-
[K in keyof T]: T[K] extends Promise<infer U> ? U : never;
|
|
556
|
-
};
|
|
557
554
|
/**
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
* `AggregateError`.
|
|
555
|
+
* Wait for all promises to resolve. Errors from rejected promises are
|
|
556
|
+
* collected into an `AggregateError`.
|
|
561
557
|
*
|
|
562
558
|
* @see https://radashi.js.org/reference/async/all
|
|
563
559
|
* @example
|
|
@@ -570,12 +566,20 @@ type PromiseValues<T extends Promise<any>[]> = {
|
|
|
570
566
|
* ```
|
|
571
567
|
* @version 12.1.0
|
|
572
568
|
*/
|
|
573
|
-
declare function all<T extends [
|
|
574
|
-
|
|
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
|
+
}>;
|
|
575
575
|
/**
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
* `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.
|
|
579
583
|
*
|
|
580
584
|
* @see https://radashi.js.org/reference/async/all
|
|
581
585
|
* @example
|
|
@@ -587,8 +591,8 @@ declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValu
|
|
|
587
591
|
* })
|
|
588
592
|
* ```
|
|
589
593
|
*/
|
|
590
|
-
declare function all<T extends Record<string,
|
|
591
|
-
[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]>;
|
|
592
596
|
}>;
|
|
593
597
|
|
|
594
598
|
/**
|
package/dist/radashi.js
CHANGED
|
@@ -369,27 +369,28 @@ var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError
|
|
|
369
369
|
})();
|
|
370
370
|
|
|
371
371
|
// src/async/all.ts
|
|
372
|
-
async function all(
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
)
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
);
|
|
382
389
|
}
|
|
383
|
-
if (
|
|
384
|
-
|
|
390
|
+
if (errors.length > 0) {
|
|
391
|
+
throw new AggregateErrorOrPolyfill(errors);
|
|
385
392
|
}
|
|
386
|
-
return
|
|
387
|
-
(acc, item) => {
|
|
388
|
-
acc[item.key] = item.result;
|
|
389
|
-
return acc;
|
|
390
|
-
},
|
|
391
|
-
{}
|
|
392
|
-
);
|
|
393
|
+
return output;
|
|
393
394
|
}
|
|
394
395
|
|
|
395
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",
|