@jitesoft/async-array

1.0.4 • Public • Published

async-array

npm (scoped) Known Vulnerabilities pipeline status coverage report npm Back project

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

Dependents (0)

Package Sidebar

Install

npm i @jitesoft/async-array

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

513 kB

Total Files

9

Last publish

Collaborators

  • jitesoft~
  • johannestegner