Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

update readme

  • Loading branch information...
commit 1edd1f6dbae8422e31eeae43dad139a8986f360f 1 parent 33e55fd
Atsuya Takagi authored December 21, 2012
44  README.md
Source Rendered
@@ -24,7 +24,7 @@ unnamed
24 24
 var DoneCriteria = require('../lib/done-criteria')
25 25
   , exit = false;
26 26
 
27  
-var doneCriteria = new DoneCriteria(['unko', 'geri'], function() {
  27
+var doneCriteria = new DoneCriteria(['unko', 'geri'], function(error) {
28 28
   console.log('all done!');
29 29
   exit = true;
30 30
 });
@@ -46,7 +46,7 @@ loop();
46 46
 This code results in:
47 47
 
48 48
 ```
49  
-$ node examples/unnamed.js 
  49
+$ node examples/unnamed.js
50 50
 not done yet...
51 51
 not done yet...
52 52
 not done yet...
@@ -72,7 +72,7 @@ var doneCriteria = new DoneCriteria(
72 72
           , function(name) { console.log('%s is done', name); }
73 73
         ]
74 74
     }
75  
-  , function() {
  75
+  , function(error) {
76 76
       console.log('all done!');
77 77
       exit = true;
78 78
     }
@@ -98,7 +98,7 @@ loop();
98 98
 This code will result in:
99 99
 
100 100
 ```
101  
-$ node examples/named.js 
  101
+$ node examples/named.js
102 102
 not done yet...
103 103
 not done yet...
104 104
 eat is done
@@ -107,6 +107,42 @@ all done!
107 107
 ```
108 108
 
109 109
 
  110
+count
  111
+-----
  112
+
  113
+```
  114
+var DoneCriteria = require('../lib/done-criteria')
  115
+  , exit = false;
  116
+
  117
+var doneCriteria = new DoneCriteria(3, function(error) {
  118
+  console.log('all done!');
  119
+  exit = true;
  120
+});
  121
+
  122
+setTimeout(function() { doneCriteria.done(); }, 200);
  123
+setTimeout(function() { doneCriteria.done(); }, 400);
  124
+setTimeout(function() { doneCriteria.done(); }, 600);
  125
+
  126
+var loop = function() {
  127
+  if (exit) {
  128
+    process.exit(0);
  129
+  } else {
  130
+    console.log('not done yet...');
  131
+    setTimeout(loop, 500);
  132
+  }
  133
+};
  134
+loop();
  135
+```
  136
+
  137
+This code will result in:
  138
+
  139
+```
  140
+$ node examples/count.js
  141
+not done yet...
  142
+not done yet...
  143
+all done!
  144
+```
  145
+
110 146
 License
111 147
 ========
112 148
 
21  examples/count.js
... ...
@@ -0,0 +1,21 @@
  1
+var DoneCriteria = require('../lib/done-criteria')
  2
+  , exit = false;
  3
+
  4
+var doneCriteria = new DoneCriteria(3, function(error) {
  5
+  console.log('all done!');
  6
+  exit = true;
  7
+});
  8
+
  9
+setTimeout(function() { doneCriteria.done(); }, 200);
  10
+setTimeout(function() { doneCriteria.done(); }, 400);
  11
+setTimeout(function() { doneCriteria.done(); }, 600);
  12
+
  13
+var loop = function() {
  14
+  if (exit) {
  15
+    process.exit(0);
  16
+  } else {
  17
+    console.log('not done yet...');
  18
+    setTimeout(loop, 500);
  19
+  }
  20
+};
  21
+loop();

0 notes on commit 1edd1f6

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