Hi Mark, It is possible but the solution is too inefficient to be usable. See http://smellegantcode.wordpress.com/2012/12/28/a-pure-library-approach-to-asyncawait-in-standard-javascript/
Bruno On Friday, October 24, 2014 6:44:41 AM UTC+2, Mark Hahn wrote: > > I've been following async to sync discussions for years but I have one > fundamental question. Is it possible to wrap an async function in a > library such that it can be called from code that is written expecting a > sync function? In other words could I make a library containing a > readFileSync function that uses fs.readFile? > > Using something like generators inside the library is legal as long as the > caller isn't aware of this. Requiring the caller code to do a transpile is > not legal. > > I should mention that this is for a node environment emulation that places > calls over the network using proxies. The readFileSync code obviously > can't go in a busy-wait loop waiting for the result from the net. > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/426140a6-d991-4d3f-91df-9003adfd2901%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.