> On Oct 24, 2014, at 12:44 AM, Mark Hahn <[email protected]> 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.
There is not. Generators are close, but require the caller to also be function *, all the way down. -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/91E5EB65-E08E-49B0-9E61-8DE860613262%40nbtsc.org. For more options, visit https://groups.google.com/d/optout.
