a-synchronous / a-synchronous/rubico

reduce.pool

Open
#159 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
283
Forks
17
PR merge metrics
No merged PRs in 30d

Description

```coffeescript
reduce.pool(maxConcurrency number, foldable Foldable, init function|any) -> Promise|any
```

`reduce` with limited concurrency.

```javascript
// (from number, to number) => AsyncIterator
const asyncRange = async function* (from, to) {
let number = from
while (++number < to) {
yield number
}
}

const asyncAdd = async (a, b) => a + b

reduce.pool(20, map(tap(console.log))(asyncAdd), 0)(asyncRange(1, 1000)).then(console.log)
// 1
// 2
// 3
// ...
// 999
// 499499
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.