Skip to content

Commit

Permalink
doc: clearify promisify behavior for bad arguments
Browse files Browse the repository at this point in the history
Currently the documentation states that promisify() will result in
undefined behavior if bad arguments are passed. This is not
necessarily the case, since the behavior is well defined, but just
not useful.

PR-URL: #17593
Fixes: #17569
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
ramsgoli authored and MylesBorins committed Jan 22, 2018
1 parent 0e20443 commit 24e7753
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions doc/api/util.md
Expand Up @@ -499,8 +499,10 @@ If there is an `original[util.promisify.custom]` property present, `promisify`
will return its value, see [Custom promisified functions][].

`promisify()` assumes that `original` is a function taking a callback as its
final argument in all cases, and the returned function will result in undefined
behavior if it does not.
final argument in all cases. If `original` is not a function, `promisify()`
will throw an error. If `original` is a function but its last argument is not a
Node.js style callback, it will still be passed a Node.js style callback
as its last argument.

### Custom promisified functions

Expand Down Expand Up @@ -535,6 +537,8 @@ doSomething[util.promisify.custom] = (foo) => {
});
};
```
If `promisify.custom` is defined but is not a function, `promisify()` will
throw an error.

### util.promisify.custom
<!-- YAML
Expand Down

0 comments on commit 24e7753

Please sign in to comment.