This repository was archived by the owner on Nov 9, 2017. It is now read-only.
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
util.callbackify
for async functions #109
Closed
Description
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:
async function foo() {
let data1 = await promiseApi(..);
let data2 = await promiseApiOther(data1);
return result;
}
const foo2 = 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?
Metadata
Metadata
Assignees
Labels
No labels