1 | # async-each
|
2 |
|
3 | No-bullshit, ultra-simple, 40-lines-of-code async parallel forEach function for JavaScript.
|
4 |
|
5 | We don't need junky 30K async libs. Really.
|
6 |
|
7 | For browsers and node.js.
|
8 |
|
9 | ## Usage
|
10 |
|
11 | `npm install async-each` if you're using NPM.
|
12 |
|
13 | For browsers, just include async-each before your scripts and use global variable `asyncEach`
|
14 |
|
15 | * `each(array, iterator, callback)` — `Array`, `Function`, `(optional) Function`
|
16 | * `iterator(item, next)` receives current item and a callback that will mark the item as done. `next` callback receives optional `error, transformedItem` arguments.
|
17 | * `callback(error, transformedArray)` optionally receives first error and transformed result `Array`.
|
18 |
|
19 | ```javascript
|
20 | var each = require('async-each');
|
21 | each(['a.js', 'b.js', 'c.js'], fs.readFile, function(error, contents) {
|
22 | if (error) console.error(error);
|
23 | console.log('Contents for a, b and c:', contents);
|
24 | });
|
25 |
|
26 | asyncEach(list, fn, callback); // use global var in browser
|
27 | ```
|
28 |
|
29 | ## License
|
30 |
|
31 | The MIT License (MIT)
|
32 |
|
33 | Copyright (c) 2016 Paul Miller [(paulmillr.com)](https://paulmillr.com)
|
34 |
|
35 | See [LICENSE](https://github.com/paulmillr/async-each/blob/master/LICENSE) file.
|