This repository was archived by the owner on Mar 31, 2018. It is now read-only.
This repository was archived by the owner on Mar 31, 2018. It is now read-only.
util.promised
- Callbacks and async/await #5
Closed
Description
With async/await
landing in v8 callback users should not have their workflows harmed.
I'm wondering if core should offer a util.promised
method that wraps a callback returning method in such a way it can be used with async/await
- effectively allowing non-promise users interact with async/await
. It would work similarly to Promise.fromCallback
:
async function doBar() {
var result = await promised(fs.readFile)("hello.txt");
}
I'm not sure about the name since promised
might come off as polarizing to callback users who would not want to be aware of the internals of async/await using promises.
Also, it's worth mentioning it doesn't have to return an actual promises but rather just a then
able since those are consumed by async/await
.