apr-for-each
Version:
Applies the function iteratee to each item in coll, in parallel.
52 lines (33 loc) • 2.19 kB
Markdown
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## for-each
<a id="for-each"></a>
Applies the function `iteratee` to each item in `coll`, in parallel.
[](https://www.npmjs.com/package/apr-for-each) [](https://www.npmjs.com/package/apr-for-each)
**Parameters**
- `input` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | Iterable)**
- `iteratee` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
**Examples**
```javascript
import awaitify from 'apr-awaitify';
import forEach from 'apr-for-each';
const writeFile = awaitify(fs.writeFile);
const files = [
'/home/.vimrc',
'/home/.zshrc'
];
await forEach(files, async (file) =>
await writeFile(file, 'boom')
);
```
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
### series
**Parameters**
- `input` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | Iterable)**
- `iteratee` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
### limit
**Parameters**
- `input` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | Iterable)**
- `limit` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
- `iteratee` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**