Permalink
Browse files

Add docs for parallel

  • Loading branch information...
1 parent 6e8d556 commit 189ba60c1d42d9e5358a742a561eca9a443011a0 @hokaccha committed Oct 17, 2011
Showing with 63 additions and 0 deletions.
  1. +63 −0 README.md
View
63 README.md
@@ -107,6 +107,28 @@ This code becomes like this by using chain-tiny.
console.log(results); // => [ '0:foo', '1:bar' ]
});
+### parallel
+
+ var r = [];
+ chain.parallel({
+ foo: function(next) {
+ setTimeout(function() {
+ r.push(1);
+ next(null, 1);
+ }, 100);
+ },
+ bar: function(next) {
+ setTimeout(function() {
+ r.push(2);
+ next(null, 2);
+ }, 1)
+ }
+ })
+ .end(function(err, results) {
+ console.log(results); // => { foo: 1, bar: 2 }
+ console.log(r); // => [2, 1]
+ });
+
## Functions
### Chain
@@ -132,6 +154,16 @@ This method only push stack. The function pushed to stack is executed when end()
* callback ( function )
+### Chain.prototype.parallel
+
+ .parallel(obj)
+
+Parallel exec functions.
+
+#### Parameters
+
+* obj ( Plaen Object or Array )
+
### Chain.prototype.end
.end(callback)
@@ -152,6 +184,16 @@ Iterator function to each item in an array. Array recieved before next function
* callback ( function )
+### Chain.prototype.forEachParallel
+
+ .forEachParallel(callback)
+
+Parallel iterator function to each item in an array. Array recieved before next function args.
+
+#### Parameters
+
+* callback ( function )
+
### Chain.forEach
chain.forEach(array, callback)
@@ -163,6 +205,27 @@ Iterator function to each item in an array.
* array ( array )
* callback ( function )
+### Chain.parallel
+
+ chain.parallel(obj)
+
+Alias of `Chain().parallel(obj)`
+
+#### Parameters
+
+* obj ( Plaen Object or Array )
+
+### Chain.forEachParallel
+
+ chain.forEachParallel(array, callback)
+
+Parallel iterator function to each item in an array.
+
+#### Parameters
+
+* array ( array )
+* callback ( function )
+
## Testing
$ make test

0 comments on commit 189ba60

Please sign in to comment.