0.0.1 • Published 5 years ago

async-iterator-batch v0.0.1

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

async-iterator-batch

Build status Coverage Status Dependencies Status

Takes an async iterator that emits variable length arrays and emits them as fixed-size batches

The final batch may be smaller than the max.

Install

$ npm install --save async-iterator-batch

Usage

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

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

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

console.info(result) // [0, 1], [2, 3], [4]