Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: remove style, update callbackify
  • Loading branch information
lossycache committed Dec 13, 2017
commit 5fc61ad1a1d33de85c0d5d8449a28e78ba34e262
6 changes: 3 additions & 3 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ they are thrown *after* the calling code has already exited.
Developers must refer to the documentation for each method to determine
exactly how errors raised by those methods are propagated.

### Error-first style callbacks
### Error-first callbacks

<!--type=misc-->

Most asynchronous methods exposed by the Node.js core API follow an idiomatic
pattern referred to as an "error-first style callback". With this pattern, a
pattern referred to as an _error-first callback_. With this pattern, a
callback function is passed to the method as an argument. When the operation
either completes or an error is raised, the callback function is called with
the Error object (if any) passed as the first argument. If no error was raised,
Expand All @@ -156,7 +156,7 @@ fs.readFile('/some/file/that/does-exist', errorFirstStyleCallback);

The JavaScript `try / catch` mechanism **cannot** be used to intercept errors
generated by asynchronous APIs. A common mistake for beginners is to try to
use `throw` inside an error-first style callback:
use `throw` inside an error-first callback:

```js
// THIS WILL NOT WORK:
Expand Down
13 changes: 7 additions & 6 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ added: v8.2.0
* Returns: {Function} a callback style function

Takes an `async` function (or a function that returns a Promise) and returns a
function following the Node.js error first callback style. In the callback, the
first argument will be the rejection reason (or `null` if the Promise resolved),
and the second argument will be the resolved value.
function following the error-first callback style, i.e. taking
a `(err, value) => ...` callback as the last argument. In the callback, the
first argument will be the rejection reason (or `null` if the Promise
resolved), and the second argument will be the resolved value.

For example:

Expand Down Expand Up @@ -517,8 +518,8 @@ added: v8.0.0
* `original` {Function}
* Returns: {Function}

Takes a function following the common error-first style callback, i.e. taking a
`(err, value) => ...` callback as the last argument, and returns a version
Takes a function following the common error-first callback style, i.e. taking
a `(err, value) => ...` callback as the last argument, and returns a version
that returns promises.

For example:
Expand Down Expand Up @@ -555,7 +556,7 @@ 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. If `original` is not a function, `promisify()`
will throw an error. If `original` is a function but its last argument is not
an error-first style callback, it will still be passed an error-first style
an error-first callback, it will still be passed an error-first
callback as its last argument.

### Custom promisified functions
Expand Down