Permalink
Browse files

removed co.join() from all examples

  • Loading branch information...
1 parent 0cb0263 commit dc49fe052d0905fb5a37248f10738289e27a5676 @armed armed committed Jan 3, 2014
Showing with 44 additions and 57 deletions.
  1. +43 −0 examples/array.js
  2. +0 −1 examples/{generator-join.js → generator-array.js}
  3. +0 −55 examples/join.js
  4. +1 −1 examples/parallel.js
View
@@ -0,0 +1,43 @@
+
+var co = require('..');
+var fs = require('fs');
+
+function size(file) {
+ return function(fn){
+ fs.stat(file, function(err, stat){
+ if (err) return fn(err);
+ fn(null, stat.size);
+ });
+ }
+}
+
+// 3 concurrent stat()s at a time
+
+co(function *(){
+ var a = yield [size('.gitignore'), size('index.js'), size('Makefile')];
+ var b = yield [size('.gitignore'), size('index.js'), size('Makefile')];
+ var c = yield [size('.gitignore'), size('index.js'), size('Makefile')];
+ console.log(a);
+ console.log(b);
+ console.log(c);
+})()
+
+// 9 concurrent stat()s
+
+co(function *(){
+ var a = [size('.gitignore'), size('index.js'), size('Makefile')];
+ var b = [size('.gitignore'), size('index.js'), size('Makefile')];
+ var c = [size('.gitignore'), size('index.js'), size('Makefile')];
+ var d = yield [a, b, c];
+ console.log(d);
+})()
+
+// 3
+
+co(function *(){
+ var a = size('.gitignore');
+ var b = size('index.js');
+ var c = size('Makefile');
+ var res = yield [a, b, c];
+ console.log(res);
+})()
@@ -2,7 +2,6 @@
var request = require('request');
var thunk = require('thunkify');
var co = require('..');
-var join = co.join;
var get = thunk(request.get);
View
@@ -1,55 +0,0 @@
-
-var co = require('..');
-var fs = require('fs');
-var join = co.join;
-
-function size(file) {
- return function(fn){
- fs.stat(file, function(err, stat){
- if (err) return fn(err);
- fn(null, stat.size);
- });
- }
-}
-
-// 3 concurrent stat()s at a time
-
-co(function *(){
- var a = yield join(size('.gitignore'), size('index.js'), size('Makefile'));
- var b = yield join(size('.gitignore'), size('index.js'), size('Makefile'));
- var c = yield join(size('.gitignore'), size('index.js'), size('Makefile'));
- console.log(a);
- console.log(b);
- console.log(c);
-})()
-
-// 9 concurrent stat()s
-
-co(function *(){
- var a = join(size('.gitignore'), size('index.js'), size('Makefile'));
- var b = join(size('.gitignore'), size('index.js'), size('Makefile'));
- var c = join(size('.gitignore'), size('index.js'), size('Makefile'));
- var d = yield join(a, b, c);
- console.log(d);
-})()
-
-// 3
-
-co(function *(){
- var a = size('.gitignore');
- var b = size('index.js');
- var c = size('Makefile');
- var res = yield join(a, b, c);
- console.log(res);
-})()
-
-// 3 with array syntax
-
-co(function *(){
- var a = size('.gitignore');
- var b = size('index.js');
- var c = size('Makefile');
- var res = yield [a, b, c];
- console.log(res);
-})()
-
View
@@ -10,7 +10,7 @@ var fs = require('fs');
// var res = yield [a, b, c] to execute them in
// parallel.
-// for an alternative see ./join.js
+// for an alternative see ./array.js
// also if writing all this boilerplate
// is not to your liking check out "thunkify"

0 comments on commit dc49fe0

Please sign in to comment.