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>
This commit is contained in:
parent
8d3e82fd6c
commit
cc258af0e4
@ -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
|
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.
|
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
|
### util.promisify.custom
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v8.0.0
|
added: v8.0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user