# @ndhoule/each

> Iterate over a collection, invoking a function for each element.

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

## Install

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

## 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 |
| Author | Nathan Houle |
| Maintainers | ndhoule |
| Keywords | component |

## Links

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

## Dependencies (1)

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

## 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

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

Iterate over a collection, invoking a function for each element in the collection.

## Installation

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

## API

### `each(iterator : Function, collection : Array|Object|string) => undefined`

Iterate over an input collection, invoking an `iterator` function for each element in the collection, passing to the iterator three arguments: `(value, index, collection)`.

The `iterator` function can end iteration early by returning `false`.

```javascript
var log = console.log.bind(console);

each(log, ['a', 'b', 'c']);
//-> 'a', 0, ['a', 'b', 'c']
//-> 'b', 1, ['a', 'b', 'c']
//-> 'c', 2, ['a', 'b', 'c']
//=> undefined

each(log, 'tim');
//-> 't', 2, 'tim'
//-> 'i', 1, 'tim'
//-> 'm', 0, 'tim'
//=> undefined

// Note: Iteration order not guaranteed across environments
each(log, { name: 'tim', occupation: 'enchanter' });
//-> 'tim', 'name', { name: 'tim', occupation: 'enchanter' }
//-> 'enchanter', 'occupation', { name: 'tim', occupation: 'enchanter' }
//=> undefined
```

## License

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

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

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