co
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -45,1 +45,12 @@ | ||
}); | ||
// 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); | ||
}); | ||
1.2.0 / 2013-06-08 | ||
================== | ||
* add array yielding support. great suggestion by @domenic | ||
1.1.0 / 2013-06-06 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -54,2 +54,7 @@ | ||
// array (join) | ||
if (Array.isArray(ret.value)) { | ||
ret.value = exports.join(ret.value); | ||
} | ||
// thunk | ||
@@ -56,0 +61,0 @@ if ('function' == typeof ret.value) { |
{ | ||
"name": "co", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "generator async flow control goodness", | ||
@@ -5,0 +5,0 @@ "keywords": ["async", "flow", "generator", "coro", "coroutine"], |
@@ -10,2 +10,6 @@ # Co | ||
Co is careful to relay any errors that occur back to the generator, including those | ||
within the thunk, or from the thunk's callback. "Uncaught" exceptions in the generator are | ||
then either passed `co()`'s thunk or thrown. | ||
## Installation | ||
@@ -20,2 +24,3 @@ | ||
- [co-fs](https://github.com/visionmedia/co-fs) - core `fs` function wrappers | ||
- [co-exec](https://github.com/visionmedia/co-exec) - core `exec` function wrapper | ||
@@ -274,2 +279,15 @@ ## Example | ||
As an alias of `join(array)` you may simply `yield` an array: | ||
```js | ||
co(function *(){ | ||
var a = size('.gitignore'); | ||
var b = size('index.js'); | ||
var c = size('Makefile'); | ||
var res = yield [a, b, c]; | ||
console.log(res); | ||
// => [ 13, 1687, 129 ] | ||
}); | ||
``` | ||
## FAQ | ||
@@ -276,0 +294,0 @@ |
@@ -43,1 +43,19 @@ | ||
}) | ||
describe('yield array', function(){ | ||
it('should alias yield join(array)', function(done){ | ||
co(function *(){ | ||
var a = read('index.js', 'utf8'); | ||
var b = read('Makefile', 'utf8'); | ||
var c = read('package.json', 'utf8'); | ||
var res = yield [a, b, c]; | ||
res.should.have.length(3); | ||
res[0].should.include('exports'); | ||
res[1].should.include('test'); | ||
res[2].should.include('devDependencies'); | ||
done(); | ||
}); | ||
}) | ||
}) |
25196
671
328