diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2bab714999..49d686356e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,7 +28,8 @@ release.
-7.7.2
+7.7.3
+7.7.2
7.7.1
7.7.0
7.6.0
diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
index 7e56b5fba6e..2b8d2c36a81 100644
--- a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
+++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
@@ -7,7 +7,7 @@ const inputs = require('../fixtures/url-inputs.js').searchParams;
const bench = common.createBenchmark(main, {
type: Object.keys(inputs),
method: ['legacy', 'whatwg'],
- n: [1e5]
+ n: [1e6]
});
function useLegacy(n, input, prop) {
diff --git a/doc/api/child_process.md b/doc/api/child_process.md
index 7ea5a6ea98c..7c1f5373d99 100644
--- a/doc/api/child_process.md
+++ b/doc/api/child_process.md
@@ -135,8 +135,9 @@ added: v0.1.90
understand the `-c` switch on UNIX or `/d /s /c` on Windows. On Windows,
command line parsing should be compatible with `cmd.exe`.)
* `timeout` {number} (Default: `0`)
- * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on
- stdout or stderr - if exceeded child process is killed (Default: `200*1024`)
+ * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
+ stderr. (Default: `200*1024`) If exceeded, the child process is terminated.
+ See caveat at [`maxBuffer` and Unicode][].
* `killSignal` {string|integer} (Default: `'SIGTERM'`)
* `uid` {number} Sets the user identity of the process. (See setuid(2).)
* `gid` {number} Sets the group identity of the process. (See setgid(2).)
@@ -212,8 +213,9 @@ added: v0.1.91
* `env` {Object} Environment key-value pairs
* `encoding` {string} (Default: `'utf8'`)
* `timeout` {number} (Default: `0`)
- * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on
- stdout or stderr - if exceeded child process is killed (Default: `200*1024`)
+ * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
+ stderr. (Default: `200*1024`) If exceeded, the child process is terminated.
+ See caveat at [`maxBuffer` and Unicode][].
* `killSignal` {string|integer} (Default: `'SIGTERM'`)
* `uid` {number} Sets the user identity of the process. (See setuid(2).)
* `gid` {number} Sets the group identity of the process. (See setgid(2).)
@@ -618,8 +620,9 @@ changes:
is allowed to run. (Default: `undefined`)
* `killSignal` {string|integer} The signal value to be used when the spawned
process will be killed. (Default: `'SIGTERM'`)
- * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on
- stdout or stderr - if exceeded child process is killed
+ * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
+ stderr. (Default: `200*1024`) If exceeded, the child process is terminated.
+ See caveat at [`maxBuffer` and Unicode][].
* `encoding` {string} The encoding used for all stdio inputs and outputs. (Default: `'buffer'`)
* Returns: {Buffer|string} The stdout from the command
@@ -664,8 +667,9 @@ changes:
is allowed to run. (Default: `undefined`)
* `killSignal` {string|integer} The signal value to be used when the spawned
process will be killed. (Default: `'SIGTERM'`)
- * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on
- stdout or stderr - if exceeded child process is killed
+ * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
+ stderr. (Default: `200*1024`) If exceeded, the child process is terminated.
+ See caveat at [`maxBuffer` and Unicode][].
* `encoding` {string} The encoding used for all stdio inputs and outputs.
(Default: `'buffer'`)
* Returns: {Buffer|string} The stdout from the command
@@ -716,8 +720,9 @@ changes:
is allowed to run. (Default: `undefined`)
* `killSignal` {string|integer} The signal value to be used when the spawned
process will be killed. (Default: `'SIGTERM'`)
- * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on
- stdout or stderr - if exceeded child process is killed
+ * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
+ stderr. (Default: `200*1024`) If exceeded, the child process is terminated.
+ See caveat at [`maxBuffer` and Unicode][].
* `encoding` {string} The encoding used for all stdio inputs and outputs.
(Default: `'buffer'`)
* `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses
@@ -1235,7 +1240,7 @@ to `stdout` although there are only 4 characters.
[`Error`]: errors.html#errors_class_error
[`EventEmitter`]: events.html#events_class_eventemitter
[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
-[`maxBuffer`]: #child_process_maxbuffer_and_unicode
+[`maxBuffer` and Unicode]: #child_process_maxbuffer_and_unicode
[`net.Server`]: net.html#net_class_net_server
[`net.Socket`]: net.html#net_class_net_socket
[`options.detached`]: #child_process_options_detached
diff --git a/doc/api/crypto.md b/doc/api/crypto.md
index e901edf5fd3..9557273a9b7 100644
--- a/doc/api/crypto.md
+++ b/doc/api/crypto.md
@@ -62,11 +62,9 @@ const cert2 = crypto.Certificate();
-
-The `spkac` data structure includes a public key and a challenge. The
-`certificate.exportChallenge()` returns the challenge component in the
-form of a Node.js [`Buffer`][]. The `spkac` argument can be either a string
-or a [`Buffer`][].
+- `spkac` {string | Buffer}
+- Returns {Buffer} The challenge component of the `spkac` data structure, which
+includes a public key and a challenge.
```js
const cert = require('crypto').Certificate();
@@ -80,11 +78,9 @@ console.log(challenge.toString('utf8'));
-
-The `spkac` data structure includes a public key and a challenge. The
-`certificate.exportPublicKey()` returns the public key component in the
-form of a Node.js [`Buffer`][]. The `spkac` argument can be either a string
-or a [`Buffer`][].
+- `spkac` {string | Buffer}
+- Returns {Buffer} The public key component of the `spkac` data structure,
+which includes a public key and a challenge.
```js
const cert = require('crypto').Certificate();
@@ -98,9 +94,9 @@ console.log(publicKey);
-
-Returns `true` if the given `spkac` data structure is valid, `false` otherwise.
-The `spkac` argument must be a Node.js [`Buffer`][].
+- `spkac` {Buffer}
+- Returns {boolean} `true` if the given `spkac` data structure is valid, `false`
+otherwise.
```js
const cert = require('crypto').Certificate();
@@ -176,6 +172,7 @@ console.log(encrypted);
+- `output_encoding` {string}
Returns any remaining enciphered contents. If `output_encoding`
parameter is one of `'latin1'`, `'base64'` or `'hex'`, a string is returned.
@@ -189,6 +186,8 @@ once will result in an error being thrown.
+- `buffer` {Buffer}
+- Returns the {Cipher} for method chaining.
When using an authenticated encryption mode (only `GCM` is currently
supported), the `cipher.setAAD()` method sets the value used for the
@@ -196,8 +195,6 @@ _additional authenticated data_ (AAD) input parameter.
The `cipher.setAAD()` method must be called before [`cipher.update()`][].
-Returns `this` for method chaining.
-
### cipher.getAuthTag()
+- `auto_padding` {boolean} Defaults to `true`.
+- Returns the {Cipher} for method chaining.
When using block encryption algorithms, the `Cipher` class will automatically
add padding to the input data to the appropriate block size. To disable the
@@ -227,8 +226,6 @@ using `0x0` instead of PKCS padding.
The `cipher.setAutoPadding()` method must be called before
[`cipher.final()`][].
-Returns `this` for method chaining.
-
### cipher.update(data[, input_encoding][, output_encoding])
+- `data` {string | Buffer}
+- `input_encoding` {string}
+- `output_encoding` {string}
Updates the cipher with `data`. If the `input_encoding` argument is given,
its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data`
@@ -322,6 +322,7 @@ console.log(decrypted);
+- `output_encoding` {string}
Returns any remaining deciphered contents. If `output_encoding`
parameter is one of `'latin1'`, `'ascii'` or `'utf8'`, a string is returned.
@@ -339,6 +340,8 @@ changes:
pr-url: https://github.com/nodejs/node/pull/9398
description: This method now returns a reference to `decipher`.
-->
+- `buffer` {Buffer}
+- Returns the {Cipher} for method chaining.
When using an authenticated encryption mode (only `GCM` is currently
supported), the `decipher.setAAD()` method sets the value used for the
@@ -346,8 +349,6 @@ _additional authenticated data_ (AAD) input parameter.
The `decipher.setAAD()` method must be called before [`decipher.update()`][].
-Returns `this` for method chaining.
-
### decipher.setAuthTag(buffer)
+- `buffer` {Buffer}
+- Returns the {Cipher} for method chaining.
When using an authenticated encryption mode (only `GCM` is currently
supported), the `decipher.setAuthTag()` method is used to pass in the
@@ -366,12 +369,12 @@ cipher text should be discarded due to failed authentication.
The `decipher.setAuthTag()` method must be called before
[`decipher.final()`][].
-Returns `this` for method chaining.
-
-### decipher.setAutoPadding(auto_padding=true)
+### decipher.setAutoPadding([auto_padding])
+- `auto_padding` {boolean} Defaults to `true`.
+- Returns the {Cipher} for method chaining.
When data has been encrypted without standard block padding, calling
`decipher.setAutoPadding(false)` will disable automatic padding to prevent
@@ -383,8 +386,6 @@ multiple of the ciphers block size.
The `decipher.setAutoPadding()` method must be called before
[`decipher.final()`][].
-Returns `this` for method chaining.
-
### decipher.update(data[, input_encoding][, output_encoding])
+- `data` {string | Buffer}
+- `input_encoding` {string}
+- `output_encoding` {string}
Updates the decipher with `data`. If the `input_encoding` argument is given,
its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data`
@@ -444,6 +448,9 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
+- `other_public_key` {string | Buffer}
+- `input_encoding` {string}
+- `output_encoding` {string}
Computes the shared secret using `other_public_key` as the other
party's public key and returns the computed shared secret. The supplied
@@ -459,6 +466,7 @@ If `output_encoding` is given a string is returned; otherwise, a
+- `encoding` {string}
Generates private and public Diffie-Hellman key values, and returns
the public key in the specified `encoding`. This key should be
@@ -470,6 +478,7 @@ or `'base64'`. If `encoding` is provided a string is returned; otherwise a
+- `encoding` {string}
Returns the Diffie-Hellman generator in the specified `encoding`, which can
be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is
@@ -479,6 +488,7 @@ returned; otherwise a [`Buffer`][] is returned.
+- `encoding` {string}
Returns the Diffie-Hellman prime in the specified `encoding`, which can
be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is
@@ -488,6 +498,7 @@ returned; otherwise a [`Buffer`][] is returned.
+- `encoding` {string}
Returns the Diffie-Hellman private key in the specified `encoding`,
which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a
@@ -497,6 +508,7 @@ string is returned; otherwise a [`Buffer`][] is returned.
+- `encoding` {string}
Returns the Diffie-Hellman public key in the specified `encoding`, which
can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a
@@ -506,6 +518,8 @@ string is returned; otherwise a [`Buffer`][] is returned.
+- `private_key` {string | Buffer}
+- `encoding` {string}
Sets the Diffie-Hellman private key. If the `encoding` argument is provided
and is either `'latin1'`, `'hex'`, or `'base64'`, `private_key` is expected
@@ -516,6 +530,8 @@ to be a [`Buffer`][].
+- `public_key` {string | Buffer}
+- `encoding` {string}
Sets the Diffie-Hellman public key. If the `encoding` argument is provided
and is either `'latin1'`, `'hex'` or `'base64'`, `public_key` is expected
@@ -577,6 +593,9 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_encoding` changed from `binary` to `utf8`.
-->
+- `other_public_key` {string | Buffer}
+- `input_encoding` {string}
+- `output_encoding` {string}
Computes the shared secret using `other_public_key` as the other
party's public key and returns the computed shared secret. The supplied
@@ -592,6 +611,8 @@ If `output_encoding` is given a string will be returned; otherwise a
+- `encoding` {string}
+- `format` {string} Defaults to `uncompressed`.
Generates private and public EC Diffie-Hellman key values, and returns
the public key in the specified `format` and `encoding`. This key should be
@@ -609,15 +630,18 @@ is returned.
+- `encoding` {string}
Returns the EC Diffie-Hellman private key in the specified `encoding`,
which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided
a string is returned; otherwise a [`Buffer`][] is returned.
-### ecdh.getPublicKey([encoding[, format]])
+### ecdh.getPublicKey([encoding][, format])
+- `encoding` {string}
+- `format` {string} Defaults to `uncompressed`.
Returns the EC Diffie-Hellman public key in the specified `encoding` and
`format`.
@@ -634,6 +658,8 @@ returned.
+- `private_key` {string | Buffer}
+- `encoding` {string}
Sets the EC Diffie-Hellman private key. The `encoding` can be `'latin1'`,
`'hex'` or `'base64'`. If `encoding` is provided, `private_key` is expected
@@ -650,6 +676,9 @@ deprecated: v5.2.0
> Stability: 0 - Deprecated
+- `public_key` {string | Buffer}
+- `encoding` {string}
+
Sets the EC Diffie-Hellman public key. Key encoding can be `'latin1'`,
`'hex'` or `'base64'`. If `encoding` is provided `public_key` is expected to
be a string; otherwise a [`Buffer`][] is expected.
@@ -747,6 +776,7 @@ console.log(hash.digest('hex'));
+- `encoding` {string}
Calculates the digest of all of the data passed to be hashed (using the
[`hash.update()`][] method). The `encoding` can be `'hex'`, `'latin1'` or
@@ -764,6 +794,8 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_encoding` changed from `binary` to `utf8`.
-->
+- `data` {string | Buffer}
+- `input_encoding` {string}
Updates the hash content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
@@ -834,6 +866,7 @@ console.log(hmac.digest('hex'));
+- `encoding` {string}
Calculates the HMAC digest of all of the data passed using [`hmac.update()`][].
The `encoding` can be `'hex'`, `'latin1'` or `'base64'`. If `encoding` is
@@ -850,6 +883,8 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_encoding` changed from `binary` to `utf8`.
-->
+- `data` {string | Buffer}
+- `input_encoding` {string}
Updates the `Hmac` content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
@@ -929,6 +964,10 @@ console.log(sign.sign(privateKey).toString('hex'));
+- `private_key` {string | Object}
+ - `key` {string}
+ - `passphrase` {string}
+- `output_format` {string}
Calculates the signature on all the data passed through using either
[`sign.update()`][] or [`sign.write()`][stream-writable-write].
@@ -955,6 +994,8 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_encoding` changed from `binary` to `utf8`.
-->
+- `data` {string | Buffer}
+- `input_encoding` {string}
Updates the `Sign` content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
@@ -1017,6 +1058,8 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_encoding` changed from `binary` to `utf8`.
-->
+- `data` {string | Buffer}
+- `input_encoding` {string}
Updates the `Verify` content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
@@ -1030,10 +1073,13 @@ This can be called many times with new data as it is streamed.
+- `object` {string}
+- `signature` {string | Buffer}
+- `signature_format` {string}
Verifies the provided data using the given `object` and `signature`.
The `object` argument is a string containing a PEM encoded object, which can be
-one an RSA public key, a DSA public key, or an X.509 certificate.
+an RSA public key, a DSA public key, or an X.509 certificate.
The `signature` argument is the previously calculated signature for the data, in
the `signature_format` which can be `'latin1'`, `'hex'` or `'base64'`.
If a `signature_format` is specified, the `signature` is expected to be a
@@ -1084,6 +1130,8 @@ currently in use. Setting to true requires a FIPS build of Node.js.
+- `algorithm` {string}
+- `password` {string | Buffer}
Creates and returns a `Cipher` object that uses the given `algorithm` and
`password`.
@@ -1108,6 +1156,9 @@ their own using [`crypto.pbkdf2()`][] and to use [`crypto.createCipheriv()`][]
to create the `Cipher` object.
### crypto.createCipheriv(algorithm, key, iv)
+- `algorithm` {string}
+- `key` {string | Buffer}
+- `iv` {string | Buffer}
Creates and returns a `Cipher` object, with the given `algorithm`, `key` and
initialization vector (`iv`).
@@ -1142,6 +1193,8 @@ called.
+- `algorithm` {string}
+- `password` {string | Buffer}
Creates and returns a `Decipher` object that uses the given `algorithm` and
`password` (key).
@@ -1162,6 +1215,9 @@ to create the `Decipher` object.
+- `algorithm` {string}
+- `key` {string | Buffer}
+- `iv` {string | Buffer}
Creates and returns a `Decipher` object that uses the given `algorithm`, `key`
and initialization vector (`iv`).
@@ -1183,6 +1239,10 @@ changes:
description: The default for the encoding parameters changed
from `binary` to `utf8`.
-->
+- `prime` {string | Buffer}
+- `prime_encoding` {string}
+- `generator` {number | string | Buffer} Defaults to `2`.
+- `generator_encoding` {string}
Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
optional specific `generator`.
@@ -1203,6 +1263,8 @@ otherwise either a number or [`Buffer`][] is expected.
+- `prime_length` {number}
+- `generator` {number | string | Buffer} Defaults to `2`.
Creates a `DiffieHellman` key exchange object and generates a prime of
`prime_length` bits using an optional specific numeric `generator`.
@@ -1212,6 +1274,7 @@ If `generator` is not specified, the value `2` is used.
+- `curve_name` {string}
Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
predefined curve specified by the `curve_name` string. Use
@@ -1223,6 +1286,7 @@ and description of each available elliptic curve.
+- `algorithm` {string}
Creates and returns a `Hash` object that can be used to generate hash digests
using the given `algorithm`.
@@ -1256,6 +1320,8 @@ input.on('readable', () => {
+- `algorithm` {string}
+- `key` {string | Buffer}
Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
@@ -1290,6 +1356,7 @@ input.on('readable', () => {
+- `algorithm` {string}
Creates and returns a `Sign` object that uses the given `algorithm`.
Use [`crypto.getHashes()`][] to obtain an array of names of the available
@@ -1299,6 +1366,7 @@ signing algorithms.
+- `algorithm` {string}
Creates and returns a `Verify` object that uses the given algorithm.
Use [`crypto.getHashes()`][] to obtain an array of names of the available
@@ -1336,6 +1404,7 @@ console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
+- `group_name` {string}
Creates a predefined `DiffieHellman` key exchange object. The
supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in
@@ -1396,6 +1465,14 @@ changes:
description: The default encoding for `password` if it is a string changed
from `binary` to `utf8`.
-->
+- `password` {string}
+- `salt` {string}
+- `iterations` {number}
+- `keylen` {number}
+- `digest` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `derivedKey` {Buffer}
Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
implementation. A selected HMAC digest algorithm specified by `digest` is
@@ -1418,9 +1495,9 @@ Example:
```js
const crypto = require('crypto');
-crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, key) => {
+crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => {
if (err) throw err;
- console.log(key.toString('hex')); // '3745e48...aa39b34'
+ console.log(derivedKey.toString('hex')); // '3745e48...aa39b34'
});
```
@@ -1440,6 +1517,11 @@ changes:
description: The default encoding for `password` if it is a string changed
from `binary` to `utf8`.
-->
+- `password` {string}
+- `salt` {string}
+- `iterations` {number}
+- `keylen` {number}
+- `digest` {string}
Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
implementation. A selected HMAC digest algorithm specified by `digest` is
@@ -1472,95 +1554,84 @@ An array of supported digest functions can be retrieved using
+- `private_key` {Object | string}
+ - `key` {string} A PEM encoded private key.
+ - `passphrase` {string} An optional passphrase for the private key.
+ - `padding` {crypto.constants} An optional padding value defined in
+ `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
+ `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
+- `buffer` {Buffer}
Decrypts `buffer` with `private_key`.
`private_key` can be an object or a string. If `private_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
-If `private_key` is an object, it is interpreted as a hash object with the
-keys:
-
-* `key`: {string} - PEM encoded private key
-* `passphrase`: {string} - Optional passphrase for the private key
-* `padding` : An optional padding value, one of the following:
- * `crypto.constants.RSA_NO_PADDING`
- * `crypto.constants.RSA_PKCS1_PADDING`
- * `crypto.constants.RSA_PKCS1_OAEP_PADDING`
-
-All paddings are defined in `crypto.constants`.
### crypto.privateEncrypt(private_key, buffer)
+- `private_key` {Object | string}
+ - `key` {string} A PEM encoded private key.
+ - `passphrase` {string} An optional passphrase for the private key.
+ - `padding` {crypto.constants} An optional padding value defined in
+ `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
+ `RSA_PKCS1_PADDING`.
+- `buffer` {Buffer}
Encrypts `buffer` with `private_key`.
`private_key` can be an object or a string. If `private_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
-If `private_key` is an object, it is interpreted as a hash object with the
-keys:
-
-* `key`: {string} - PEM encoded private key
-* `passphrase`: {string} - Optional passphrase for the private key
-* `padding` : An optional padding value, one of the following:
- * `crypto.constants.RSA_NO_PADDING`
- * `crypto.constants.RSA_PKCS1_PADDING`
-
-All paddings are defined in `crypto.constants`.
### crypto.publicDecrypt(public_key, buffer)
+- `private_key` {Object | string}
+ - `key` {string} A PEM encoded private key.
+ - `passphrase` {string} An optional passphrase for the private key.
+ - `padding` {crypto.constants} An optional padding value defined in
+ `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
+ `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
+- `buffer` {Buffer}
Decrypts `buffer` with `public_key`.
`public_key` can be an object or a string. If `public_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
-If `public_key` is an object, it is interpreted as a hash object with the
-keys:
-
-* `key`: {string} - PEM encoded public key
-* `passphrase`: {string} - Optional passphrase for the private key
-* `padding` : An optional padding value, one of the following:
- * `crypto.constants.RSA_NO_PADDING`
- * `crypto.constants.RSA_PKCS1_PADDING`
- * `crypto.constants.RSA_PKCS1_OAEP_PADDING`
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.
-All paddings are defined in `crypto.constants`.
-
### crypto.publicEncrypt(public_key, buffer)
+- `private_key` {Object | string}
+ - `key` {string} A PEM encoded private key.
+ - `passphrase` {string} An optional passphrase for the private key.
+ - `padding` {crypto.constants} An optional padding value defined in
+ `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
+ `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
+- `buffer` {Buffer}
Encrypts `buffer` with `public_key`.
`public_key` can be an object or a string. If `public_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
-If `public_key` is an object, it is interpreted as a hash object with the
-keys:
-
-* `key`: {string} - PEM encoded public key
-* `passphrase`: {string} - Optional passphrase for the private key
-* `padding` : An optional padding value, one of the following:
- * `crypto.constants.RSA_NO_PADDING`
- * `crypto.constants.RSA_PKCS1_PADDING`
- * `crypto.constants.RSA_PKCS1_OAEP_PADDING`
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.
-All paddings are defined in `crypto.constants`.
-
### crypto.randomBytes(size[, callback])
+- `size` {number}
+- `callback` {Function}
+ - `err` {Error}
+ - `buf` {Buffer}
Generates cryptographically strong pseudo-random data. The `size` argument
is a number indicating the number of bytes to generate.
@@ -1599,6 +1670,8 @@ time is right after boot, when the whole system is still low on entropy.
+- `engine` {string}
+- `flags` {crypto.constants} Defaults to `crypto.constants.ENGINE_METHOD_ALL`.
Load and set the `engine` for some or all OpenSSL functions (selected by flags).
@@ -1626,6 +1699,8 @@ is a bit field taking one of or a mix of the following flags (defined in
+- `a` {Buffer}
+- `b` {Buffer}
Returns true if `a` is equal to `b`, without leaking timing information that
would allow an attacker to guess one of the values. This is suitable for
diff --git a/doc/api/dns.md b/doc/api/dns.md
index 7f075be3114..45d494eab3b 100644
--- a/doc/api/dns.md
+++ b/doc/api/dns.md
@@ -70,33 +70,25 @@ changes:
pr-url: https://github.com/nodejs/node/pull/744
description: The `all` option is supported now.
-->
+- `hostname` {string}
+- `options` {integer | Object}
+ - `family` {integer} The record family. Must be `4` or `6`. IPv4
+ and IPv6 addresses are both returned by default.
+ - `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple
+ flags may be passed by bitwise `OR`ing their values.
+ - `all` {boolean} When `true`, the callback returns all resolved addresses in
+ an array. Otherwise, returns a single address. Defaults to `false`.
+- `callback` {Function}
+ - `err` {Error}
+ - `address` {string} A string representation of an IPv4 or IPv6 address.
+ - `family` {integer} `4` or `6`, denoting the family of `address`.
Resolves a hostname (e.g. `'nodejs.org'`) into the first found A (IPv4) or
-AAAA (IPv6) record. `options` can be an object or integer. If `options` is
-not provided, then IPv4 and IPv6 addresses are both valid. If `options` is
-an integer, then it must be `4` or `6`.
-
-Alternatively, `options` can be an object containing these properties:
-
-* `family` {number} - The record family. If present, must be the integer
- `4` or `6`. If not provided, both IP v4 and v6 addresses are accepted.
-* `hints`: {number} - If present, it should be one or more of the supported
- `getaddrinfo` flags. If `hints` is not provided, then no flags are passed to
- `getaddrinfo`. Multiple flags can be passed through `hints` by bitwise
- `OR`ing their values.
- See [supported `getaddrinfo` flags][] for more information on supported
- flags.
-* `all`: {boolean} - When `true`, the callback returns all resolved addresses
- in an array, otherwise returns a single address. Defaults to `false`.
-
-All properties are optional.
-
-The `callback` function has arguments `(err, address, family)`. `address` is a
-string representation of an IPv4 or IPv6 address. `family` is either the
-integer `4` or `6` and denotes the family of `address` (not necessarily the
-value initially passed to `lookup`).
-
-With the `all` option set to `true`, the arguments change to
+AAAA (IPv6) record. All `option` properties are optional. If `options` is an
+integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
+and IPv6 addresses are both returned if found.
+
+With the `all` option set to `true`, the arguments for `callback` change to
`(err, addresses)`, with `addresses` being an array of objects with the
properties `address` and `family`.
@@ -147,6 +139,12 @@ on some operating systems (e.g FreeBSD 10.1).
+- `address` {string}
+- `port` {number}
+- `callback` {Function}
+ - `err` {Error}
+ - `hostname` {string} e.g. `example.com`
+ - `service` {string} e.g. `http`
Resolves the given `address` and `port` into a hostname and service using
the operating system's underlying `getnameinfo` implementation.
@@ -155,10 +153,7 @@ If `address` is not a valid IP address, a `TypeError` will be thrown.
The `port` will be coerced to a number. If it is not a legal port, a `TypeError`
will be thrown.
-The callback has arguments `(err, hostname, service)`. The `hostname` and
-`service` arguments are strings (e.g. `'localhost'` and `'http'` respectively).
-
-On error, `err` is an [`Error`][] object, where `err.code` is the error code.
+On an error, `err` is an [`Error`][] object, where `err.code` is the error code.
```js
const dns = require('dns');
@@ -172,6 +167,11 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
+- `hostname` {string}
+- `rrtype` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {string[] | Object[] | string[][] | Object}
Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an
array of the record types specified by `rrtype`.
@@ -208,18 +208,21 @@ changes:
description: This method now supports passing `options`,
specifically `options.ttl`.
-->
+- `hostname` {string} Hostname to resolve.
+- `options` {Object}
+ - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
+ When `true`, the callback receives an array of
+ `{ address: '1.2.3.4', ttl: 60 }` objects rather than an array of strings,
+ with the TTL expressed in seconds.
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {string[] | Object[]}
Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the
`hostname`. The `addresses` argument passed to the `callback` function
will contain an array of IPv4 addresses (e.g.
`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
-* `hostname` {string} Hostname to resolve.
-* `options` {Object}
- * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
- The callback receives an array of `{ address: '1.2.3.4', ttl: 60 }` objects
- rather than an array of strings. The TTL is expressed in seconds.
-* `callback` {Function} An `(err, result)` callback function.
## dns.resolve6(hostname[, options], callback)
+- `hostname` {string} Hostname to resolve.
+- `options` {Object}
+ - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
+ When `true`, the callback receives an array of
+ `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` objects rather than an array of
+ strings, with the TTL expressed in seconds.
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {string[] | Object[]}
Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the
`hostname`. The `addresses` argument passed to the `callback` function
will contain an array of IPv6 addresses.
-* `hostname` {string} Hostname to resolve.
-* `options` {Object}
- * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
- The callback receives an array of `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }`
- objects rather than an array of strings. The TTL is expressed in seconds.
-* `callback` {Function} An `(err, result)` callback function.
## dns.resolveCname(hostname, callback)
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {string[]}
Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The
`addresses` argument passed to the `callback` function
@@ -256,6 +266,10 @@ will contain an array of canonical name records available for the `hostname`
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {Object[]}
Uses the DNS protocol to resolve mail exchange records (`MX` records) for the
`hostname`. The `addresses` argument passed to the `callback` function will
@@ -266,11 +280,14 @@ property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {Object[]}
Uses the DNS protocol to resolve regular expression based records (`NAPTR`
-records) for the `hostname`. The `callback` function has arguments
-`(err, addresses)`. The `addresses` argument passed to the `callback` function
-will contain an array of objects with the following properties:
+records) for the `hostname`. The `addresses` argument passed to the `callback`
+function will contain an array of objects with the following properties:
* `flags`
* `service`
@@ -296,16 +313,24 @@ For example:
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {string[]}
Uses the DNS protocol to resolve name server records (`NS` records) for the
`hostname`. The `addresses` argument passed to the `callback` function will
contain an array of name server records available for `hostname`
(e.g. `['ns1.example.com', 'ns2.example.com']`).
-## dns.resolvePtr(hostname, callback)
+## dns.resolvePtr(hostname)
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {string[]}
Uses the DNS protocol to resolve pointer records (`PTR` records) for the
`hostname`. The `addresses` argument passed to the `callback` function will
@@ -315,9 +340,13 @@ be an array of strings containing the reply records.
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `address` {Object}
Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
-the `hostname`. The `addresses` argument passed to the `callback` function will
+the `hostname`. The `address` argument passed to the `callback` function will
be an object with the following properties:
* `nsname`
@@ -344,6 +373,10 @@ be an object with the following properties:
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {Object[]}
Uses the DNS protocol to resolve service records (`SRV` records) for the
`hostname`. The `addresses` argument passed to the `callback` function will
@@ -367,6 +400,10 @@ be an array of objects with the following properties:
+- `hostname` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `addresses` {string[][]}
Uses the DNS protocol to resolve text queries (`TXT` records) for the
`hostname`. The `addresses` argument passed to the `callback` function is
@@ -379,13 +416,14 @@ treated separately.
+- `ip` {string}
+- `callback` {Function}
+ - `err` {Error}
+ - `hostnames` {string[]}
Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
array of hostnames.
-The `callback` function has arguments `(err, hostnames)`, where `hostnames`
-is an array of resolved hostnames for the given `ip`.
-
On error, `err` is an [`Error`][] object, where `err.code` is
one of the [DNS error codes][].
@@ -393,11 +431,12 @@ one of the [DNS error codes][].
+- `servers` {string[]}
Sets the IP addresses of the servers to be used when resolving. The `servers`
argument is an array of IPv4 or IPv6 addresses.
-If a port specified on the address it will be removed.
+If a port is specified on the address, it will be removed.
An error will be thrown if an invalid address is provided.
diff --git a/doc/api/events.md b/doc/api/events.md
index 5f12cfe3191..5c0614b68bf 100644
--- a/doc/api/events.md
+++ b/doc/api/events.md
@@ -98,7 +98,7 @@ listener will be invoked _every time_ the named event is emitted.
```js
const myEmitter = new MyEmitter();
-var m = 0;
+let m = 0;
myEmitter.on('event', () => {
console.log(++m);
});
@@ -114,7 +114,7 @@ the listener is unregistered and *then* called.
```js
const myEmitter = new MyEmitter();
-var m = 0;
+let m = 0;
myEmitter.once('event', () => {
console.log(++m);
});
@@ -148,7 +148,7 @@ can be used. (_Note, however, that the `domain` module has been deprecated_)
const myEmitter = new MyEmitter();
process.on('uncaughtException', (err) => {
- console.log('whoops! there was an error');
+ console.error('whoops! there was an error');
});
myEmitter.emit('error', new Error('whoops!'));
@@ -160,7 +160,7 @@ As a best practice, listeners should always be added for the `'error'` events.
```js
const myEmitter = new MyEmitter();
myEmitter.on('error', (err) => {
- console.log('whoops! there was an error');
+ console.error('whoops! there was an error');
});
myEmitter.emit('error', new Error('whoops!'));
// Prints: whoops! there was an error
@@ -185,7 +185,7 @@ added and `'removeListener'` when existing listeners are removed.
added: v0.1.26
-->
-* `eventName` {string|symbol} The name of the event being listened for
+* `eventName` {any} The name of the event being listened for
* `listener` {Function} The event handler function
The `EventEmitter` instance will emit its own `'newListener'` event *before*
@@ -229,7 +229,7 @@ changes:
now yields the original listener function.
-->
-* `eventName` {string|symbol} The event name
+* `eventName` {any} The event name
* `listener` {Function} The event handler function
The `'removeListener'` event is emitted *after* the `listener` is removed.
@@ -296,6 +296,8 @@ Its `name` property is set to `'MaxListenersExceededWarning'`.
+- `eventName` {any}
+- `listener` {Function}
Alias for `emitter.on(eventName, listener)`.
@@ -303,6 +305,8 @@ Alias for `emitter.on(eventName, listener)`.
+- `eventName` {any}
+- `...args` {any}
Synchronously calls each of the listeners registered for the event named
`eventName`, in the order they were registered, passing the supplied arguments
@@ -345,7 +349,7 @@ set by [`emitter.setMaxListeners(n)`][] or defaults to
added: v3.2.0
-->
-* `eventName` {string|symbol} The name of the event being listened for
+* `eventName` {any} The name of the event being listened for
Returns the number of listeners listening to the event named `eventName`.
@@ -358,6 +362,7 @@ changes:
description: For listeners attached using `.once()` this returns the
original listeners instead of wrapper functions now.
-->
+- `eventName` {any}
Returns a copy of the array of listeners for the event named `eventName`.
@@ -374,7 +379,7 @@ console.log(util.inspect(server.listeners('connection')));
added: v0.1.101
-->
-* `eventName` {string|symbol} The name of the event.
+* `eventName` {any} The name of the event.
* `listener` {Function} The callback function
Adds the `listener` function to the end of the listeners array for the
@@ -410,7 +415,7 @@ myEE.emit('foo');
added: v0.3.0
-->
-* `eventName` {string|symbol} The name of the event.
+* `eventName` {any} The name of the event.
* `listener` {Function} The callback function
Adds a **one time** `listener` function for the event named `eventName`. The
@@ -443,7 +448,7 @@ myEE.emit('foo');
added: v6.0.0
-->
-* `eventName` {string|symbol} The name of the event.
+* `eventName` {any} The name of the event.
* `listener` {Function} The callback function
Adds the `listener` function to the *beginning* of the listeners array for the
@@ -465,7 +470,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
added: v6.0.0
-->
-* `eventName` {string|symbol} The name of the event.
+* `eventName` {any} The name of the event.
* `listener` {Function} The callback function
Adds a **one time** `listener` function for the event named `eventName` to the
@@ -484,6 +489,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
+- `eventName` {any}
Removes all listeners, or those of the specified `eventName`.
@@ -497,12 +503,14 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
+- `eventName` {any}
+- `listener` {Function}
Removes the specified `listener` from the listener array for the event named
`eventName`.
```js
-var callback = (stream) => {
+const callback = (stream) => {
console.log('someone connected!');
};
server.on('connection', callback);
@@ -524,12 +532,12 @@ events will behave as expected.
```js
const myEmitter = new MyEmitter();
-var callbackA = () => {
+const callbackA = () => {
console.log('A');
myEmitter.removeListener('event', callbackB);
};
-var callbackB = () => {
+const callbackB = () => {
console.log('B');
};
@@ -564,6 +572,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
+- `n` {integer}
By default EventEmitters will print a warning if more than `10` listeners are
added for a particular event. This is a useful default that helps finding
diff --git a/doc/api/net.md b/doc/api/net.md
index d20e6bf767e..f1df6911859 100644
--- a/doc/api/net.md
+++ b/doc/api/net.md
@@ -40,7 +40,7 @@ double-backslashes, such as:
```js
net.createServer().listen(
- path.join('\\\\?\\pipe', process.cwd(), 'myctl'))
+ path.join('\\\\?\\pipe', process.cwd(), 'myctl'));
```
## Class: net.Server
@@ -107,7 +107,7 @@ Returns an object with `port`, `family`, and `address` properties:
Example:
```js
-var server = net.createServer((socket) => {
+const server = net.createServer((socket) => {
socket.end('goodbye\n');
}).on('error', (err) => {
// handle errors here
@@ -758,7 +758,7 @@ socket.setTimeout(3000);
socket.on('timeout', () => {
console.log('socket timeout');
socket.end();
-})
+});
```
If `timeout` is 0, then the existing idle timeout is disabled.
@@ -997,8 +997,8 @@ server.listen(8124, () => {
Test this by using `telnet`:
-```sh
-telnet localhost 8124
+```console
+$ telnet localhost 8124
```
To listen on the socket `/tmp/echo.sock` the third line from the last would
@@ -1012,8 +1012,8 @@ server.listen('/tmp/echo.sock', () => {
Use `nc` to connect to a UNIX domain socket server:
-```js
-nc -U /tmp/echo.sock
+```console
+$ nc -U /tmp/echo.sock
```
## net.isIP(input)
diff --git a/doc/api/process.md b/doc/api/process.md
index 0ff80980f9c..2e9b655f28c 100644
--- a/doc/api/process.md
+++ b/doc/api/process.md
@@ -298,7 +298,7 @@ too many listeners have been added to an event
```txt
$ node
-> event.defaultMaxListeners = 1;
+> events.defaultMaxListeners = 1;
> process.on('foo', () => {});
> process.on('foo', () => {});
> (node:38638) Warning: Possible EventEmitter memory leak detected. 2 foo
@@ -311,7 +311,7 @@ adds a custom handler to the `'warning'` event:
```txt
$ node --no-warnings
> var p = process.on('warning', (warning) => console.warn('Do not do that!'));
-> event.defaultMaxListeners = 1;
+> events.defaultMaxListeners = 1;
> process.on('foo', () => {});
> process.on('foo', () => {});
> Do not do that!
diff --git a/doc/api/stream.md b/doc/api/stream.md
index c48dfe05080..75cba6fd514 100644
--- a/doc/api/stream.md
+++ b/doc/api/stream.md
@@ -1016,7 +1016,7 @@ function parseHeader(stream, callback) {
const remaining = split.join('\n\n');
const buf = Buffer.from(remaining, 'utf8');
stream.removeListener('error', callback);
- // set the readable listener before unshifting
+ // remove the readable listener before unshifting
stream.removeListener('readable', onReadable);
if (buf.length)
stream.unshift(buf);
diff --git a/doc/changelogs/CHANGELOG_V7.md b/doc/changelogs/CHANGELOG_V7.md
index 53c6b345ba4..45dda5d2edd 100644
--- a/doc/changelogs/CHANGELOG_V7.md
+++ b/doc/changelogs/CHANGELOG_V7.md
@@ -6,6 +6,8 @@
|