doc: add missing periods or colons
Some other formatting nits were fixed and some superfluous descriptions were simplified in passing. PR-URL: https://github.com/nodejs/node/pull/20401 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
536b1fbd3f
commit
392d80a617
@ -2458,7 +2458,7 @@ added: v3.0.0
|
|||||||
|
|
||||||
* {integer} The largest size allowed for a single `Buffer` instance.
|
* {integer} The largest size allowed for a single `Buffer` instance.
|
||||||
|
|
||||||
An alias for [`buffer.constants.MAX_LENGTH`][]
|
An alias for [`buffer.constants.MAX_LENGTH`][].
|
||||||
|
|
||||||
Note that this is a property on the `buffer` module returned by
|
Note that this is a property on the `buffer` module returned by
|
||||||
`require('buffer')`, not on the `Buffer` global or a `Buffer` instance.
|
`require('buffer')`, not on the `Buffer` global or a `Buffer` instance.
|
||||||
|
@ -652,7 +652,7 @@ child registers an event handler for the [`'disconnect'`][] event
|
|||||||
or the [`'message'`][] event. This allows the child to exit
|
or the [`'message'`][] event. This allows the child to exit
|
||||||
normally without the process being held open by the open IPC channel.*
|
normally without the process being held open by the open IPC channel.*
|
||||||
|
|
||||||
See also: [`child_process.exec()`][] and [`child_process.fork()`][]
|
See also: [`child_process.exec()`][] and [`child_process.fork()`][].
|
||||||
|
|
||||||
## Synchronous Process Creation
|
## Synchronous Process Creation
|
||||||
|
|
||||||
@ -776,7 +776,7 @@ process has exited.*
|
|||||||
|
|
||||||
If the process times out or has a non-zero exit code, this method ***will***
|
If the process times out or has a non-zero exit code, this method ***will***
|
||||||
throw. The [`Error`][] object will contain the entire result from
|
throw. The [`Error`][] object will contain the entire result from
|
||||||
[`child_process.spawnSync()`][]
|
[`child_process.spawnSync()`][].
|
||||||
|
|
||||||
**Never pass unsanitized user input to this function. Any input containing shell
|
**Never pass unsanitized user input to this function. Any input containing shell
|
||||||
metacharacters may be used to trigger arbitrary command execution.**
|
metacharacters may be used to trigger arbitrary command execution.**
|
||||||
@ -1056,7 +1056,7 @@ does not indicate that the child process has been terminated.
|
|||||||
added: v0.1.90
|
added: v0.1.90
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* {number} Integer
|
* {integer}
|
||||||
|
|
||||||
Returns the process identifier (PID) of the child process.
|
Returns the process identifier (PID) of the child process.
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ added: v6.0.0
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built with
|
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built with
|
||||||
`./configure --openssl-fips`)
|
`./configure --openssl-fips`.)
|
||||||
|
|
||||||
### `--experimental-modules`
|
### `--experimental-modules`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -87,14 +87,14 @@ added: v6.0.0
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
|
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
|
||||||
(Same requirements as `--enable-fips`)
|
(Same requirements as `--enable-fips`.)
|
||||||
|
|
||||||
### `--icu-data-dir=file`
|
### `--icu-data-dir=file`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v0.11.15
|
added: v0.11.15
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Specify ICU data load path. (overrides `NODE_ICU_DATA`)
|
Specify ICU data load path. (Overrides `NODE_ICU_DATA`.)
|
||||||
|
|
||||||
### `--inspect-brk[=[host:]port]`
|
### `--inspect-brk[=[host:]port]`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -246,8 +246,8 @@ Throw errors for deprecations.
|
|||||||
added: v4.0.0
|
added: v4.0.0
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Specify an alternative default TLS cipher list. (Requires Node.js to be built
|
Specify an alternative default TLS cipher list. Requires Node.js to be built
|
||||||
with crypto support. (Default))
|
with crypto support (default).
|
||||||
|
|
||||||
### `--trace-deprecation`
|
### `--trace-deprecation`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
|
@ -363,7 +363,7 @@ Each new worker is given its own unique id, this id is stored in the
|
|||||||
`id`.
|
`id`.
|
||||||
|
|
||||||
While a worker is alive, this is the key that indexes it in
|
While a worker is alive, this is the key that indexes it in
|
||||||
cluster.workers
|
`cluster.workers`.
|
||||||
|
|
||||||
### worker.isConnected()
|
### worker.isConnected()
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -412,7 +412,7 @@ All workers are created using [`child_process.fork()`][], the returned object
|
|||||||
from this function is stored as `.process`. In a worker, the global `process`
|
from this function is stored as `.process`. In a worker, the global `process`
|
||||||
is stored.
|
is stored.
|
||||||
|
|
||||||
See: [Child Process module][]
|
See: [Child Process module][].
|
||||||
|
|
||||||
Note that workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
Note that workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
||||||
on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
||||||
@ -748,7 +748,7 @@ changes:
|
|||||||
description: The `stdio` option is supported now.
|
description: The `stdio` option is supported now.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `settings` {Object} see [`cluster.settings`][]
|
* `settings` {Object} See [`cluster.settings`][].
|
||||||
|
|
||||||
`setupMaster` is used to change the default 'fork' behavior. Once called,
|
`setupMaster` is used to change the default 'fork' behavior. Once called,
|
||||||
the settings will be present in `cluster.settings`.
|
the settings will be present in `cluster.settings`.
|
||||||
|
@ -99,7 +99,7 @@ changes:
|
|||||||
Setting to `true` enables coloring while inspecting values, setting to
|
Setting to `true` enables coloring while inspecting values, setting to
|
||||||
`'auto'` will make color support depend on the value of the `isTTY` property
|
`'auto'` will make color support depend on the value of the `isTTY` property
|
||||||
and the value returned by `getColorDepth()` on the respective stream.
|
and the value returned by `getColorDepth()` on the respective stream.
|
||||||
**Default:** `'auto'`
|
**Default:** `'auto'`.
|
||||||
|
|
||||||
Creates a new `Console` with one or two writable stream instances. `stdout` is a
|
Creates a new `Console` with one or two writable stream instances. `stdout` is a
|
||||||
writable stream to print log or info output. `stderr` is used for warning or
|
writable stream to print log or info output. `stderr` is used for warning or
|
||||||
|
@ -170,7 +170,7 @@ explicitly via error event handlers set on the domain instead.
|
|||||||
Type: End-of-Life
|
Type: End-of-Life
|
||||||
|
|
||||||
Calling an asynchronous function without a callback throws a `TypeError`
|
Calling an asynchronous function without a callback throws a `TypeError`
|
||||||
v10.0.0 onwards. Refer: [PR 12562](https://github.com/nodejs/node/pull/12562)
|
v10.0.0 onwards. Refer: [PR 12562](https://github.com/nodejs/node/pull/12562).
|
||||||
|
|
||||||
<a id="DEP0014"></a>
|
<a id="DEP0014"></a>
|
||||||
### DEP0014: fs.read legacy String interface
|
### DEP0014: fs.read legacy String interface
|
||||||
|
@ -111,7 +111,7 @@ properties.
|
|||||||
added: v0.1.99
|
added: v0.1.99
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `port` {number} Integer.
|
* `port` {integer}
|
||||||
* `address` {string}
|
* `address` {string}
|
||||||
* `callback` {Function} with no parameters. Called when binding is complete.
|
* `callback` {Function} with no parameters. Called when binding is complete.
|
||||||
|
|
||||||
@ -279,9 +279,9 @@ changes:
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
* `msg` {Buffer|Uint8Array|string|Array} Message to be sent.
|
* `msg` {Buffer|Uint8Array|string|Array} Message to be sent.
|
||||||
* `offset` {number} Integer. Offset in the buffer where the message starts.
|
* `offset` {integer} Offset in the buffer where the message starts.
|
||||||
* `length` {number} Integer. Number of bytes in the message.
|
* `length` {integer} Number of bytes in the message.
|
||||||
* `port` {number} Integer. Destination port.
|
* `port` {integer} Destination port.
|
||||||
* `address` {string} Destination hostname or IP address.
|
* `address` {string} Destination hostname or IP address.
|
||||||
* `callback` {Function} Called when the message has been sent.
|
* `callback` {Function} Called when the message has been sent.
|
||||||
|
|
||||||
@ -479,7 +479,7 @@ multicast packets will also be received on the local interface.
|
|||||||
added: v0.3.8
|
added: v0.3.8
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `ttl` {number} Integer.
|
* `ttl` {integer}
|
||||||
|
|
||||||
Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
|
Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
|
||||||
"Time to Live", in this context it specifies the number of IP hops that a
|
"Time to Live", in this context it specifies the number of IP hops that a
|
||||||
@ -495,7 +495,7 @@ between 0 and 255. The default on most systems is `1` but can vary.
|
|||||||
added: v8.7.0
|
added: v8.7.0
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `size` {number} Integer
|
* `size` {integer}
|
||||||
|
|
||||||
Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
||||||
in bytes.
|
in bytes.
|
||||||
@ -505,7 +505,7 @@ in bytes.
|
|||||||
added: v8.7.0
|
added: v8.7.0
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `size` {number} Integer
|
* `size` {integer}
|
||||||
|
|
||||||
Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
||||||
in bytes.
|
in bytes.
|
||||||
@ -515,7 +515,7 @@ in bytes.
|
|||||||
added: v0.1.101
|
added: v0.1.101
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `ttl` {number} Integer.
|
* `ttl` {integer}
|
||||||
|
|
||||||
Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
||||||
in this context it specifies the number of IP hops that a packet is allowed to
|
in this context it specifies the number of IP hops that a packet is allowed to
|
||||||
|
@ -1660,7 +1660,7 @@ entry types were found.
|
|||||||
<a id="ERR_VALUE_OUT_OF_RANGE"></a>
|
<a id="ERR_VALUE_OUT_OF_RANGE"></a>
|
||||||
### ERR_VALUE_OUT_OF_RANGE
|
### ERR_VALUE_OUT_OF_RANGE
|
||||||
|
|
||||||
Superseded by `ERR_OUT_OF_RANGE`
|
Superseded by `ERR_OUT_OF_RANGE`.
|
||||||
|
|
||||||
<a id="ERR_VM_MODULE_ALREADY_LINKED"></a>
|
<a id="ERR_VM_MODULE_ALREADY_LINKED"></a>
|
||||||
### ERR_VM_MODULE_ALREADY_LINKED
|
### ERR_VM_MODULE_ALREADY_LINKED
|
||||||
|
@ -500,7 +500,7 @@ added: v0.1.10
|
|||||||
|
|
||||||
Returns `true` if the `fs.Stats` object describes a symbolic link.
|
Returns `true` if the `fs.Stats` object describes a symbolic link.
|
||||||
|
|
||||||
This method is only valid when using [`fs.lstat()`][]
|
This method is only valid when using [`fs.lstat()`][].
|
||||||
|
|
||||||
### stats.dev
|
### stats.dev
|
||||||
|
|
||||||
@ -1038,7 +1038,7 @@ changes:
|
|||||||
Asynchronously changes the permissions of a file. No arguments other than a
|
Asynchronously changes the permissions of a file. No arguments other than a
|
||||||
possible exception are given to the completion callback.
|
possible exception are given to the completion callback.
|
||||||
|
|
||||||
See also: chmod(2)
|
See also: chmod(2).
|
||||||
|
|
||||||
### File modes
|
### File modes
|
||||||
|
|
||||||
@ -1097,7 +1097,7 @@ changes:
|
|||||||
Synchronously changes the permissions of a file. Returns `undefined`.
|
Synchronously changes the permissions of a file. Returns `undefined`.
|
||||||
This is the synchronous version of [`fs.chmod()`][].
|
This is the synchronous version of [`fs.chmod()`][].
|
||||||
|
|
||||||
See also: chmod(2)
|
See also: chmod(2).
|
||||||
|
|
||||||
## fs.chown(path, uid, gid, callback)
|
## fs.chown(path, uid, gid, callback)
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -1126,7 +1126,7 @@ changes:
|
|||||||
Asynchronously changes owner and group of a file. No arguments other than a
|
Asynchronously changes owner and group of a file. No arguments other than a
|
||||||
possible exception are given to the completion callback.
|
possible exception are given to the completion callback.
|
||||||
|
|
||||||
See also: chown(2)
|
See also: chown(2).
|
||||||
|
|
||||||
## fs.chownSync(path, uid, gid)
|
## fs.chownSync(path, uid, gid)
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -1145,7 +1145,7 @@ changes:
|
|||||||
Synchronously changes owner and group of a file. Returns `undefined`.
|
Synchronously changes owner and group of a file. Returns `undefined`.
|
||||||
This is the synchronous version of [`fs.chown()`][].
|
This is the synchronous version of [`fs.chown()`][].
|
||||||
|
|
||||||
See also: chown(2)
|
See also: chown(2).
|
||||||
|
|
||||||
## fs.close(fd, callback)
|
## fs.close(fd, callback)
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -1711,7 +1711,8 @@ given to the completion callback.
|
|||||||
If the file referred to by the file descriptor was larger than `len` bytes, only
|
If the file referred to by the file descriptor was larger than `len` bytes, only
|
||||||
the first `len` bytes will be retained in the file.
|
the first `len` bytes will be retained in the file.
|
||||||
|
|
||||||
For example, the following program retains only the first four bytes of the file
|
For example, the following program retains only the first four bytes of the
|
||||||
|
file:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
console.log(fs.readFileSync('temp.txt', 'utf8'));
|
console.log(fs.readFileSync('temp.txt', 'utf8'));
|
||||||
@ -1985,7 +1986,7 @@ changes:
|
|||||||
Asynchronously creates a directory. No arguments other than a possible exception
|
Asynchronously creates a directory. No arguments other than a possible exception
|
||||||
are given to the completion callback.
|
are given to the completion callback.
|
||||||
|
|
||||||
See also: mkdir(2)
|
See also: mkdir(2).
|
||||||
|
|
||||||
## fs.mkdirSync(path[, mode])
|
## fs.mkdirSync(path[, mode])
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -2003,7 +2004,7 @@ changes:
|
|||||||
Synchronously creates a directory. Returns `undefined`.
|
Synchronously creates a directory. Returns `undefined`.
|
||||||
This is the synchronous version of [`fs.mkdir()`][].
|
This is the synchronous version of [`fs.mkdir()`][].
|
||||||
|
|
||||||
See also: mkdir(2)
|
See also: mkdir(2).
|
||||||
|
|
||||||
## fs.mkdtemp(prefix[, options], callback)
|
## fs.mkdtemp(prefix[, options], callback)
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -2868,7 +2869,7 @@ fs.unlink('path/file.txt', (err) => {
|
|||||||
`fs.unlink()` will not work on a directory, empty or otherwise. To remove a
|
`fs.unlink()` will not work on a directory, empty or otherwise. To remove a
|
||||||
directory, use [`fs.rmdir()`][].
|
directory, use [`fs.rmdir()`][].
|
||||||
|
|
||||||
See also: unlink(2)
|
See also: unlink(2).
|
||||||
|
|
||||||
## fs.unlinkSync(path)
|
## fs.unlinkSync(path)
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
|
@ -459,7 +459,7 @@ added: v0.7.8
|
|||||||
Emitted when the underlying socket times out from inactivity. This only notifies
|
Emitted when the underlying socket times out from inactivity. This only notifies
|
||||||
that the socket has been idle. The request must be aborted manually.
|
that the socket has been idle. The request must be aborted manually.
|
||||||
|
|
||||||
See also: [`request.setTimeout()`][]
|
See also: [`request.setTimeout()`][].
|
||||||
|
|
||||||
### Event: 'upgrade'
|
### Event: 'upgrade'
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -541,7 +541,7 @@ added: v0.3.0
|
|||||||
|
|
||||||
* {net.Socket}
|
* {net.Socket}
|
||||||
|
|
||||||
See [`request.socket`][]
|
See [`request.socket`][].
|
||||||
|
|
||||||
### request.end([data[, encoding]][, callback])
|
### request.end([data[, encoding]][, callback])
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -1798,7 +1798,7 @@ automatically. Note that the callback must take care to consume the response
|
|||||||
data for reasons stated in [`http.ClientRequest`][] section.
|
data for reasons stated in [`http.ClientRequest`][] section.
|
||||||
|
|
||||||
The `callback` is invoked with a single argument that is an instance of
|
The `callback` is invoked with a single argument that is an instance of
|
||||||
[`http.IncomingMessage`][]
|
[`http.IncomingMessage`][].
|
||||||
|
|
||||||
JSON Fetching Example:
|
JSON Fetching Example:
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ protocol is available on the host `'example.org'` on TCP/IP port 81. The
|
|||||||
host and port *must* be contained within the quote (`"`) characters.
|
host and port *must* be contained within the quote (`"`) characters.
|
||||||
|
|
||||||
Multiple alternatives may be specified, for instance: `'h2="example.org:81",
|
Multiple alternatives may be specified, for instance: `'h2="example.org:81",
|
||||||
h2=":82"'`
|
h2=":82"'`.
|
||||||
|
|
||||||
The protocol identifier (`'h2'` in the examples) may be any valid
|
The protocol identifier (`'h2'` in the examples) may be any valid
|
||||||
[ALPN Protocol ID][].
|
[ALPN Protocol ID][].
|
||||||
|
@ -170,7 +170,7 @@ Makes a request to a secure web server.
|
|||||||
The following additional `options` from [`tls.connect()`][] are also accepted:
|
The following additional `options` from [`tls.connect()`][] are also accepted:
|
||||||
`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,
|
`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,
|
||||||
`honorCipherOrder`, `key`, `passphrase`, `pfx`, `rejectUnauthorized`,
|
`honorCipherOrder`, `key`, `passphrase`, `pfx`, `rejectUnauthorized`,
|
||||||
`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`
|
`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`.
|
||||||
|
|
||||||
`options` can be an object, a string, or a [`URL`][] object. If `options` is a
|
`options` can be an object, a string, or a [`URL`][] object. If `options` is a
|
||||||
string, it is automatically parsed with [`new URL()`][]. If it is a [`URL`][]
|
string, it is automatically parsed with [`new URL()`][]. If it is a [`URL`][]
|
||||||
|
@ -706,7 +706,7 @@ this, assign the desired export object to `module.exports`. Note that assigning
|
|||||||
the desired object to `exports` will simply rebind the local `exports` variable,
|
the desired object to `exports` will simply rebind the local `exports` variable,
|
||||||
which is probably not what is desired.
|
which is probably not what is desired.
|
||||||
|
|
||||||
For example suppose we were making a module called `a.js`
|
For example suppose we were making a module called `a.js`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
@ -720,7 +720,7 @@ setTimeout(() => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
```
|
```
|
||||||
|
|
||||||
Then in another file we could do
|
Then in another file we could do:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const a = require('./a');
|
const a = require('./a');
|
||||||
|
@ -2635,7 +2635,7 @@ napi_status napi_set_named_property(napi_env env,
|
|||||||
Returns `napi_ok` if the API succeeded.
|
Returns `napi_ok` if the API succeeded.
|
||||||
|
|
||||||
This method is equivalent to calling [`napi_set_property`][] with a `napi_value`
|
This method is equivalent to calling [`napi_set_property`][] with a `napi_value`
|
||||||
created from the string passed in as `utf8Name`
|
created from the string passed in as `utf8Name`.
|
||||||
|
|
||||||
#### napi_get_named_property
|
#### napi_get_named_property
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -2656,7 +2656,7 @@ napi_status napi_get_named_property(napi_env env,
|
|||||||
Returns `napi_ok` if the API succeeded.
|
Returns `napi_ok` if the API succeeded.
|
||||||
|
|
||||||
This method is equivalent to calling [`napi_get_property`][] with a `napi_value`
|
This method is equivalent to calling [`napi_get_property`][] with a `napi_value`
|
||||||
created from the string passed in as `utf8Name`
|
created from the string passed in as `utf8Name`.
|
||||||
|
|
||||||
#### napi_has_named_property
|
#### napi_has_named_property
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -2677,7 +2677,7 @@ napi_status napi_has_named_property(napi_env env,
|
|||||||
Returns `napi_ok` if the API succeeded.
|
Returns `napi_ok` if the API succeeded.
|
||||||
|
|
||||||
This method is equivalent to calling [`napi_has_property`][] with a `napi_value`
|
This method is equivalent to calling [`napi_has_property`][] with a `napi_value`
|
||||||
created from the string passed in as `utf8Name`
|
created from the string passed in as `utf8Name`.
|
||||||
|
|
||||||
#### napi_set_element
|
#### napi_set_element
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
|
@ -114,11 +114,10 @@ added: v0.1.90
|
|||||||
|
|
||||||
* Returns: {Object}
|
* Returns: {Object}
|
||||||
|
|
||||||
Returns the bound address, the address family name, and port of the server
|
Returns the bound `address`, the address `family` name, and `port` of the server
|
||||||
as reported by the operating system if listening on an IP socket.
|
as reported by the operating system if listening on an IP socket
|
||||||
Useful to find which port was assigned when getting an OS-assigned address.
|
(useful to find which port was assigned when getting an OS-assigned address):
|
||||||
Returns an object with `port`, `family`, and `address` properties:
|
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
|
||||||
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
|
||||||
|
|
||||||
For a server listening on a pipe or UNIX domain socket, the name is returned
|
For a server listening on a pipe or UNIX domain socket, the name is returned
|
||||||
as a string.
|
as a string.
|
||||||
@ -442,7 +441,7 @@ added: v0.1.90
|
|||||||
|
|
||||||
Emitted when the write buffer becomes empty. Can be used to throttle uploads.
|
Emitted when the write buffer becomes empty. Can be used to throttle uploads.
|
||||||
|
|
||||||
See also: the return values of `socket.write()`
|
See also: the return values of `socket.write()`.
|
||||||
|
|
||||||
### Event: 'end'
|
### Event: 'end'
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -504,7 +503,7 @@ added: v0.1.90
|
|||||||
Emitted if the socket times out from inactivity. This is only to notify that
|
Emitted if the socket times out from inactivity. This is only to notify that
|
||||||
the socket has been idle. The user must manually close the connection.
|
the socket has been idle. The user must manually close the connection.
|
||||||
|
|
||||||
See also: [`socket.setTimeout()`][]
|
See also: [`socket.setTimeout()`][].
|
||||||
|
|
||||||
### socket.address()
|
### socket.address()
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -513,9 +512,8 @@ added: v0.1.90
|
|||||||
|
|
||||||
* Returns: {Object}
|
* Returns: {Object}
|
||||||
|
|
||||||
Returns the bound address, the address family name and port of the
|
Returns the bound `address`, the address `family` name and `port` of the
|
||||||
socket as reported by the operating system. Returns an object with
|
socket as reported by the operating system:
|
||||||
three properties, e.g.
|
|
||||||
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
||||||
|
|
||||||
### socket.bufferSize
|
### socket.bufferSize
|
||||||
@ -954,7 +952,7 @@ client.on('end', () => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
To connect on the socket `/tmp/echo.sock` the second line would just be
|
To connect on the socket `/tmp/echo.sock` the second line would just be
|
||||||
changed to
|
changed to:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const client = net.createConnection({ path: '/tmp/echo.sock' });
|
const client = net.createConnection({ path: '/tmp/echo.sock' });
|
||||||
@ -1064,7 +1062,7 @@ $ telnet localhost 8124
|
|||||||
```
|
```
|
||||||
|
|
||||||
To listen on the socket `/tmp/echo.sock` the third line from the last would
|
To listen on the socket `/tmp/echo.sock` the third line from the last would
|
||||||
just be changed to
|
just be changed to:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
server.listen('/tmp/echo.sock', () => {
|
server.listen('/tmp/echo.sock', () => {
|
||||||
|
@ -254,7 +254,7 @@ The properties available on the assigned network address object include:
|
|||||||
is `IPv6`)
|
is `IPv6`)
|
||||||
* `cidr` {string} The assigned IPv4 or IPv6 address with the routing prefix
|
* `cidr` {string} The assigned IPv4 or IPv6 address with the routing prefix
|
||||||
in CIDR notation. If the `netmask` is invalid, this property is set
|
in CIDR notation. If the `netmask` is invalid, this property is set
|
||||||
to `null`
|
to `null`.
|
||||||
|
|
||||||
<!-- eslint-skip -->
|
<!-- eslint-skip -->
|
||||||
```js
|
```js
|
||||||
|
@ -289,7 +289,7 @@ command-line option can be used to suppress the default console output but the
|
|||||||
`'warning'` event will still be emitted by the `process` object.
|
`'warning'` event will still be emitted by the `process` object.
|
||||||
|
|
||||||
The following example illustrates the warning that is printed to `stderr` when
|
The following example illustrates the warning that is printed to `stderr` when
|
||||||
too many listeners have been added to an event
|
too many listeners have been added to an event:
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
$ node
|
$ node
|
||||||
|
@ -90,7 +90,7 @@ The `'pause'` event is emitted when one of the following occur:
|
|||||||
|
|
||||||
* The `input` stream is paused.
|
* The `input` stream is paused.
|
||||||
* The `input` stream is not paused and receives the `'SIGCONT'` event. (See
|
* The `input` stream is not paused and receives the `'SIGCONT'` event. (See
|
||||||
events [`'SIGTSTP'`][] and [`'SIGCONT'`][])
|
events [`'SIGTSTP'`][] and [`'SIGCONT'`][].)
|
||||||
|
|
||||||
The listener function is called without passing any arguments.
|
The listener function is called without passing any arguments.
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ The following special commands are supported by all REPL instances:
|
|||||||
`> .save ./file/to/save.js`
|
`> .save ./file/to/save.js`
|
||||||
* `.load` - Load a file into the current REPL session.
|
* `.load` - Load a file into the current REPL session.
|
||||||
`> .load ./file/to/load.js`
|
`> .load ./file/to/load.js`
|
||||||
* `.editor` - Enter editor mode (`<ctrl>-D` to finish, `<ctrl>-C` to cancel)
|
* `.editor` - Enter editor mode (`<ctrl>-D` to finish, `<ctrl>-C` to cancel).
|
||||||
|
|
||||||
<!-- eslint-skip -->
|
<!-- eslint-skip -->
|
||||||
```js
|
```js
|
||||||
@ -607,10 +607,11 @@ By starting a REPL from a Unix socket-based server instead of stdin, it is
|
|||||||
possible to connect to a long-running Node.js process without restarting it.
|
possible to connect to a long-running Node.js process without restarting it.
|
||||||
|
|
||||||
For an example of running a "full-featured" (`terminal`) REPL over
|
For an example of running a "full-featured" (`terminal`) REPL over
|
||||||
a `net.Server` and `net.Socket` instance, see: https://gist.github.com/2209310
|
a `net.Server` and `net.Socket` instance, see:
|
||||||
|
[https://gist.github.com/2209310](https://gist.github.com/2209310).
|
||||||
|
|
||||||
For an example of running a REPL instance over [curl(1)][],
|
For an example of running a REPL instance over [curl(1)][], see:
|
||||||
see: https://gist.github.com/2053342
|
[https://gist.github.com/2053342](https://gist.github.com/2053342).
|
||||||
|
|
||||||
[`--experimental-repl-await`]: cli.html#cli_experimental_repl_await
|
[`--experimental-repl-await`]: cli.html#cli_experimental_repl_await
|
||||||
[`readline.InterfaceCompleter`]: readline.html#readline_use_of_the_completer_function
|
[`readline.InterfaceCompleter`]: readline.html#readline_use_of_the_completer_function
|
||||||
|
@ -2407,14 +2407,12 @@ The workaround in this situation is to call the
|
|||||||
```js
|
```js
|
||||||
// Workaround
|
// Workaround
|
||||||
net.createServer((socket) => {
|
net.createServer((socket) => {
|
||||||
|
|
||||||
socket.on('end', () => {
|
socket.on('end', () => {
|
||||||
socket.end('The message was received but was not processed.\n');
|
socket.end('The message was received but was not processed.\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
// start the flow of data, discarding it.
|
// start the flow of data, discarding it.
|
||||||
socket.resume();
|
socket.resume();
|
||||||
|
|
||||||
}).listen(1337);
|
}).listen(1337);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -88,9 +88,9 @@ $ node hello-world.js
|
|||||||
An output like this should appear in the terminal to indicate Node.js
|
An output like this should appear in the terminal to indicate Node.js
|
||||||
server is running:
|
server is running:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
Server running at http://127.0.0.1:3000/
|
Server running at http://127.0.0.1:3000/
|
||||||
````
|
```
|
||||||
|
|
||||||
Now, open any preferred web browser and visit `http://127.0.0.1:3000`.
|
Now, open any preferred web browser and visit `http://127.0.0.1:3000`.
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ added: v3.0.0
|
|||||||
* Returns: {Buffer}
|
* Returns: {Buffer}
|
||||||
|
|
||||||
Returns a `Buffer` instance holding the keys currently used for
|
Returns a `Buffer` instance holding the keys currently used for
|
||||||
encryption/decryption of the [TLS Session Tickets][]
|
encryption/decryption of the [TLS Session Tickets][].
|
||||||
|
|
||||||
### server.listen()
|
### server.listen()
|
||||||
|
|
||||||
@ -516,10 +516,9 @@ added: v0.11.4
|
|||||||
|
|
||||||
* Returns: {Object}
|
* Returns: {Object}
|
||||||
|
|
||||||
Returns the bound address, the address family name, and port of the
|
Returns the bound `address`, the address `family` name, and `port` of the
|
||||||
underlying socket as reported by the operating system. Returns an
|
underlying socket as reported by the operating system:
|
||||||
object with three properties, e.g.
|
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
|
||||||
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
|
||||||
|
|
||||||
### tlsSocket.authorizationError
|
### tlsSocket.authorizationError
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -565,7 +564,7 @@ added: v0.11.4
|
|||||||
Returns an object representing the cipher name. The `version` key is a legacy
|
Returns an object representing the cipher name. The `version` key is a legacy
|
||||||
field which always contains the value `'TLSv1/SSLv3'`.
|
field which always contains the value `'TLSv1/SSLv3'`.
|
||||||
|
|
||||||
For example: `{ name: 'AES256-SHA', version: 'TLSv1/SSLv3' }`
|
For example: `{ name: 'AES256-SHA', version: 'TLSv1/SSLv3' }`.
|
||||||
|
|
||||||
See `SSL_CIPHER_get_name()` in
|
See `SSL_CIPHER_get_name()` in
|
||||||
https://www.openssl.org/docs/man1.1.0/ssl/SSL_CIPHER_get_name.html for more
|
https://www.openssl.org/docs/man1.1.0/ssl/SSL_CIPHER_get_name.html for more
|
||||||
@ -585,7 +584,7 @@ ephemeral. As this is only supported on a client socket; `null` is returned
|
|||||||
if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The
|
if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The
|
||||||
`name` property is available only when type is 'ECDH'.
|
`name` property is available only when type is 'ECDH'.
|
||||||
|
|
||||||
For Example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`
|
For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`.
|
||||||
|
|
||||||
### tlsSocket.getFinished()
|
### tlsSocket.getFinished()
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -1216,7 +1215,6 @@ const options = {
|
|||||||
|
|
||||||
// This is necessary only if using the client certificate authentication.
|
// This is necessary only if using the client certificate authentication.
|
||||||
requestCert: true,
|
requestCert: true,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.createServer(options, (socket) => {
|
const server = tls.createServer(options, (socket) => {
|
||||||
@ -1341,7 +1339,7 @@ changes:
|
|||||||
* `session` {Buffer} An optional `Buffer` instance containing a TLS session.
|
* `session` {Buffer} An optional `Buffer` instance containing a TLS session.
|
||||||
* `requestOCSP` {boolean} If `true`, specifies that the OCSP status request
|
* `requestOCSP` {boolean} If `true`, specifies that the OCSP status request
|
||||||
extension will be added to the client hello and an `'OCSPResponse'` event
|
extension will be added to the client hello and an `'OCSPResponse'` event
|
||||||
will be emitted on the socket before establishing a secure communication
|
will be emitted on the socket before establishing a secure communication.
|
||||||
|
|
||||||
Creates a new secure pair object with two streams, one of which reads and writes
|
Creates a new secure pair object with two streams, one of which reads and writes
|
||||||
the encrypted data and the other of which reads and writes the cleartext data.
|
the encrypted data and the other of which reads and writes the cleartext data.
|
||||||
|
@ -884,42 +884,42 @@ double slashes (if present) and precedes the `host` component, delimited by an
|
|||||||
ASCII "at sign" (`@`). The format of the string is `{username}[:{password}]`,
|
ASCII "at sign" (`@`). The format of the string is `{username}[:{password}]`,
|
||||||
with the `[:{password}]` portion being optional.
|
with the `[:{password}]` portion being optional.
|
||||||
|
|
||||||
For example: `'user:pass'`
|
For example: `'user:pass'`.
|
||||||
|
|
||||||
#### urlObject.hash
|
#### urlObject.hash
|
||||||
|
|
||||||
The `hash` property consists of the "fragment" portion of the URL including
|
The `hash` property consists of the "fragment" portion of the URL including
|
||||||
the leading ASCII hash (`#`) character.
|
the leading ASCII hash (`#`) character.
|
||||||
|
|
||||||
For example: `'#hash'`
|
For example: `'#hash'`.
|
||||||
|
|
||||||
#### urlObject.host
|
#### urlObject.host
|
||||||
|
|
||||||
The `host` property is the full lower-cased host portion of the URL, including
|
The `host` property is the full lower-cased host portion of the URL, including
|
||||||
the `port` if specified.
|
the `port` if specified.
|
||||||
|
|
||||||
For example: `'sub.host.com:8080'`
|
For example: `'sub.host.com:8080'`.
|
||||||
|
|
||||||
#### urlObject.hostname
|
#### urlObject.hostname
|
||||||
|
|
||||||
The `hostname` property is the lower-cased host name portion of the `host`
|
The `hostname` property is the lower-cased host name portion of the `host`
|
||||||
component *without* the `port` included.
|
component *without* the `port` included.
|
||||||
|
|
||||||
For example: `'sub.host.com'`
|
For example: `'sub.host.com'`.
|
||||||
|
|
||||||
#### urlObject.href
|
#### urlObject.href
|
||||||
|
|
||||||
The `href` property is the full URL string that was parsed with both the
|
The `href` property is the full URL string that was parsed with both the
|
||||||
`protocol` and `host` components converted to lower-case.
|
`protocol` and `host` components converted to lower-case.
|
||||||
|
|
||||||
For example: `'http://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'`
|
For example: `'http://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'`.
|
||||||
|
|
||||||
#### urlObject.path
|
#### urlObject.path
|
||||||
|
|
||||||
The `path` property is a concatenation of the `pathname` and `search`
|
The `path` property is a concatenation of the `pathname` and `search`
|
||||||
components.
|
components.
|
||||||
|
|
||||||
For example: `'/p/a/t/h?query=string'`
|
For example: `'/p/a/t/h?query=string'`.
|
||||||
|
|
||||||
No decoding of the `path` is performed.
|
No decoding of the `path` is performed.
|
||||||
|
|
||||||
@ -930,7 +930,7 @@ is everything following the `host` (including the `port`) and before the start
|
|||||||
of the `query` or `hash` components, delimited by either the ASCII question
|
of the `query` or `hash` components, delimited by either the ASCII question
|
||||||
mark (`?`) or hash (`#`) characters.
|
mark (`?`) or hash (`#`) characters.
|
||||||
|
|
||||||
For example `'/p/a/t/h'`
|
For example `'/p/a/t/h'`.
|
||||||
|
|
||||||
No decoding of the path string is performed.
|
No decoding of the path string is performed.
|
||||||
|
|
||||||
@ -938,13 +938,13 @@ No decoding of the path string is performed.
|
|||||||
|
|
||||||
The `port` property is the numeric port portion of the `host` component.
|
The `port` property is the numeric port portion of the `host` component.
|
||||||
|
|
||||||
For example: `'8080'`
|
For example: `'8080'`.
|
||||||
|
|
||||||
#### urlObject.protocol
|
#### urlObject.protocol
|
||||||
|
|
||||||
The `protocol` property identifies the URL's lower-cased protocol scheme.
|
The `protocol` property identifies the URL's lower-cased protocol scheme.
|
||||||
|
|
||||||
For example: `'http:'`
|
For example: `'http:'`.
|
||||||
|
|
||||||
#### urlObject.query
|
#### urlObject.query
|
||||||
|
|
||||||
@ -953,7 +953,7 @@ question mark (`?`), or an object returned by the [`querystring`][] module's
|
|||||||
`parse()` method. Whether the `query` property is a string or object is
|
`parse()` method. Whether the `query` property is a string or object is
|
||||||
determined by the `parseQueryString` argument passed to `url.parse()`.
|
determined by the `parseQueryString` argument passed to `url.parse()`.
|
||||||
|
|
||||||
For example: `'query=string'` or `{'query': 'string'}`
|
For example: `'query=string'` or `{'query': 'string'}`.
|
||||||
|
|
||||||
If returned as a string, no decoding of the query string is performed. If
|
If returned as a string, no decoding of the query string is performed. If
|
||||||
returned as an object, both keys and values are decoded.
|
returned as an object, both keys and values are decoded.
|
||||||
@ -963,7 +963,7 @@ returned as an object, both keys and values are decoded.
|
|||||||
The `search` property consists of the entire "query string" portion of the
|
The `search` property consists of the entire "query string" portion of the
|
||||||
URL, including the leading ASCII question mark (`?`) character.
|
URL, including the leading ASCII question mark (`?`) character.
|
||||||
|
|
||||||
For example: `'?query=string'`
|
For example: `'?query=string'`.
|
||||||
|
|
||||||
No decoding of the query string is performed.
|
No decoding of the query string is performed.
|
||||||
|
|
||||||
|
@ -54,18 +54,19 @@ Since `null` has a special meaning as the first argument to a callback, if a
|
|||||||
wrapped function rejects a `Promise` with a falsy value as a reason, the value
|
wrapped function rejects a `Promise` with a falsy value as a reason, the value
|
||||||
is wrapped in an `Error` with the original value stored in a field named
|
is wrapped in an `Error` with the original value stored in a field named
|
||||||
`reason`.
|
`reason`.
|
||||||
```js
|
|
||||||
function fn() {
|
|
||||||
return Promise.reject(null);
|
|
||||||
}
|
|
||||||
const callbackFunction = util.callbackify(fn);
|
|
||||||
|
|
||||||
callbackFunction((err, ret) => {
|
```js
|
||||||
|
function fn() {
|
||||||
|
return Promise.reject(null);
|
||||||
|
}
|
||||||
|
const callbackFunction = util.callbackify(fn);
|
||||||
|
|
||||||
|
callbackFunction((err, ret) => {
|
||||||
// When the Promise was rejected with `null` it is wrapped with an Error and
|
// When the Promise was rejected with `null` it is wrapped with an Error and
|
||||||
// the original value is stored in `reason`.
|
// the original value is stored in `reason`.
|
||||||
err && err.hasOwnProperty('reason') && err.reason === null; // true
|
err && err.hasOwnProperty('reason') && err.reason === null; // true
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## util.debuglog(section)
|
## util.debuglog(section)
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -339,7 +340,7 @@ stream.on('data', (data) => {
|
|||||||
stream.write('It works!'); // Received data: "It works!"
|
stream.write('It works!'); // Received data: "It works!"
|
||||||
```
|
```
|
||||||
|
|
||||||
ES6 example using `class` and `extends`
|
ES6 example using `class` and `extends`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
|
@ -867,7 +867,7 @@ const code = `
|
|||||||
})`;
|
})`;
|
||||||
|
|
||||||
vm.runInThisContext(code)(require);
|
vm.runInThisContext(code)(require);
|
||||||
```
|
```
|
||||||
|
|
||||||
The `require()` in the above case shares the state with the context it is
|
The `require()` in the above case shares the state with the context it is
|
||||||
passed from. This may introduce risks when untrusted code is executed, e.g.
|
passed from. This may introduce risks when untrusted code is executed, e.g.
|
||||||
|
@ -312,7 +312,7 @@ ignored by the decompression classes.
|
|||||||
* `strategy` {integer} (compression only)
|
* `strategy` {integer} (compression only)
|
||||||
* `dictionary` {Buffer|TypedArray|DataView|ArrayBuffer} (deflate/inflate only,
|
* `dictionary` {Buffer|TypedArray|DataView|ArrayBuffer} (deflate/inflate only,
|
||||||
empty dictionary by default)
|
empty dictionary by default)
|
||||||
* `info` {boolean} (If `true`, returns an object with `buffer` and `engine`)
|
* `info` {boolean} (If `true`, returns an object with `buffer` and `engine`.)
|
||||||
|
|
||||||
See the description of `deflateInit2` and `inflateInit2` at
|
See the description of `deflateInit2` and `inflateInit2` at
|
||||||
<https://zlib.net/manual.html#Advanced> for more information on these.
|
<https://zlib.net/manual.html#Advanced> for more information on these.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user