Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update docs.

  • Loading branch information...
commit 168cc1633155314b3b38d72c46902a2991d61291 1 parent 21a4ac8
Kazuhito Hokamura authored February 13, 2013

Showing 1 changed file with 38 additions and 0 deletions. Show diff stats Hide diff stats

  1. 38  README.md
38  README.md
Source Rendered
@@ -64,6 +64,28 @@ This code becomes like this by using chain-tiny.
64 64
       console.log(baz); // => baz
65 65
     });
66 66
 
  67
+### using this.next
  68
+
  69
+    var chain = require('chain-tiny');
  70
+
  71
+    chain(function() {
  72
+      var next = this.next;
  73
+      setTimeout(function() {
  74
+        next(null, 'foo');
  75
+      }, 100);
  76
+    })
  77
+    .chain(function(foo) {
  78
+      var next = this.next;
  79
+      console.log(foo); // => foo
  80
+      setTimeout(function() {
  81
+        next(null, 'bar', 'baz');
  82
+      }, 1);
  83
+    })
  84
+    .end(function(err, bar, baz) {
  85
+      console.log(bar); // => bar
  86
+      console.log(baz); // => baz
  87
+    });
  88
+
67 89
 ### error handling
68 90
 
69 91
     var chain = require('chain-tiny');
@@ -161,6 +183,22 @@ chain:
161 183
       console.log(results); // => { foo: 'foo:bar', hoge: 'hoge:fuga' }
162 184
     });
163 185
 
  186
+or,
  187
+
  188
+    var chain = require('chain-tiny');
  189
+
  190
+    chain(function(next) {
  191
+      next(null);
  192
+    })
  193
+    .each({ foo: 'bar', hoge: 'fuga'}, function(key, val, next) {
  194
+      setTimeout(function() {
  195
+        next(null, key + ':' + val);
  196
+      }, 1);
  197
+    })
  198
+    .end(function(err, results) { // or .chain(results, next)
  199
+      console.log(results); // => { foo: 'foo:bar', hoge: 'hoge:fuga' }
  200
+    });
  201
+
164 202
 parallel:
165 203
 
166 204
     var chain = require('chain-tiny');

0 notes on commit 168cc16

Please sign in to comment.
Something went wrong with that request. Please try again.