radashi 12.3.2 → 12.3.4
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 +15 -9
- package/dist/radashi.d.cts +4 -3
- package/dist/radashi.d.ts +4 -3
- package/dist/radashi.js +15 -9
- package/package.json +1 -1
package/dist/radashi.cjs
CHANGED
|
@@ -521,17 +521,23 @@ async function parallel(options, array, func) {
|
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
// src/async/reduce.ts
|
|
524
|
-
async function reduce(array,
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
524
|
+
async function reduce(array, reducer, initialValue) {
|
|
525
|
+
if (!array) {
|
|
526
|
+
array = [];
|
|
527
|
+
}
|
|
528
|
+
const indices = array.keys();
|
|
529
|
+
let acc = initialValue;
|
|
530
|
+
if (acc === void 0 && arguments.length < 3) {
|
|
531
|
+
if (!array.length) {
|
|
532
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
|
533
|
+
}
|
|
534
|
+
acc = array[0];
|
|
535
|
+
indices.next();
|
|
528
536
|
}
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
for (const [i, item] of iter.entries()) {
|
|
532
|
-
value = await asyncReducer(value, item, i);
|
|
537
|
+
for (const index of indices) {
|
|
538
|
+
acc = await reducer(acc, array[index], index);
|
|
533
539
|
}
|
|
534
|
-
return
|
|
540
|
+
return acc;
|
|
535
541
|
}
|
|
536
542
|
|
|
537
543
|
// src/async/retry.ts
|
package/dist/radashi.d.cts
CHANGED
|
@@ -677,7 +677,7 @@ declare function guard<TFunction extends () => any>(func: TFunction, shouldGuard
|
|
|
677
677
|
* ```
|
|
678
678
|
* @version 12.1.0
|
|
679
679
|
*/
|
|
680
|
-
declare function map<T, K>(array: readonly T[], asyncMapFunc: (item: T, index: number) =>
|
|
680
|
+
declare function map<T, K>(array: readonly T[], asyncMapFunc: (item: T, index: number) => PromiseLike<K>): Promise<K[]>;
|
|
681
681
|
|
|
682
682
|
type AbortSignal$1 = {
|
|
683
683
|
readonly aborted: boolean;
|
|
@@ -738,7 +738,8 @@ declare function parallel<T, K>(options: ParallelOptions | number, array: readon
|
|
|
738
738
|
* ```
|
|
739
739
|
* @version 12.1.0
|
|
740
740
|
*/
|
|
741
|
-
declare function reduce<T, K>(array: readonly T[],
|
|
741
|
+
declare function reduce<T, K>(array: readonly T[], reducer: (acc: K, item: T, index: number) => Promise<K>, initialValue: K): Promise<K>;
|
|
742
|
+
declare function reduce<T, K>(array: readonly T[], reducer: (acc: K, item: T, index: number) => Promise<K>): Promise<K>;
|
|
742
743
|
|
|
743
744
|
type AbortSignal = {
|
|
744
745
|
throwIfAborted(): void;
|
|
@@ -1468,7 +1469,7 @@ declare function range<T = number>(startOrLength: number, end?: number, valueOrM
|
|
|
1468
1469
|
* @example
|
|
1469
1470
|
* ```ts
|
|
1470
1471
|
* round(123.456)
|
|
1471
|
-
* // => 123
|
|
1472
|
+
* // => 123
|
|
1472
1473
|
*
|
|
1473
1474
|
* round(1234.56, -2)
|
|
1474
1475
|
* // => 1200
|
package/dist/radashi.d.ts
CHANGED
|
@@ -677,7 +677,7 @@ declare function guard<TFunction extends () => any>(func: TFunction, shouldGuard
|
|
|
677
677
|
* ```
|
|
678
678
|
* @version 12.1.0
|
|
679
679
|
*/
|
|
680
|
-
declare function map<T, K>(array: readonly T[], asyncMapFunc: (item: T, index: number) =>
|
|
680
|
+
declare function map<T, K>(array: readonly T[], asyncMapFunc: (item: T, index: number) => PromiseLike<K>): Promise<K[]>;
|
|
681
681
|
|
|
682
682
|
type AbortSignal$1 = {
|
|
683
683
|
readonly aborted: boolean;
|
|
@@ -738,7 +738,8 @@ declare function parallel<T, K>(options: ParallelOptions | number, array: readon
|
|
|
738
738
|
* ```
|
|
739
739
|
* @version 12.1.0
|
|
740
740
|
*/
|
|
741
|
-
declare function reduce<T, K>(array: readonly T[],
|
|
741
|
+
declare function reduce<T, K>(array: readonly T[], reducer: (acc: K, item: T, index: number) => Promise<K>, initialValue: K): Promise<K>;
|
|
742
|
+
declare function reduce<T, K>(array: readonly T[], reducer: (acc: K, item: T, index: number) => Promise<K>): Promise<K>;
|
|
742
743
|
|
|
743
744
|
type AbortSignal = {
|
|
744
745
|
throwIfAborted(): void;
|
|
@@ -1468,7 +1469,7 @@ declare function range<T = number>(startOrLength: number, end?: number, valueOrM
|
|
|
1468
1469
|
* @example
|
|
1469
1470
|
* ```ts
|
|
1470
1471
|
* round(123.456)
|
|
1471
|
-
* // => 123
|
|
1472
|
+
* // => 123
|
|
1472
1473
|
*
|
|
1473
1474
|
* round(1234.56, -2)
|
|
1474
1475
|
* // => 1200
|
package/dist/radashi.js
CHANGED
|
@@ -519,17 +519,23 @@ async function parallel(options, array, func) {
|
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
// src/async/reduce.ts
|
|
522
|
-
async function reduce(array,
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
522
|
+
async function reduce(array, reducer, initialValue) {
|
|
523
|
+
if (!array) {
|
|
524
|
+
array = [];
|
|
525
|
+
}
|
|
526
|
+
const indices = array.keys();
|
|
527
|
+
let acc = initialValue;
|
|
528
|
+
if (acc === void 0 && arguments.length < 3) {
|
|
529
|
+
if (!array.length) {
|
|
530
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
|
531
|
+
}
|
|
532
|
+
acc = array[0];
|
|
533
|
+
indices.next();
|
|
526
534
|
}
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
for (const [i, item] of iter.entries()) {
|
|
530
|
-
value = await asyncReducer(value, item, i);
|
|
535
|
+
for (const index of indices) {
|
|
536
|
+
acc = await reducer(acc, array[index], index);
|
|
531
537
|
}
|
|
532
|
-
return
|
|
538
|
+
return acc;
|
|
533
539
|
}
|
|
534
540
|
|
|
535
541
|
// src/async/retry.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "radashi",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.4",
|
|
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": {
|