# @arr/reduce

> A tiny, faster alternative to native Array.prototype.reduce

Latest version **1.0.3** (published 2020-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @arr/reduce
pnpm add @arr/reduce
yarn add @arr/reduce
bun add @arr/reduce
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-09-09 |
| First published | 2017-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=4 |
| Dependencies | 0 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 259 |
| Author | Luke Edwards |
| Maintainers | lukeed |
| Keywords | arr, array, Array.reduce, Array.prototype.reduce, performance, native, reduce |

## Links

- npm: https://www.npmjs.com/package/@arr/reduce
- Repository: https://github.com/lukeed/arr
- Homepage: https://github.com/lukeed/arr#readme
- Issues: https://github.com/lukeed/arr/issues
- npm.io page: https://npm.io/package/@arr/reduce

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-09-09
- 1.0.1 — 2019-10-23
- 1.0.0 — 2017-07-13
- 0.2.0 — 2017-07-13
- 0.1.0 — 2017-07-09

## README

# @arr/reduce

> A tiny, faster alternative to native `Array.prototype.reduce`

## Install

```
$ npm install --save @arr/reduce
```

## Usage

```js
import reduce from '@arr/reduce';

const total = reduce([0, 1, 2, 3], (sum, value) => sum + value);
//=> 6

const flattened = reduce([[0, 1], [2, 3], [4, 5]], (a, b) => a.concat(b), []);
//=> [0, 1, 2, 3, 4, 5]
```

## API

### reduce(arr, callback[, initialValue])

#### arr
Type: `Array`<br>
The array to iterate upon.

#### callback(accumulator, value, index, array)
Type: `Function`<br>
Function to test for each element, taking four arguments:

* **accumulator** -- The accumulator accumulates the callback's return values.
* **value** -- The current element being processed in the array.
* **index** -- The index of the current element being processed in the array.
* **array** -- The array `reduce` was called upon.

#### initialValue
Type: `Mixed`<br>
Default: `arr[0]`<br>
The `value` to use as the first argument to the first call of the `callback`. If no initial value is supplied, the first element in the array will be used.


## License

MIT © [Luke Edwards](http://lukeed.com)

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