@injectivelabs/utils 1.18.2 → 1.18.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/cjs/index.cjs +5 -3
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +5 -3
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -67,11 +67,13 @@ const awaitAll = async (array, callback) => await Promise.all(array.map(async (i
|
|
|
67
67
|
* When we want to execute the promises one by one
|
|
68
68
|
* and not all in batch as with await Promise.all()
|
|
69
69
|
*/
|
|
70
|
-
const awaitForAll = async (array, callback) => {
|
|
70
|
+
const awaitForAll = async (array, callback, onError) => {
|
|
71
71
|
const result = [];
|
|
72
72
|
for (let i = 0; i < array.length; i += 1) try {
|
|
73
73
|
result.push(await callback(array[i]));
|
|
74
|
-
} catch (
|
|
74
|
+
} catch (e) {
|
|
75
|
+
if (onError) onError(e, array[i], i);
|
|
76
|
+
}
|
|
75
77
|
return result;
|
|
76
78
|
};
|
|
77
79
|
const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => {
|
|
@@ -92,7 +94,7 @@ const splitArrayToChunks = ({ array, filter, chunkSize }) => {
|
|
|
92
94
|
chunkSize,
|
|
93
95
|
filter
|
|
94
96
|
});
|
|
95
|
-
} catch (
|
|
97
|
+
} catch (_unused) {
|
|
96
98
|
return [array];
|
|
97
99
|
}
|
|
98
100
|
};
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -27,7 +27,7 @@ declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S
|
|
|
27
27
|
* When we want to execute the promises one by one
|
|
28
28
|
* and not all in batch as with await Promise.all()
|
|
29
29
|
*/
|
|
30
|
-
declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S
|
|
30
|
+
declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>;
|
|
31
31
|
declare const splitArrayToChunksThrow: <T>({
|
|
32
32
|
array,
|
|
33
33
|
filter,
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S
|
|
|
27
27
|
* When we want to execute the promises one by one
|
|
28
28
|
* and not all in batch as with await Promise.all()
|
|
29
29
|
*/
|
|
30
|
-
declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S
|
|
30
|
+
declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>;
|
|
31
31
|
declare const splitArrayToChunksThrow: <T>({
|
|
32
32
|
array,
|
|
33
33
|
filter,
|
package/dist/esm/index.js
CHANGED
|
@@ -38,11 +38,13 @@ const awaitAll = async (array, callback) => await Promise.all(array.map(async (i
|
|
|
38
38
|
* When we want to execute the promises one by one
|
|
39
39
|
* and not all in batch as with await Promise.all()
|
|
40
40
|
*/
|
|
41
|
-
const awaitForAll = async (array, callback) => {
|
|
41
|
+
const awaitForAll = async (array, callback, onError) => {
|
|
42
42
|
const result = [];
|
|
43
43
|
for (let i = 0; i < array.length; i += 1) try {
|
|
44
44
|
result.push(await callback(array[i]));
|
|
45
|
-
} catch (
|
|
45
|
+
} catch (e) {
|
|
46
|
+
if (onError) onError(e, array[i], i);
|
|
47
|
+
}
|
|
46
48
|
return result;
|
|
47
49
|
};
|
|
48
50
|
const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => {
|
|
@@ -63,7 +65,7 @@ const splitArrayToChunks = ({ array, filter, chunkSize }) => {
|
|
|
63
65
|
chunkSize,
|
|
64
66
|
filter
|
|
65
67
|
});
|
|
66
|
-
} catch (
|
|
68
|
+
} catch (_unused) {
|
|
67
69
|
return [array];
|
|
68
70
|
}
|
|
69
71
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/utils",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.4",
|
|
4
4
|
"description": "List of utils and helper functions that can be reused throughout Injective's projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"bignumber.js": "^9.3.1",
|
|
67
67
|
"http-status-codes": "^2.3.0",
|
|
68
68
|
"store2": "^2.14.4",
|
|
69
|
-
"@injectivelabs/
|
|
70
|
-
"@injectivelabs/
|
|
71
|
-
"@injectivelabs/
|
|
69
|
+
"@injectivelabs/exceptions": "1.18.4",
|
|
70
|
+
"@injectivelabs/networks": "1.18.4",
|
|
71
|
+
"@injectivelabs/ts-types": "1.18.4"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|