> Also, while very readable, using the yield operator forbids to run async tasks in parallel. Correct me if I'm wrong. It seems the only way to do so is to use multiple calls to `suspend` which in the end is very much like using a callbacks anyway.
I've addressed this in the readme: https://github.com/jmar777/suspend#what-about-parallel-execution-mapping-etc If I can arrive at a really elegant API for suspend to provide parallel and other "advanced" control flow operations, it probably will. For now, however, it's intentionally designed to be easily interoperable with your existing control-flow libraries of choice. Here's the example from the readme: // async without suspend async.map(['file1','file2','file3'], fs.stat, function(err, results){ // results is now an array of stats for each file }); // async with suspend var res = yield async.map(['file1','file2','file3'], fs.stat, resume); On Thursday, May 30, 2013 4:32:14 AM UTC-4, Floby wrote: > > Also, while very readable, using the yield operator forbids to run async > tasks in parallel. Correct me if I'm wrong. It seems the only way to do so > is to use multiple calls to `suspend` which in the end is very much like > using a callbacks anyway. > > On Tuesday, 28 May 2013 16:20:06 UTC+2, jmar777 wrote: >> >> *suspend* <https://github.com/jmar777/suspend> is a new control flow >> library that exposes a minimal API around* ES6 generators*, and is >> expressly designed to work transparently with Node's existing callback >> conventions. This allows unobtrusive use of *yield* execution semantics >> that works seamlessly with existing Node code bases (no need to wrap >> everything in a promises/whatever layer). >> >> *Quick example:* >> * >> * >> var suspend = require('suspend'), >> fs = require('fs'); >> >> suspend(function* (resume) { >> var data = yield fs.readFile(__filename, resume); >> console.log(data[1].toString('utf8')); >> })(); >> >> *Links:* GitHub Repo <https://github.com/jmar777/suspend> | Blog >> Announcement<http://devsmash.com/blog/suspend-generator-based-control-flow-for-node> >> >> *NPM: *$ npm install suspend >> >> *suspend* is extremely experimental, and I would greatly appreciate any >> feedback! >> > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
