Skip to content

Commit 56c27c6

Browse files
vsemozhetbytMylesBorins
authored andcommitted
doc: add more missing backticks
Also, fix some other nits in passing (formatting, punctuation, typos, redundancy, obsoleteness). PR-URL: #20438 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent ad793ab commit 56c27c6

35 files changed

+642
-640
lines changed

doc/api/addons.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ just as if they were an ordinary Node.js module. They are used primarily to
99
provide an interface between JavaScript running in Node.js and C/C++ libraries.
1010

1111
At the moment, the method for implementing Addons is rather complicated,
12-
involving knowledge of several components and APIs :
12+
involving knowledge of several components and APIs:
1313

1414
- V8: the C++ library Node.js currently uses to provide the
1515
JavaScript implementation. V8 provides the mechanisms for creating objects,
@@ -93,7 +93,7 @@ There is no semi-colon after `NODE_MODULE` as it's not a function (see
9393
`node.h`).
9494

9595
The `module_name` must match the filename of the final binary (excluding
96-
the .node suffix).
96+
the `.node` suffix).
9797

9898
In the `hello.cc` example, then, the initialization function is `init` and the
9999
Addon module name is `addon`.
@@ -1085,9 +1085,9 @@ console.log(result);
10851085

10861086
### AtExit hooks
10871087

1088-
An "AtExit" hook is a function that is invoked after the Node.js event loop
1088+
An `AtExit` hook is a function that is invoked after the Node.js event loop
10891089
has ended but before the JavaScript VM is terminated and Node.js shuts down.
1090-
"AtExit" hooks are registered using the `node::AtExit` API.
1090+
`AtExit` hooks are registered using the `node::AtExit` API.
10911091

10921092
#### void AtExit(callback, args)
10931093

@@ -1099,12 +1099,12 @@ has ended but before the JavaScript VM is terminated and Node.js shuts down.
10991099
Registers exit hooks that run after the event loop has ended but before the VM
11001100
is killed.
11011101

1102-
AtExit takes two parameters: a pointer to a callback function to run at exit,
1102+
`AtExit` takes two parameters: a pointer to a callback function to run at exit,
11031103
and a pointer to untyped context data to be passed to that callback.
11041104

11051105
Callbacks are run in last-in first-out order.
11061106

1107-
The following `addon.cc` implements AtExit:
1107+
The following `addon.cc` implements `AtExit`:
11081108

11091109
```cpp
11101110
// addon.cc

doc/api/assert.md

+26-25
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ added: v0.1.21
165165
changes:
166166
- version: v9.0.0
167167
pr-url: https://github.com/nodejs/node/pull/15001
168-
description: Error names and messages are now properly compared
168+
description: The `Error` names and messages are now properly compared
169169
- version: v8.0.0
170170
pr-url: https://github.com/nodejs/node/pull/12142
171-
description: Set and Map content is also compared
171+
description: The `Set` and `Map` content is also compared
172172
- version: v6.4.0, v4.7.1
173173
pr-url: https://github.com/nodejs/node/pull/8002
174174
description: Typed array slices are handled correctly now.
@@ -208,7 +208,7 @@ the [`RegExp`][] object are not enumerable:
208208
assert.deepEqual(/a/gi, new Date());
209209
```
210210

211-
An exception is made for [`Map`][] and [`Set`][]. Maps and Sets have their
211+
An exception is made for [`Map`][] and [`Set`][]. `Map`s and `Set`s have their
212212
contained items compared too, as expected.
213213

214214
"Deep" equality means that the enumerable "own" properties of child objects
@@ -264,15 +264,15 @@ changes:
264264
description: Enumerable symbol properties are now compared.
265265
- version: v9.0.0
266266
pr-url: https://github.com/nodejs/node/pull/15036
267-
description: NaN is now compared using the
267+
description: The `NaN` is now compared using the
268268
[SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero)
269269
comparison.
270270
- version: v8.5.0
271271
pr-url: https://github.com/nodejs/node/pull/15001
272-
description: Error names and messages are now properly compared
272+
description: The `Error` names and messages are now properly compared
273273
- version: v8.0.0
274274
pr-url: https://github.com/nodejs/node/pull/12142
275-
description: Set and Map content is also compared
275+
description: The `Set` and `Map` content is also compared
276276
- version: v6.4.0, v4.7.1
277277
pr-url: https://github.com/nodejs/node/pull/8002
278278
description: Typed array slices are handled correctly now.
@@ -303,8 +303,8 @@ are recursively evaluated also by the following rules.
303303
enumerable properties.
304304
* Enumerable own [`Symbol`][] properties are compared as well.
305305
* [Object wrappers][] are compared both as objects and unwrapped values.
306-
* Object properties are compared unordered.
307-
* Map keys and Set items are compared unordered.
306+
* `Object` properties are compared unordered.
307+
* `Map` keys and `Set` items are compared unordered.
308308
* Recursion stops when both sides differ or both sides encounter a circular
309309
reference.
310310
* [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values. See
@@ -413,10 +413,10 @@ function and awaits the returned promise to complete. It will then check that
413413
the promise is not rejected.
414414

415415
If `block` is a function and it throws an error synchronously,
416-
`assert.doesNotReject()` will return a rejected Promise with that error. If the
417-
function does not return a promise, `assert.doesNotReject()` will return a
418-
rejected Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the
419-
error handler is skipped.
416+
`assert.doesNotReject()` will return a rejected `Promise` with that error. If
417+
the function does not return a promise, `assert.doesNotReject()` will return a
418+
rejected `Promise` with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases
419+
the error handler is skipped.
420420

421421
Please note: Using `assert.doesNotReject()` is actually not useful because there
422422
is little benefit by catching a rejection and then rejecting it again. Instead,
@@ -494,7 +494,7 @@ assert.doesNotThrow(
494494
```
495495

496496
However, the following will result in an `AssertionError` with the message
497-
'Got unwanted exception (TypeError)..':
497+
'Got unwanted exception...':
498498

499499
<!-- eslint-disable no-restricted-syntax -->
500500
```js
@@ -519,7 +519,7 @@ assert.doesNotThrow(
519519
/Wrong value/,
520520
'Whoops'
521521
);
522-
// Throws: AssertionError: Got unwanted exception (TypeError). Whoops
522+
// Throws: AssertionError: Got unwanted exception: Whoops
523523
```
524524

525525
## assert.equal(actual, expected[, message])
@@ -656,7 +656,7 @@ changes:
656656
- version: v10.0.0
657657
pr-url: https://github.com/nodejs/node/pull/18247
658658
description: Instead of throwing the original error it is now wrapped into
659-
a AssertionError that contains the full stack trace.
659+
an `AssertionError` that contains the full stack trace.
660660
- version: v10.0.0
661661
pr-url: https://github.com/nodejs/node/pull/18247
662662
description: Value may now only be `undefined` or `null`. Before any truthy
@@ -701,10 +701,10 @@ added: v0.1.21
701701
changes:
702702
- version: v9.0.0
703703
pr-url: https://github.com/nodejs/node/pull/15001
704-
description: Error names and messages are now properly compared
704+
description: The `Error` names and messages are now properly compared
705705
- version: v8.0.0
706706
pr-url: https://github.com/nodejs/node/pull/12142
707-
description: Set and Map content is also compared
707+
description: The `Set` and `Map` content is also compared
708708
- version: v6.4.0, v4.7.1
709709
pr-url: https://github.com/nodejs/node/pull/8002
710710
description: Typed array slices are handled correctly now.
@@ -774,18 +774,18 @@ added: v1.2.0
774774
changes:
775775
- version: v9.0.0
776776
pr-url: https://github.com/nodejs/node/pull/15398
777-
description: -0 and +0 are not considered equal anymore.
777+
description: The `-0` and `+0` are not considered equal anymore.
778778
- version: v9.0.0
779779
pr-url: https://github.com/nodejs/node/pull/15036
780-
description: NaN is now compared using the
780+
description: The `NaN` is now compared using the
781781
[SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero)
782782
comparison.
783783
- version: v9.0.0
784784
pr-url: https://github.com/nodejs/node/pull/15001
785-
description: Error names and messages are now properly compared
785+
description: The `Error` names and messages are now properly compared
786786
- version: v8.0.0
787787
pr-url: https://github.com/nodejs/node/pull/12142
788-
description: Set and Map content is also compared
788+
description: The `Set` and `Map` content is also compared
789789
- version: v6.4.0, v4.7.1
790790
pr-url: https://github.com/nodejs/node/pull/8002
791791
description: Typed array slices are handled correctly now.
@@ -893,7 +893,8 @@ added: v0.1.21
893893
changes:
894894
- version: v10.0.0
895895
pr-url: https://github.com/nodejs/node/pull/18319
896-
description: assert.ok() (no arguments) will now use a predefined error msg.
896+
description: The `assert.ok()` (no arguments) will now use a predefined
897+
error message.
897898
-->
898899
* `value` {any}
899900
* `message` {any}
@@ -907,7 +908,7 @@ parameter is `undefined`, a default error message is assigned. If the `message`
907908
parameter is an instance of an [`Error`][] then it will be thrown instead of the
908909
`AssertionError`.
909910
If no arguments are passed in at all `message` will be set to the string:
910-
"No value argument passed to assert.ok".
911+
``'No value argument passed to `assert.ok()`'``.
911912

912913
Be aware that in the `repl` the error message will be different to the one
913914
thrown in a file! See below for further details.
@@ -966,9 +967,9 @@ function and awaits the returned promise to complete. It will then check that
966967
the promise is rejected.
967968

968969
If `block` is a function and it throws an error synchronously,
969-
`assert.rejects()` will return a rejected Promise with that error. If the
970+
`assert.rejects()` will return a rejected `Promise` with that error. If the
970971
function does not return a promise, `assert.rejects()` will return a rejected
971-
Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error
972+
`Promise` with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error
972973
handler is skipped.
973974

974975
Besides the async nature to await the completion behaves identically to

doc/api/async_hooks.md

+25-23
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const async_hooks = require('async_hooks');
1717
An asynchronous resource represents an object with an associated callback.
1818
This callback may be called multiple times, for example, the `'connection'`
1919
event in `net.createServer()`, or just a single time like in `fs.open()`.
20-
A resource can also be closed before the callback is called. AsyncHook does not
21-
explicitly distinguish between these different cases but will represent them
20+
A resource can also be closed before the callback is called. `AsyncHook` does
21+
not explicitly distinguish between these different cases but will represent them
2222
as the abstract concept that is a resource.
2323

2424
## Public API
@@ -188,7 +188,7 @@ const hook = async_hooks.createHook(callbacks).enable();
188188
* Returns: {AsyncHook} A reference to `asyncHook`.
189189

190190
Disable the callbacks for a given `AsyncHook` instance from the global pool of
191-
AsyncHook callbacks to be executed. Once a hook has been disabled it will not
191+
`AsyncHook` callbacks to be executed. Once a hook has been disabled it will not
192192
be called again until enabled.
193193

194194
For API consistency `disable()` also returns the `AsyncHook` instance.
@@ -299,10 +299,10 @@ and document their own resource objects. For example, such a resource object
299299
could contain the SQL query being executed.
300300

301301
In the case of Promises, the `resource` object will have `promise` property
302-
that refers to the Promise that is being initialized, and a `isChainedPromise`
303-
property, set to `true` if the promise has a parent promise, and `false`
304-
otherwise. For example, in the case of `b = a.then(handler)`, `a` is considered
305-
a parent Promise of `b`. Here, `b` is considered a chained promise.
302+
that refers to the `Promise` that is being initialized, and an
303+
`isChainedPromise` property, set to `true` if the promise has a parent promise,
304+
and `false` otherwise. For example, in the case of `b = a.then(handler)`, `a` is
305+
considered a parent `Promise` of `b`. Here, `b` is considered a chained promise.
306306

307307
In some cases the resource object is reused for performance reasons, it is
308308
thus not safe to use it as a key in a `WeakMap` or add properties to it.
@@ -466,7 +466,7 @@ added: v8.1.0
466466
changes:
467467
- version: v8.2.0
468468
pr-url: https://github.com/nodejs/node/pull/13490
469-
description: Renamed from currentId
469+
description: Renamed from `currentId`
470470
-->
471471

472472
* Returns: {number} The `asyncId` of the current execution context. Useful to
@@ -498,7 +498,7 @@ const server = net.createServer(function onConnection(conn) {
498498
});
499499
```
500500

501-
Note that promise contexts may not get precise executionAsyncIds by default.
501+
Note that promise contexts may not get precise `executionAsyncIds` by default.
502502
See the section on [promise execution tracking][].
503503

504504
#### async_hooks.triggerAsyncId()
@@ -521,12 +521,12 @@ const server = net.createServer((conn) => {
521521
});
522522
```
523523

524-
Note that promise contexts may not get valid triggerAsyncIds by default. See
524+
Note that promise contexts may not get valid `triggerAsyncId`s by default. See
525525
the section on [promise execution tracking][].
526526

527527
## Promise execution tracking
528528

529-
By default, promise executions are not assigned asyncIds due to the relatively
529+
By default, promise executions are not assigned `asyncId`s due to the relatively
530530
expensive nature of the [promise introspection API][PromiseHooks] provided by
531531
V8. This means that programs using promises or `async`/`await` will not get
532532
correct execution and trigger ids for promise callback contexts by default.
@@ -542,10 +542,10 @@ Promise.resolve(1729).then(() => {
542542
// eid 1 tid 0
543543
```
544544

545-
Observe that the `then` callback claims to have executed in the context of the
545+
Observe that the `then()` callback claims to have executed in the context of the
546546
outer scope even though there was an asynchronous hop involved. Also note that
547-
the triggerAsyncId value is 0, which means that we are missing context about the
548-
resource that caused (triggered) the `then` callback to be executed.
547+
the `triggerAsyncId` value is `0`, which means that we are missing context about
548+
the resource that caused (triggered) the `then()` callback to be executed.
549549

550550
Installing async hooks via `async_hooks.createHook` enables promise execution
551551
tracking. Example:
@@ -562,15 +562,16 @@ Promise.resolve(1729).then(() => {
562562

563563
In this example, adding any actual hook function enabled the tracking of
564564
promises. There are two promises in the example above; the promise created by
565-
`Promise.resolve()` and the promise returned by the call to `then`. In the
566-
example above, the first promise got the asyncId 6 and the latter got asyncId 7.
567-
During the execution of the `then` callback, we are executing in the context of
568-
promise with asyncId 7. This promise was triggered by async resource 6.
565+
`Promise.resolve()` and the promise returned by the call to `then()`. In the
566+
example above, the first promise got the `asyncId` `6` and the latter got
567+
`asyncId` `7`. During the execution of the `then()` callback, we are executing
568+
in the context of promise with `asyncId` `7`. This promise was triggered by
569+
async resource `6`.
569570

570571
Another subtlety with promises is that `before` and `after` callbacks are run
571-
only on chained promises. That means promises not created by `then`/`catch` will
572-
not have the `before` and `after` callbacks fired on them. For more details see
573-
the details of the V8 [PromiseHooks][] API.
572+
only on chained promises. That means promises not created by `then()`/`catch()`
573+
will not have the `before` and `after` callbacks fired on them. For more details
574+
see the details of the V8 [PromiseHooks][] API.
574575

575576
## JavaScript Embedder API
576577

@@ -632,8 +633,9 @@ asyncResource.emitAfter();
632633
async event. **Default:** `executionAsyncId()`.
633634
* `requireManualDestroy` {boolean} Disables automatic `emitDestroy` when the
634635
object is garbage collected. This usually does not need to be set (even if
635-
`emitDestroy` is called manually), unless the resource's asyncId is retrieved
636-
and the sensitive API's `emitDestroy` is called with it. **Default:** `false`.
636+
`emitDestroy` is called manually), unless the resource's `asyncId` is
637+
retrieved and the sensitive API's `emitDestroy` is called with it.
638+
**Default:** `false`.
637639

638640
Example usage:
639641

0 commit comments

Comments
 (0)