@@ -15,32 +15,16 @@ A collection of array-related async utilities.
1515
1616### General utils
1717
18- #### ` asyncMap ()`
18+ #### ` asyncEvery ()`
1919
20- Creates a new array populated with the results of calling a provided asynchronous function on every element in the calling array.
21-
22- Note: For optimization purposes, all iterations are ran concurrently. If you rely on any side effects, consider `asyncMapStrict ()` instead.
20+ Tests whether all elements in the array pass the test implemented by the provided asynchronous function . It returns a Boolean value.
2321
2422##### Sample usage
2523
2624```js
27- import { asyncMap } from ' @wojtekmaj/async-array-utils' ;
25+ import { asyncEvery } from '@wojtekmaj/async-array-utils';
2826
29- const asyncMappedArr = await asyncMap ([1 , 2 , 3 ], async (el , index ) => el * 2 ); // [2, 4, 6]
30- ```
31-
32- #### ` asyncMapStrict() `
33-
34- Like ` asyncMap() ` , but runs iterations non-concurrently.
35-
36- ##### Sample usage
37-
38- ``` js
39- import { asyncMapStrict } from ' @wojtekmaj/async-array-utils' ;
40-
41- const indexes = [];
42- await asyncMapStrict ([1 , 2 , 3 ], async (el , index ) => { indexes .push (index); return el * 2 ; }); // [2, 4, 6]
43- console .log (indexes); // [0, 1, 2]
27+ const largerThanZero = await asyncEvery ([1 , 2 , 3 ], async (el , index ) => el > 0 ); // true
4428```
4529
4630#### `asyncForEach()`
@@ -77,6 +61,34 @@ await asyncForEachStrict(
7761console .log (indexes); // [0, 1, 2]
7862```
7963
64+ #### ` asyncMap() `
65+
66+ Creates a new array populated with the results of calling a provided asynchronous function on every element in the calling array.
67+
68+ Note: For optimization purposes, all iterations are ran concurrently. If you rely on any side effects, consider ` asyncMapStrict() ` instead.
69+
70+ ##### Sample usage
71+
72+ ``` js
73+ import { asyncMap } from ' @wojtekmaj/async-array-utils' ;
74+
75+ const asyncMappedArr = await asyncMap ([1 , 2 , 3 ], async (el , index ) => el * 2 ); // [2, 4, 6]
76+ ```
77+
78+ #### ` asyncMapStrict() `
79+
80+ Like ` asyncMap() ` , but runs iterations non-concurrently.
81+
82+ ##### Sample usage
83+
84+ ``` js
85+ import { asyncMapStrict } from ' @wojtekmaj/async-array-utils' ;
86+
87+ const indexes = [];
88+ await asyncMapStrict ([1 , 2 , 3 ], async (el , index ) => { indexes .push (index); return el * 2 ; }); // [2, 4, 6]
89+ console .log (indexes); // [0, 1, 2]
90+ ```
91+
8092#### ` asyncReduce() `
8193
8294Executes a reducer asynchronous function (that you provide) on each element of the array, resulting in a single output value.
@@ -93,6 +105,32 @@ const result = await asyncReduce(
93105); // 6
94106```
95107
108+ #### ` asyncSome() `
109+
110+ Tests whether at least one element in the array pass the test implemented by the provided asynchronous function. It returns a Boolean value.
111+
112+ Note: For optimization purposes, all iterations are ran concurrently. If you rely on any side effects or execution order, consider ` asyncMapStrict() ` instead.
113+
114+ ##### Sample usage
115+
116+ ``` js
117+ import { asyncSome } from ' @wojtekmaj/async-array-utils' ;
118+
119+ const largerThanZero = await asyncSome ([1 , 2 , 3 ], async (el , index ) => el > 0 ); // true
120+ ```
121+
122+ #### ` asyncSomeStrict() `
123+
124+ Like ` asyncSome() ` , but runs iterations non-concurrently.
125+
126+ ##### Sample usage
127+
128+ ``` js
129+ import { asyncSomeStrict } from ' @wojtekmaj/async-array-utils' ;
130+
131+ const largerThanZero = await asyncSomeStrict ([1 , 2 , 3 ], async (el , index ) => el > 0 ); // true
132+ ```
133+
96134## License
97135
98136The MIT License.
0 commit comments