This package has been deprecated

Author message:

this package has been deprecated

freach

1.0.0 • Public • Published

forEach

There are so many libraries that do this sort of thing – this is just my preferred syntax. If pass an error to next, everything stops and the final callback is invoked with whatever error you passed.

I like it because it's easy to switch my asynchronous code between series and parallel. It also supports iteration of lists and objects.

Series

forEach([1,2,3], function(number, next){
 
  // Do something, async or not
  next(err);
 
}, function(err){
  // Everything finished
});

Parallel

 
var each = forEach.parallel;
 
each([1,2,3], function(number, next){
 
  // Do something, async or not
  next(err);
 
}, function(err){
  // Everything done
});

Parallel with cap

This is useful for running a reasonable number of network requests in parallel.

 
var each = forEach.parallel(10);
 
each([1,2,3], function(number, next){
 
  // Do something, async or not
  next(err);
 
}, function(err){
  // Everything done
});

Package Sidebar

Install

npm i freach

Weekly Downloads

2

Version

1.0.0

License

CC0-1.0

Last publish

Collaborators

  • davidmerfield