-
Notifications
You must be signed in to change notification settings - Fork 27
util.callbackify
for async functions
#109
Comments
I think we need this if we want to ship promisify. |
👍 from me. Regardless of how core feels about promises and async/await, userland will use them, so we need to ensure interop works well. |
I think it makes sense if promisify makes it in. |
-1 unless we have something to offer in terms of performance |
Someone has to say it: |
Yea, can we be consistent? |
util.toCallback
for async functionsutil.callbackify
for async functions
@bnoordhuis @evanlucas this issue was mostly to see if there is interest - I've amended to |
@not-an-aardvark I'm working on a PR, finishing some tests and will upload tomorrow for you'll to review... |
I'd be happy if we could push nodejs/node#12712 forward. |
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Promise`/`awaitable` Fixes: nodejs/CTC#109
I believe this could be closed now that nodejs/node@af3aa68 landed |
Sweet! Thanks a lot @refack :) |
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` PR-URL: nodejs#12712 Fixes: nodejs/CTC#109 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` Original-PR-URL: #12712 Fixes: nodejs/CTC#109 Original-Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Original-Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Original-Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Original-Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> Original-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #13750 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` Original-PR-URL: #12712 Fixes: nodejs/CTC#109 Original-Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Original-Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Original-Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Original-Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> Original-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #13750 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` Original-PR-URL: #12712 Fixes: nodejs/CTC#109 Original-Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Original-Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Original-Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Original-Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> Original-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #13750 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` Original-PR-URL: #12712 Fixes: nodejs/CTC#109 Original-Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Original-Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Original-Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Original-Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> Original-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #13750 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` Original-PR-URL: #12712 Fixes: nodejs/CTC#109 Original-Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Original-Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Original-Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Original-Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> Original-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #13750 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` Original-PR-URL: #12712 Fixes: nodejs/CTC#109 Original-Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Original-Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Original-Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Original-Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> Original-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #13750 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Hey,
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:
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?
The text was updated successfully, but these errors were encountered: