# async-reduce

> `reduce` function for async reductions on arrays.

Latest version **0.0.1** (published 2013-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-reduce
pnpm add async-reduce
yarn add async-reduce
bun add async-reduce
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2013-07-03 |
| First published | 2013-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Eldar Gabdullin |
| Maintainers | eldar |
| Keywords | reduce, async, array, parallel |

## Links

- npm: https://www.npmjs.com/package/async-reduce
- Repository: https://github.com/eldargab/async-reduce
- Issues: https://github.com/eldargab/async-reduce/issues
- npm.io page: https://npm.io/package/async-reduce

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2013-07-03

## README

#async-reduce

`reduce` function for async reductions on arrays.

##Examples

```javascript
var reduce = require('async-reduce')

function sum(a, b, cb) {
  setTimeout(function() {
    cb(null, a + b)
  })
}

reduce([1, 2, 3], 1, sum, function(err, result) {
  result.should.equal(7)
})
```

Concurrent reductions are also supported

```javascript
var reduce = require('async-reduce').concurrent(2, 0, function(a, b) {
  return a + b
})

reduce([1, 2, 3], 1, sum, function(err, result) {
  result.should.equal(7) // still the same result
})
```

During such reduction the given array is splitted into several
chunks with total chunks number equal to concurrency level (it is
the first arg to `.concurrent()`).
That chunks are reduced in parallel. That means that we need a
`combine` function to assembel results from that independent reductions
(third arg). We also need some sort of `unit` value to seed our
reductions (second arg). But we can omit `unit` and `combine`
if we only interested in side effects:

```javascript
var reduce = require('async-reduce').concurrent(5)
var items = []

reduce([1, 2, 3], null, function(_, item, cb) {
  items.push(item)
  cb()
}, function(err) {
  items.should.include(1)
  items.should.include(2)
  items.should.include(3)
})
```

This lib takes care about sync callback calls. They do not cause stack overflows.

##Installation

via component

```
component install eldargab/async-reduce
```

via npm

```
npm install async-reduce
```

##License

MIT

---
_Source: https://npm.io/package/async-reduce · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
