2da47b34ba2935371234814f24be5fbbb1bfe03b8e64b050f6ceed226f315eac30f8f826b7a0ae63d1d3c04deccb2132a143f6cd91fa72004bf4e68e4bc54e 1.1 KB

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