@jitesoft/async-array
v1.0.4
Published
Array wrapper with async methods.
Downloads
13
Readme
async-array
Array wrapper with async methods.
There are multiple ways to use this package:
Static functions
Import the static methods which are possible to use on any array type object:
import {map} from '@jitesoft/async-array';
import {doFunStuffAsync} from './async-functions';
(async () => {
let result = await map(['a', 'b', 'c'], async (value, index, list) => {
let somethingSomething = await doFunStuffAsync(value);
});
})();
The following methods are available to import directly for usage:
every
find
findIndex
forEach
forEachSeries
map
some
AsyncArray class
The AsyncArray
class is a class which extends the Array class. All the standard methods that the array class have is
available on the AsyncArray
. The following methods are overriden to introduce async functionality:
.every
.find
.findIndex
.forEach
.series
.map
.some
Convert Array
It's also possible to import the simple async
and sync
methods directly from the package to convert a normal array into
async or async array into normal.
import {sync, async} from '@jitesoft/async-array';
let array = []; // Array
array = async(array); // AsyncArray
array = sync(array); // Array