Permalink
Browse files

Update docs.

  • Loading branch information...
1 parent 21a4ac8 commit 168cc1633155314b3b38d72c46902a2991d61291 @hokaccha committed Feb 13, 2013
Showing with 38 additions and 0 deletions.
  1. +38 −0 README.md
View
38 README.md
@@ -64,6 +64,28 @@ This code becomes like this by using chain-tiny.
console.log(baz); // => baz
});
+### using this.next
+
+ var chain = require('chain-tiny');
+
+ chain(function() {
+ var next = this.next;
+ setTimeout(function() {
+ next(null, 'foo');
+ }, 100);
+ })
+ .chain(function(foo) {
+ var next = this.next;
+ console.log(foo); // => foo
+ setTimeout(function() {
+ next(null, 'bar', 'baz');
+ }, 1);
+ })
+ .end(function(err, bar, baz) {
+ console.log(bar); // => bar
+ console.log(baz); // => baz
+ });
+
### error handling
var chain = require('chain-tiny');
@@ -161,6 +183,22 @@ chain:
console.log(results); // => { foo: 'foo:bar', hoge: 'hoge:fuga' }
});
+or,
+
+ var chain = require('chain-tiny');
+
+ chain(function(next) {
+ next(null);
+ })
+ .each({ foo: 'bar', hoge: 'fuga'}, function(key, val, next) {
+ setTimeout(function() {
+ next(null, key + ':' + val);
+ }, 1);
+ })
+ .end(function(err, results) { // or .chain(results, next)
+ console.log(results); // => { foo: 'foo:bar', hoge: 'hoge:fuga' }
+ });
+
parallel:
var chain = require('chain-tiny');

0 comments on commit 168cc16

Please sign in to comment.