Skip to content

Commit 0e54f72

Browse files
committed
cjihrig's comments
1 parent 39bd08e commit 0e54f72

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

doc/api/util.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ added: REPLACEME
1818
* `original` {Function} An `async` function
1919
* Returns: {Function} a callback style function
2020

21-
This method converts Promise returning API endpoints to ones that use callbacks.
22-
`callbackify` takes an `async` function (or a function that returns a Promise)
23-
and returns a function following the common Node.js callback style, i.e. taking
24-
a `(err, val) => ...` callback as the last argument. In the callback, the first
25-
argument will be the rejection reason (or `null` if the Promise resolved), and
26-
the second argument will be the resolved value.
21+
Takes an `async` function (or a function that returns a Promise) and returns a
22+
function following the Node.js error first callback style. In the callback, the
23+
first argument will be the rejection reason (or `null` if the Promise resolved),
24+
and the second argument will be the resolved value.
2725

2826
For example:
2927

@@ -41,18 +39,17 @@ callbackFunction((err, ret) => {
4139
});
4240
```
4341

44-
Will print something like:
42+
Will print:
4543

4644
```txt
4745
hello world
4846
```
4947

5048
*Note*:
5149

52-
* Like with most callback style functions, the callback is executed in an
53-
async context (i.e. having a limited stacktrace). If the callback throws, the
54-
process will emit an [`'uncaughtException'`][] event, and if not handled will
55-
exit.
50+
* The callback is executed asynchronously, and will have a limited stack trace.
51+
If the callback throws, the process will emit an [`'uncaughtException'`][]
52+
event, and if not handled will exit.
5653

5754
* Since `null` has a special meaning as the first argument to a callback, if a
5855
wrapped function rejects a `Promise` with a falsy value as a reason, the value

test/fixtures/uncaught-exceptions/callbackify1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
const { callbackify } = require('util');
66

77
{
8-
async function fn3() { }
8+
async function fn() { }
99

10-
const cbFn = callbackify(fn3);
10+
const cbFn = callbackify(fn);
1111

1212
cbFn((err, ret) => {
1313
throw new Error(__filename);

test/fixtures/uncaught-exceptions/callbackify2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const { callbackify } = require('util');
1313
console.log(err.message);
1414
});
1515

16-
async function fn3() {
16+
async function fn() {
1717
return await Promise.reject(sentinel);
1818
}
1919

20-
const cbFn = callbackify(fn3);
20+
const cbFn = callbackify(fn);
2121
cbFn((err, ret) => assert.ifError(err));
2222
}

0 commit comments

Comments
 (0)