Skip to content

util: add util.callbackify()

Rodrigo Muino Tomonari requested to merge github/fork/refack/callbackify into master

This is a first draft of an implementation of util.callbackify(function). There is at least one issue that need ironing out: if and how to project the return value into multiple args...

Implementation inspired by @addaleax's #12442 Background discussion at: https://github.com/nodejs/CTC/issues/109

Open discussion

Should we allow customization of the wrapping?

  1. specifying a transform for the awaitable before the connection to the callback
  2. projection of the returned value
  3. tiying in the callback into the promise's life-cycle

Original commit descriptions

Add util.callbackify(function) for creating callback style functions

from functions returning a Promise/awaitable

Fixes: https://github.com/nodejs/CTC/issues/109

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

util

Merge request reports

Loading