1.0.4 • Published 5 years ago

@jitesoft/async-array v1.0.4

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
5 years ago

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
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago