diff options
author | Shiya Luo <luo.shiya@gmail.com> | 2017-10-10 04:46:14 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2017-10-18 09:31:49 +0300 |
commit | 55fa067a6d6e72b6f2250a1b7454c37bb60da3e8 (patch) | |
tree | e83b3eff8a2dd2f8fee657c316cc851b3745ad89 /doc | |
parent | ae0a00c8d4e188d08758db2f156d937718ff7221 (diff) |
doc: clarify usage of util.promisify.custom
PR-URL: https://github.com/nodejs/node/pull/16134
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/util.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/api/util.md b/doc/api/util.md index 2653c01af1d..9cca721e63c 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 <!-- YAML added: v8.0.0 |