async-iterator-all

2019-08-16 admin

async-iterator-all是什么

什么是async-iterator-all,Collects all values from an async iterator and returns them as an array

async-iterator-all使用教程帮助文档

async-iterator-all

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-all

Usage

const all = require('async-iterator-all')

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

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

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

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-72680.html

文章标题:async-iterator-all

回到顶部