Skip to content

Commit

Permalink
Add docs for parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
hokaccha committed Oct 17, 2011
1 parent 6e8d556 commit 189ba60
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions README.md
Expand Up @@ -107,6 +107,28 @@ This code becomes like this by using chain-tiny.
console.log(results); // => [ '0:foo', '1:bar' ] 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 ## Functions


### Chain ### Chain
Expand All @@ -132,6 +154,16 @@ This method only push stack. The function pushed to stack is executed when end()


* callback ( function ) * callback ( function )


### Chain.prototype.parallel

.parallel(obj)

Parallel exec functions.

#### Parameters

* obj ( Plaen Object or Array )

### Chain.prototype.end ### Chain.prototype.end


.end(callback) .end(callback)
Expand All @@ -152,6 +184,16 @@ Iterator function to each item in an array. Array recieved before next function


* callback ( 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


chain.forEach(array, callback) chain.forEach(array, callback)
Expand All @@ -163,6 +205,27 @@ Iterator function to each item in an array.
* array ( array ) * array ( array )
* callback ( function ) * 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 ## Testing


$ make test $ make test

0 comments on commit 189ba60

Please sign in to comment.