You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
From nodejs/promises#6 originally, but seeing that util.promisify is finally in sight, I think this might be worth proposing too.
I propose that for compatibility reasons, and so that callback users using Node can keep working with their tooling to add a util.callbackify function that converts an async function to a callback taking function.
For example:
asyncfunctionfoo(){letdata1=awaitpromiseApi(..);letdata2=awaitpromiseApiOther(data1);returnresult;}constfoo2=util.callbackify(foo);foo2(function(err,data){// error here if foo threw// use data here});
This is likely faster in core, and would enable seamless integration of async functions into callback APIs and code bases. Seeing as we're not going to make a promisified core any time soon - this is beneficial for interoping between code bases using callbacks and async functions together.
How do @nodejs/collaborators feel about this?
darkyen, iMoses, yotam707, silicakes, webernir and 19 moresindresorhus, sergeysova, chicoxyzzy, melikhov-dev, fual and 3 more