@cowprotocol/cow-sdk
Version:
<p align="center"> <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" /> </p>
29 lines (18 loc) • 1.02 kB
Markdown
# it-batch
[](https://github.com/achingbrain/it/actions/workflows/test.yml) [](https://coveralls.io/github/achingbrain/it?branch=master) [](https://david-dm.org/achingbrain/it?path=packages/it-batch)
> Takes an (async) iterable that emits things and returns an async iterable that emits those things in fixed-sized batches.
The final batch may be smaller than the max.
## Install
```sh
$ npm install --save it-batch
```
## Usage
```javascript
const batch = require('it-batch')
const all = require('it-all')
// This can also be an iterator, async iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const batchSize = 2
const result = await all(batch(values, batchSize))
console.info(result) // [0, 1], [2, 3], [4]
```