Notwithstanding Precautions, Misadventure
Miss any of our Open RFC calls?Watch the recordings here! »

async-array-class

1.0.2 • Public • Published

asyncArray

JavaScript Style Guide

Async Arrays for ES6

Install

npm install async-array-class

Compatibility

This class extends the native Array, so this works only in the engines that support natively ES6 classes

https://kangax.github.io/compat-table/es6/#test-class

all the updated browsers, no IE

http://node.green/#class

from Node 4.4.6

Description

This class extends the normal Array adding the following async methods:

  • everyAsync
  • filterAsync
  • findAsync
  • findIndexAsync
  • includesAsync
  • someAsync
  • mapAsync
  • reduceAsync
  • reduceRightAsync

Use cases

This methods can be useful in a lot of cases, for example you can use map to transform an array of urls, in an array of documents :

const asyncListOfUrls = AsyncArray.from(listOfUrls)
const asyncListOfDocuments = await asyncListOfUrls.map(downloadUrl)

or a long list of user cases ( this are just examples ):

const asyncListOfFilenames = AsyncArray.from(listOfFilenames)
const asyncListOfSmallFiles = await asyncListOfFilenames.filter(isFileSmallerThan300KB)
 
const asyncListOfDependecies = AsyncArray.from(lListOfDependecies)
const isAppUpdated = await asyncListOfDependecies.every(isDependenciesUpdated)
 

Example

http://jsbin.com/sixibupava/edit?js,console

Keywords

Install

npm i async-array-class

DownloadsWeekly Downloads

2

Version

1.0.2

License

ISC

Last publish

Collaborators

  • avatar