http://wingolog.org/archives/2013/05/08/generators-in-v8
// notice: function* instead of function
function* values() {
for (var i = 0; i < arguments.length; i++) {
yield arguments[i];
}
}
var o = values(1, 2, 3); // => [object Generator]
加上以后 Node.js 就不是原来的异步了啊...
Why? This is still asynchronous. It is more convenient to do pipeline. More like fp.
JavaScript's support for coroutines can be said to be a huge leap forward. It uses new syntax to avoid conflicts with old syntax to achieve new features.
For details, please refer to: Koa, co and coroutine