Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add quotes for event names + fix similar nits #19915

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ added: v0.1.21
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18418
description: Calling `assert.fail` with more than one argument is deprecated
and emits a warning.
description: Calling `assert.fail()` with more than one argument is
deprecated and emits a warning.
-->
* `actual` {any}
* `expected` {any}
Expand Down
8 changes: 4 additions & 4 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const async_hooks = require('async_hooks');
## Terminology

An asynchronous resource represents an object with an associated callback.
This callback may be called multiple times, for example, the `connection` event
in `net.createServer`, or just a single time like in `fs.open`. A resource
can also be closed before the callback is called. AsyncHook does not
This callback may be called multiple times, for example, the `'connection'`
event in `net.createServer()`, or just a single time like in `fs.open()`.
A resource can also be closed before the callback is called. AsyncHook does not
explicitly distinguish between these different cases but will represent them
as the abstract concept that is a resource.

Expand Down Expand Up @@ -128,7 +128,7 @@ const asyncHook = async_hooks.createHook(new MyAddedCallbacks());

If any `AsyncHook` callbacks throw, the application will print the stack trace
and exit. The exit path does follow that of an uncaught exception, but
all `uncaughtException` listeners are removed, thus forcing the process to
all `'uncaughtException'` listeners are removed, thus forcing the process to
exit. The `'exit'` callbacks will still be called unless the application is run
with `--abort-on-uncaught-exception`, in which case a stack trace will be
printed and the application exits, leaving a core file.
Expand Down
22 changes: 10 additions & 12 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,8 @@ pipes between the parent and child. The value is one of the following:
between parent and child. A [`ChildProcess`][] may have at most *one* IPC stdio
file descriptor. Setting this option enables the [`subprocess.send()`][]
method. If the child is a Node.js process, the presence of an IPC channel
will enable [`process.send()`][], [`process.disconnect()`][],
[`process.on('disconnect')`][], and [`process.on('message')`] within the
child.
will enable [`process.send()`][] and [`process.disconnect()`][] methods,
as well as [`'disconnect'`][] and [`'message'`][] events within the child.

Accessing the IPC channel fd in any way other than [`process.send()`][]
or using the IPC channel with a child process that is not a Node.js instance
Expand Down Expand Up @@ -651,8 +650,8 @@ spawn('prg', [], { stdio: ['pipe', null, null, null, 'pipe'] });
*It is worth noting that when an IPC channel is established between the
parent and child processes, and the child is a Node.js process, the child
is launched with the IPC channel unreferenced (using `unref()`) until the
child registers an event handler for the [`process.on('disconnect')`][] event
or the [`process.on('message')`][] event. This allows the child to exit
child registers an event handler for the [`'disconnect'`][] event
or the [`'message'`][] event. This allows the child to exit
normally without the process being held open by the open IPC channel.*

See also: [`child_process.exec()`][] and [`child_process.fork()`][]
Expand Down Expand Up @@ -1103,8 +1102,7 @@ changes:
When an IPC channel has been established between the parent and child (
i.e. when using [`child_process.fork()`][]), the `subprocess.send()` method can
be used to send messages to the child process. When the child process is a
Node.js instance, these messages can be received via the
[`process.on('message')`][] event.
Node.js instance, these messages can be received via the [`'message'`][] event.

The message goes through serialization and parsing. The resulting
message might not be the same as what is originally sent.
Expand Down Expand Up @@ -1139,16 +1137,16 @@ allows the child to send messages back to the parent.

There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages
containing a `NODE_` prefix in the `cmd` property are reserved for use within
Node.js core and will not be emitted in the child's [`process.on('message')`][]
Node.js core and will not be emitted in the child's [`'message'`][]
event. Rather, such messages are emitted using the
`process.on('internalMessage')` event and are consumed internally by Node.js.
`'internalMessage'` event and are consumed internally by Node.js.
Applications should avoid using such messages or listening for
`'internalMessage'` events as it is subject to change without notice.

The optional `sendHandle` argument that may be passed to `subprocess.send()` is
for passing a TCP server or socket object to the child process. The child will
receive the object as the second argument passed to the callback function
registered on the [`process.on('message')`][] event. Any data that is received
registered on the [`'message'`][] event. Any data that is received
and buffered in the socket will not be sent to the child.

The optional `callback` is a function that is invoked after the message is
Expand Down Expand Up @@ -1363,8 +1361,10 @@ the same requirement. Thus, in `child_process` functions where a shell can be
spawned, `'cmd.exe'` is used as a fallback if `process.env.ComSpec` is
unavailable.

[`'disconnect'`]: process.html#process_event_disconnect
[`'error'`]: #child_process_event_error
[`'exit'`]: #child_process_event_exit
[`'message'`]: process.html#process_event_message
[`ChildProcess`]: #child_process_child_process
[`Error`]: errors.html#errors_class_error
[`EventEmitter`]: events.html#events_class_eventemitter
Expand All @@ -1389,8 +1389,6 @@ unavailable.
[`process.disconnect()`]: process.html#process_process_disconnect
[`process.env`]: process.html#process_process_env
[`process.execPath`]: process.html#process_process_execpath
[`process.on('disconnect')`]: process.html#process_event_disconnect
[`process.on('message')`]: process.html#process_event_message
[`process.send()`]: process.html#process_process_send_message_sendhandle_options_callback
[`stdio`]: #child_process_options_stdio
[`util.promisify()`]: util.html#util_util_promisify_original
Expand Down
14 changes: 7 additions & 7 deletions doc/api/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ added: v0.7.0
* `message` {Object}
* `handle` {undefined|Object}

Similar to the `cluster.on('message')` event, but specific to this worker.
Similar to the `'message'` event of `cluster`, but specific to this worker.

Within a worker, `process.on('message')` may also be used.

Expand Down Expand Up @@ -463,7 +463,7 @@ added: v0.7.9

Emitted after the worker IPC channel has disconnected. This can occur when a
worker exits gracefully, is killed, or is disconnected manually (such as with
worker.disconnect()).
`worker.disconnect()`).

There may be a delay between the `'disconnect'` and `'exit'` events. These
events can be used to detect if the process is stuck in a cleanup or if there
Expand Down Expand Up @@ -497,7 +497,7 @@ cluster.on('exit', (worker, code, signal) => {
});
```

See [child_process event: 'exit'][].
See [child_process event: `'exit'`][].

## Event: 'fork'
<!-- YAML
Expand Down Expand Up @@ -573,7 +573,7 @@ changes:

Emitted when the cluster master receives a message from any worker.

See [child_process event: 'message'][].
See [child_process event: `'message'`][].

Before Node.js v6.0, this event emitted only the message and the handle,
but not the worker object, contrary to what the documentation stated.
Expand Down Expand Up @@ -603,7 +603,7 @@ added: v0.7.0
After forking a new worker, the worker should respond with an online message.
When the master receives an online message it will emit this event.
The difference between `'fork'` and `'online'` is that fork is emitted when the
master forks a worker, and 'online' is emitted when the worker is running.
master forks a worker, and `'online'` is emitted when the worker is running.

```js
cluster.on('online', (worker) => {
Expand Down Expand Up @@ -846,6 +846,6 @@ socket.on('data', (id) => {
[`server.close()`]: net.html#net_event_close
[`worker.exitedAfterDisconnect`]: #cluster_worker_exitedafterdisconnect
[Child Process module]: child_process.html#child_process_child_process_fork_modulepath_args_options
[child_process event: 'exit']: child_process.html#child_process_event_exit
[child_process event: 'message']: child_process.html#child_process_event_message
[child_process event: `'exit'`]: child_process.html#child_process_event_exit
[child_process event: `'message'`]: child_process.html#child_process_event_message
[`cluster.settings`]: #cluster_cluster_settings
2 changes: 1 addition & 1 deletion doc/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ added: v8.0.0
* `label` {string}

This method does not display anything unless used in the inspector. The
`console.timeStamp()` method adds an event with the label `label` to the
`console.timeStamp()` method adds an event with the label `'label'` to the
**Timeline** panel of the inspector.

### console.timeline([label])
Expand Down
2 changes: 1 addition & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ API instead.

Type: End-of-Life

`runInAsyncIdScope` doesn't emit the `before` or `after` event and can thus
`runInAsyncIdScope` doesn't emit the `'before'` or `'after'` event and can thus
cause a lot of issues. See https://github.com/nodejs/node/issues/14328 for more
details.

Expand Down
6 changes: 3 additions & 3 deletions doc/api/dgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,13 +605,13 @@ and port can be retrieved using [`socket.address().address`][] and
added: v0.1.99
-->

* `type` {string} - Either 'udp4' or 'udp6'.
* `type` {string} - Either `'udp4'` or `'udp6'`.
* `callback` {Function} - Attached as a listener to `'message'` events.
* Returns: {dgram.Socket}

Creates a `dgram.Socket` object of the specified `type`. The `type` argument
can be either `udp4` or `udp6`. An optional `callback` function can be passed
which is added as a listener for `'message'` events.
can be either `'udp4'` or `'udp6'`. An optional `callback` function can be
passed which is added as a listener for `'message'` events.

Once the socket is created, calling [`socket.bind()`][] will instruct the
socket to begin listening for datagram messages. When `address` and `port` are
Expand Down
8 changes: 4 additions & 4 deletions doc/api/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ failures or behavior changes when API modifications occur. To help avoid such
surprises, `Experimental` features may require a command-line flag to
explicitly enable them, or may cause a process warning to be emitted.
By default, such warnings are printed to [`stderr`][] and may be handled by
attaching a listener to the [`process.on('warning')`][] event.
attaching a listener to the [`'warning'`][] event.

## JSON Output
<!-- YAML
Expand Down Expand Up @@ -94,9 +94,9 @@ relative to Linux and macOS. For an example of the subtle ways in which it's
sometimes impossible to replace Unix syscall semantics on Windows, see [Node
issue 4760](https://github.com/nodejs/node/issues/4760).

[submit an issue]: https://github.com/nodejs/node/issues/new
[the contributing guide]: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md
[`'warning'`]: process.html#process_event_warning
[`stderr`]: process.html#process_process_stderr
[`process.on('warning')`]: process.html#process_event_warning
[`fs.open()`]: fs.html#fs_fs_open_path_flags_mode_callback
[`fs.lchown()`]: fs.html#fs_fs_lchown_path_uid_gid_callback
[submit an issue]: https://github.com/nodejs/node/issues/new
[the contributing guide]: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md
30 changes: 15 additions & 15 deletions doc/api/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ binding.

This also works with timers that are returned from [`setInterval()`][] and
[`setTimeout()`][]. If their callback function throws, it will be caught by
the domain 'error' handler.
the domain `'error'` handler.

If the Timer or EventEmitter was already bound to a domain, it is removed
from that one, and bound to this one instead.
Expand Down Expand Up @@ -334,30 +334,30 @@ d.on('error', (er) => {

### domain.enter()

The `enter` method is plumbing used by the `run`, `bind`, and `intercept`
methods to set the active domain. It sets `domain.active` and `process.domain`
to the domain, and implicitly pushes the domain onto the domain stack managed
by the domain module (see [`domain.exit()`][] for details on the domain stack).
The call to `enter` delimits the beginning of a chain of asynchronous calls and
I/O operations bound to a domain.
The `enter()` method is plumbing used by the `run()`, `bind()`, and
`intercept()` methods to set the active domain. It sets `domain.active` and
`process.domain` to the domain, and implicitly pushes the domain onto the domain
stack managed by the domain module (see [`domain.exit()`][] for details on the
domain stack). The call to `enter()` delimits the beginning of a chain of
asynchronous calls and I/O operations bound to a domain.

Calling `enter` changes only the active domain, and does not alter the domain
itself. `enter` and `exit` can be called an arbitrary number of times on a
Calling `enter()` changes only the active domain, and does not alter the domain
itself. `enter()` and `exit()` can be called an arbitrary number of times on a
single domain.

### domain.exit()

The `exit` method exits the current domain, popping it off the domain stack.
The `exit()` method exits the current domain, popping it off the domain stack.
Any time execution is going to switch to the context of a different chain of
asynchronous calls, it's important to ensure that the current domain is exited.
The call to `exit` delimits either the end of or an interruption to the chain
The call to `exit()` delimits either the end of or an interruption to the chain
of asynchronous calls and I/O operations bound to a domain.

If there are multiple, nested domains bound to the current execution context,
`exit` will exit any domains nested within this domain.
`exit()` will exit any domains nested within this domain.

Calling `exit` changes only the active domain, and does not alter the domain
itself. `enter` and `exit` can be called an arbitrary number of times on a
Calling `exit()` changes only the active domain, and does not alter the domain
itself. `enter()` and `exit()` can be called an arbitrary number of times on a
single domain.

### domain.intercept(callback)
Expand Down Expand Up @@ -481,7 +481,7 @@ d2.run(() => {
```

Note that domains will not interfere with the error handling mechanisms for
Promises, i.e. no `error` event will be emitted for unhandled Promise
Promises, i.e. no `'error'` event will be emitted for unhandled Promise
rejections.

[`Error`]: errors.html#errors_class_error
Expand Down
6 changes: 3 additions & 3 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ For *all* [`EventEmitter`][] objects, if an `'error'` event handler is not
provided, the error will be thrown, causing the Node.js process to report an
unhandled exception and crash unless either: The [`domain`][domains] module is
used appropriately or a handler has been registered for the
[`process.on('uncaughtException')`][] event.
[`'uncaughtException'`][] event.

```js
const EventEmitter = require('events');
Expand Down Expand Up @@ -1438,7 +1438,7 @@ An attempt was made to use a readable stream that did not implement
<a id="ERR_STREAM_UNSHIFT_AFTER_END_EVENT"></a>
### ERR_STREAM_UNSHIFT_AFTER_END_EVENT

An attempt was made to call [`stream.unshift()`][] after the `end` event was
An attempt was made to call [`stream.unshift()`][] after the `'end'` event was
emitted.

<a id="ERR_STREAM_WRAP"></a>
Expand Down Expand Up @@ -1656,6 +1656,7 @@ meaning of the error depends on the specific function.

Creation of a [`zlib`][] object failed due to incorrect configuration.

[`'uncaughtException'`]: process.html#process_event_uncaughtexception
[`--force-fips`]: cli.html#cli_force_fips
[`child_process`]: child_process.html
[`cipher.getAuthTag()`]: crypto.html#crypto_cipher_getauthtag
Expand Down Expand Up @@ -1687,7 +1688,6 @@ Creation of a [`zlib`][] object failed due to incorrect configuration.
[`net`]: net.html
[`new URL(input)`]: url.html#url_constructor_new_url_input_base
[`new URLSearchParams(iterable)`]: url.html#url_constructor_new_urlsearchparams_iterable
[`process.on('uncaughtException')`]: process.html#process_event_uncaughtexception
[`process.send()`]: process.html#process_process_send_message_sendhandle_options_callback
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
[`require('crypto').setEngine()`]: crypto.html#crypto_crypto_setengine_engine_flags
Expand Down
8 changes: 4 additions & 4 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ server.on('connection', callback);
server.removeListener('connection', callback);
```

`removeListener` will remove, at most, one instance of a listener from the
`removeListener()` will remove, at most, one instance of a listener from the
listener array. If any single listener has been added multiple times to the
listener array for the specified `eventName`, then `removeListener` must be
listener array for the specified `eventName`, then `removeListener()` must be
called multiple times to remove each instance.

Note that once an event has been emitted, all listeners attached to it at the
Expand Down Expand Up @@ -596,7 +596,7 @@ added: v9.4.0
- Returns: {Function[]}

Returns a copy of the array of listeners for the event named `eventName`,
including any wrappers (such as those created by `.once`).
including any wrappers (such as those created by `.once()`).

```js
const emitter = new EventEmitter();
Expand All @@ -614,7 +614,7 @@ logFnWrapper.listener();
logFnWrapper();

emitter.on('log', () => console.log('log persistently'));
// will return a new Array with a single function bound by `on` above
// will return a new Array with a single function bound by `.on()` above
const newListeners = emitter.rawListeners('log');

// logs "log persistently" twice
Expand Down
6 changes: 3 additions & 3 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ support. If `filename` is provided, it will be provided as a `Buffer` if
`filename` will be a UTF-8 string.

```js
// Example when handled through fs.watch listener
// Example when handled through fs.watch() listener
fs.watch('./tmp', { encoding: 'buffer' }, (eventType, filename) => {
if (filename) {
console.log(filename);
Expand Down Expand Up @@ -1323,7 +1323,7 @@ to [`net.Socket`][].
If `autoClose` is false, then the file descriptor won't be closed, even if
there's an error. It is the application's responsibility to close it and make
sure there's no file descriptor leak. If `autoClose` is set to true (default
behavior), on `error` or `end` the file descriptor will be closed
behavior), on `'error'` or `'end'` the file descriptor will be closed
automatically.

`mode` sets the file mode (permission and sticky bits), but only if the
Expand Down Expand Up @@ -1386,7 +1386,7 @@ than replacing it may require a `flags` mode of `r+` rather than the
default mode `w`. The `encoding` can be any one of those accepted by
[`Buffer`][].

If `autoClose` is set to true (default behavior) on `error` or `end`
If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`
the file descriptor will be closed automatically. If `autoClose` is false,
then the file descriptor won't be closed, even if there's an error.
It is the application's responsibility to close it and make sure there's no
Expand Down
Loading