# @ndhoule/foldl

> Apply a function to each value in a collection, accumulating the results into a single return value.

Latest version **2.0.1** (published 2016-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ndhoule/foldl
pnpm add @ndhoule/foldl
yarn add @ndhoule/foldl
bun add @ndhoule/foldl
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2016-05-02 |
| First published | 2015-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nathan Houle |
| Maintainers | ndhoule |
| Keywords | fold, reduce, component |

## Links

- npm: https://www.npmjs.com/package/@ndhoule/foldl
- Repository: https://github.com/ndhoule/foldl
- Issues: https://github.com/ndhoule/foldl/issues
- npm.io page: https://npm.io/package/@ndhoule/foldl

## Dependencies (1)

- [@ndhoule/each](https://npm.io/package/@ndhoule/each.md) ^2.0.1

## Recent versions

- 2.0.1 (latest) — 2016-05-02
- 2.0.0 — 2016-05-02
- 1.0.3 — 2015-05-05
- 1.0.2 — 2015-05-04

## README

# foldl [![CI][ci-badge]][ci-link]

Apply a function to each value in a collection, accumulating the results into a single return value.

## Installation

```sh
$ component install ndhoule/foldl
$ npm install @ndhoule/foldl
```

## API

### `reduce(iterator : Function, accumulator : *, collection : Array|Object)`

Reduces all the values in a collection down into a single value. Does so by iterating through the collection from left to right, repeatedly calling an `iterator` function and passing to it four arguments: `(accumulator, value, index, collection)`.

```javascript
foldl(function(total, n) {
  return total + n;
}, 0, [1, 2, 3]);
//=> 6

var phonebook = { bob: '555-111-2345', tim: '655-222-6789', sheila: '655-333-1298' };

foldl(function(results, phoneNumber) {
 if (phoneNumber[0] === '6') {
   return results.concat(phoneNumber);
 }
 return results;
}, [], phonebook);
// => ['655-222-6789', '655-333-1298']
```

## License

Released under the [MIT license](LICENSE.md).

[ci-link]: https://travis-ci.org/ndhoule/foldl
[ci-badge]: https://travis-ci.org/ndhoule/foldl.svg?branch=master

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