From cc258af0e4898338b6be49ac79b49dc28169d0c9 Mon Sep 17 00:00:00 2001 From: Shiya Luo Date: Mon, 9 Oct 2017 18:46:14 -0700 Subject: [PATCH] doc: clarify usage of util.promisify.custom PR-URL: https://github.com/nodejs/node/pull/16134 Reviewed-By: Anna Henningsen Reviewed-By: Stephen Belanger Reviewed-By: Jeremiah Senkpiel Reviewed-By: Evan Lucas Reviewed-By: James M Snell --- doc/api/util.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/api/util.md b/doc/api/util.md index 2653c01af1d4c9..9cca721e63cc94 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -525,6 +525,16 @@ console.log(promisified === doSomething[util.promisify.custom]); This can be useful for cases where the original function does not follow the standard format of taking an error-first callback as the last argument. +For example, with a function that takes in `(foo, onSuccessCallback, onErrorCallback)`: + +```js +doSomething[util.promisify.custom] = function(foo) { + return new Promise(function(resolve, reject) { + doSomething(foo, resolve, reject); + }); +}; +``` + ### util.promisify.custom