0.0.1 • Published 5 years ago

async-iterator-to-array v0.0.1

Weekly downloads
434
License
ISC
Repository
github
Last release
5 years ago

async-iterator-to-array

Build status Coverage Status Dependencies Status

Collects all values from an async iterator and returns them as an array

Mostly useful for tests.

Install

$ npm install --save async-iterator-to-array

Usage

const toArray = require('async-iterator-to-array')

async function * iterator (values) {
  for (let i = 0; i < values.length; i++) {
    yield values[i]
  }
}

const arr = await toArray(iterator([0, 1, 2, 3, 4]))

console.info(arr) // 0, 1, 2, 3, 4