Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/component/each

Object / array / array-ish / string iteration utility
https://github.com/component/each

Last synced: 12 days ago
JSON representation

Object / array / array-ish / string iteration utility

Awesome Lists containing this project

README

        

# each

Array / object / string iteration utility.

## Installation

$ component install component/each

## API

### each(array, fn[, ctx])

Iterate an array:

```js
each([1,2,3], function(num, i){

})
```

Optionally pass a context object:

```js
each([1,2,3], function(num, i){

}, this)
```

### each(object, fn[, ctx])

Iterate an object's key / value pairs:

```js
each(conf, function(key, val){

})
```

Iterate an array-ish object (has numeric `.length`):

```js
each(collection, function(val, i){

})
```

### each(string, fn[, ctx])

Iterate a string's characters:

```js
each('hello', function(c, i){

})
```

# License

MIT