util: add util.promisify()
See nodejs/CTC#12 for discussion/background. I would say that that thread is a better place for general discussion, and I prefer it if comments here would be kept to what is directly relevant for this PR.
CI: https://ci.nodejs.org/job/node-test-commit/9143/
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
Affected core subsystem(s)
util, timers
Original commit descriptions
util: add internal bindings for promise handling
Add methods for creating, resolving and rejecting promises using the V8 C++ API that does not require creation of extra resolve
and reject
functions to process.binding('util')
.
util: add util.promisify()
Add util.promisify(function)
for creating promisified functions.
Fixes: nodejs/CTC#12
timers: add promisify support
Add support for util.promisify(setTimeout)
and util.promisify(setImmediate)
as a proof-of-concept implementation. clearTimeout()
and clearImmediate()
resolve the promise immediately instead of rejecting it; that might be the most opinionated choice about this.
/cc @chrisdickinson @benjamingr @Fishrock123 @nodejs/ctc
edit: CTC voting comment