Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit a5cb4e2

Browse files
committed
Merge remote-tracking branch 'upstream/v10.x' into v10.x
2 parents e75d19a + 0d56982 commit a5cb4e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+442
-500
lines changed

BUILDING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ If you are running tests prior to submitting a Pull Request, the recommended
179179
command is:
180180

181181
```console
182-
$ make test
182+
$ make -j4 test
183183
```
184184

185-
`make test` does a full check on the codebase, including running linters and
185+
`make -j4 test` does a full check on the codebase, including running linters and
186186
documentation tests.
187187

188188
Optionally, continue below.

doc/api/assert.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,10 @@ function and awaits the returned promise to complete. It will then check that
387387
the promise is not rejected.
388388

389389
If `block` is a function and it throws an error synchronously,
390-
`assert.doesNotReject()` will return a rejected Promise with that error without
391-
checking the error handler.
390+
`assert.doesNotReject()` will return a rejected Promise with that error. If the
391+
function does not return a promise, `assert.doesNotReject()` will return a
392+
rejected Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the
393+
error handler is skipped.
392394

393395
Please note: Using `assert.doesNotReject()` is actually not useful because there
394396
is little benefit by catching a rejection and then rejecting it again. Instead,
@@ -929,8 +931,10 @@ function and awaits the returned promise to complete. It will then check that
929931
the promise is rejected.
930932

931933
If `block` is a function and it throws an error synchronously,
932-
`assert.rejects()` will return a rejected Promise with that error without
933-
checking the error handler.
934+
`assert.rejects()` will return a rejected Promise with that error. If the
935+
function does not return a promise, `assert.rejects()` will return a rejected
936+
Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error
937+
handler is skipped.
934938

935939
Besides the async nature to await the completion behaves identically to
936940
[`assert.throws()`][].
@@ -1138,6 +1142,7 @@ assert.throws(throwingFirst, /Second$/);
11381142
Due to the confusing notation, it is recommended not to use a string as the
11391143
second argument. This might lead to difficult-to-spot errors.
11401144

1145+
[`ERR_INVALID_RETURN_VALUE`]: errors.html#errors_err_invalid_return_value
11411146
[`Class`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
11421147
[`Error.captureStackTrace`]: errors.html#errors_error_capturestacktrace_targetobject_constructoropt
11431148
[`Error`]: errors.html#errors_class_error

doc/api/buffer.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# Buffer
22

33
<!--introduced_in=v0.1.90-->
4-
<!--lint disable maximum-line-length-->
54

65
> Stability: 2 - Stable
76
87
Prior to the introduction of [`TypedArray`], the JavaScript language had no
98
mechanism for reading or manipulating streams of binary data. The `Buffer` class
10-
was introduced as part of the Node.js API to make it possible to interact with
11-
octet streams in the context of things like TCP streams and file system
12-
operations.
9+
was introduced as part of the Node.js API to enable interaction with octet
10+
streams in TCP streams, file system operations, and other contexts.
1311

1412
With [`TypedArray`] now available, the `Buffer` class implements the
1513
[`Uint8Array`] API in a manner that is more optimized and suitable for Node.js.
@@ -81,7 +79,7 @@ to one of these new APIs.*
8179

8280
* [`Buffer.from(array)`] returns a new `Buffer` that *contains a copy* of the
8381
provided octets.
84-
* [`Buffer.from(arrayBuffer[, byteOffset [, length]])`][`Buffer.from(arrayBuffer)`]
82+
* [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
8583
returns a new `Buffer` that *shares the same allocated memory* as the given
8684
[`ArrayBuffer`].
8785
* [`Buffer.from(buffer)`] returns a new `Buffer` that *contains a copy* of the
@@ -194,8 +192,8 @@ Modern Web browsers follow the [WHATWG Encoding Standard][] which aliases
194192
both `'latin1'` and `'ISO-8859-1'` to `'win-1252'`. This means that while doing
195193
something like `http.get()`, if the returned charset is one of those listed in
196194
the WHATWG specification it is possible that the server actually returned
197-
win-1252-encoded data, and using `'latin1'` encoding may incorrectly decode the
198-
characters.
195+
`'win-1252'`-encoded data, and using `'latin1'` encoding may incorrectly decode
196+
the characters.
199197

200198
## Buffers and TypedArray
201199
<!-- YAML
@@ -273,7 +271,7 @@ function:
273271

274272
* [`Buffer.from(array)`]
275273
* [`Buffer.from(buffer)`]
276-
* [`Buffer.from(arrayBuffer[, byteOffset [, length]])`][`Buffer.from(arrayBuffer)`]
274+
* [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
277275
* [`Buffer.from(string[, encoding])`][`Buffer.from(string)`]
278276

279277
## Buffers and iteration
@@ -327,7 +325,7 @@ Allocates a new `Buffer` using an `array` of octets.
327325
const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
328326
```
329327

330-
### new Buffer(arrayBuffer[, byteOffset [, length]])
328+
### new Buffer(arrayBuffer[, byteOffset[, length]])
331329
<!-- YAML
332330
added: v3.0.0
333331
deprecated: v6.0.0
@@ -348,7 +346,7 @@ changes:
348346
-->
349347

350348
> Stability: 0 - Deprecated: Use
351-
> [`Buffer.from(arrayBuffer[, byteOffset [, length]])`][`Buffer.from(arrayBuffer)`]
349+
> [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
352350
> instead.
353351
354352
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`],
@@ -402,7 +400,8 @@ changes:
402400

403401
> Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`] instead.
404402
405-
* `buffer` {Buffer} An existing `Buffer` to copy data from.
403+
* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which
404+
to copy data.
406405

407406
Copies the passed `buffer` data onto a new `Buffer` instance.
408407

@@ -842,7 +841,8 @@ A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`] or a
842841
added: v5.10.0
843842
-->
844843

845-
* `buffer` {Buffer} An existing `Buffer` to copy data from.
844+
* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which
845+
to copy data.
846846

847847
Copies the passed `buffer` data onto a new `Buffer` instance.
848848

@@ -1887,7 +1887,7 @@ added: v5.10.0
18871887
* Returns: {Buffer} A reference to `buf`.
18881888

18891889
Interprets `buf` as an array of unsigned 16-bit integers and swaps the
1890-
byte-order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is
1890+
byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is
18911891
not a multiple of 2.
18921892

18931893
```js
@@ -1915,7 +1915,7 @@ added: v5.10.0
19151915
* Returns: {Buffer} A reference to `buf`.
19161916

19171917
Interprets `buf` as an array of unsigned 32-bit integers and swaps the
1918-
byte-order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is
1918+
byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is
19191919
not a multiple of 4.
19201920

19211921
```js
@@ -1942,9 +1942,8 @@ added: v6.3.0
19421942

19431943
* Returns: {Buffer} A reference to `buf`.
19441944

1945-
Interprets `buf` as an array of 64-bit numbers and swaps the byte-order
1946-
*in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is not a
1947-
multiple of 8.
1945+
Interprets `buf` as an array of 64-bit numbers and swaps byte order *in-place*.
1946+
Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is not a multiple of 8.
19481947

19491948
```js
19501949
const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
@@ -2074,19 +2073,21 @@ for (const value of buf) {
20742073
added: v0.1.90
20752074
-->
20762075

2077-
* `string` {string} String to be written to `buf`.
2078-
* `offset` {integer} Number of bytes to skip before starting to write `string`. **Default:** `0`.
2079-
* `length` {integer} Number of bytes to write. **Default:** `buf.length - offset`.
2076+
* `string` {string} String to write to `buf`.
2077+
* `offset` {integer} Number of bytes to skip before starting to write `string`.
2078+
**Default:** `0`.
2079+
* `length` {integer} Number of bytes to write. **Default:**
2080+
`buf.length - offset`.
20802081
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
20812082
* Returns: {integer} Number of bytes written.
20822083

2083-
Writes `string` to `buf` at `offset` according to the character encoding in `encoding`.
2084-
The `length` parameter is the number of bytes to write. If `buf` did not contain
2085-
enough space to fit the entire string, only a partial amount of `string` will
2086-
be written. However, partially encoded characters will not be written.
2084+
Writes `string` to `buf` at `offset` according to the character encoding in
2085+
`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
2086+
not contain enough space to fit the entire string, only part of `string` will be
2087+
written. However, partially encoded characters will not be written.
20872088

20882089
```js
2089-
const buf = Buffer.allocUnsafe(256);
2090+
const buf = Buffer.alloc(256);
20902091

20912092
const len = buf.write('\u00bd + \u00bc = \u00be', 0);
20922093

@@ -2213,8 +2214,8 @@ changes:
22132214

22142215
Writes `value` to `buf` at the specified `offset` with specified endian
22152216
format (`writeInt16BE()` writes big endian, `writeInt16LE()` writes little
2216-
endian). `value` *should* be a valid signed 16-bit integer. Behavior is undefined
2217-
when `value` is anything other than a signed 16-bit integer.
2217+
endian). `value` *should* be a valid signed 16-bit integer. Behavior is
2218+
undefined when `value` is anything other than a signed 16-bit integer.
22182219

22192220
`value` is interpreted and written as a two's complement signed integer.
22202221

@@ -2246,8 +2247,8 @@ changes:
22462247

22472248
Writes `value` to `buf` at the specified `offset` with specified endian
22482249
format (`writeInt32BE()` writes big endian, `writeInt32LE()` writes little
2249-
endian). `value` *should* be a valid signed 32-bit integer. Behavior is undefined
2250-
when `value` is anything other than a signed 32-bit integer.
2250+
endian). `value` *should* be a valid signed 32-bit integer. Behavior is
2251+
undefined when `value` is anything other than a signed 32-bit integer.
22512252

22522253
`value` is interpreted and written as a two's complement signed integer.
22532254

@@ -2605,7 +2606,7 @@ This value may depend on the JS engine that is being used.
26052606
[`Buffer.allocUnsafe()`]: #buffer_class_method_buffer_allocunsafe_size
26062607
[`Buffer.allocUnsafeSlow()`]: #buffer_class_method_buffer_allocunsafeslow_size
26072608
[`Buffer.from(array)`]: #buffer_class_method_buffer_from_array
2608-
[`Buffer.from(arrayBuffer)`]: #buffer_class_method_buffer_from_arraybuffer_byteoffset_length
2609+
[`Buffer.from(arrayBuf)`]: #buffer_class_method_buffer_from_arraybuffer_byteoffset_length
26092610
[`Buffer.from(buffer)`]: #buffer_class_method_buffer_from_buffer
26102611
[`Buffer.from(string)`]: #buffer_class_method_buffer_from_string_encoding
26112612
[`Buffer.poolSize`]: #buffer_class_property_buffer_poolsize

doc/api/console.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ added: v0.1.104
425425
* `message` {any}
426426
* `...args` {any}
427427

428-
Prints to `stderr` the string `'Trace :'`, followed by the [`util.format()`][]
428+
Prints to `stderr` the string `'Trace: '`, followed by the [`util.format()`][]
429429
formatted message and stack trace to the current position in the code.
430430

431431
```js

doc/api/errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,12 @@ An invalid `options.protocol` was passed.
11861186
Both `breakEvalOnSigint` and `eval` options were set in the REPL config, which
11871187
is not supported.
11881188

1189+
<a id="ERR_INVALID_RETURN_VALUE"></a>
1190+
### ERR_INVALID_RETURN_VALUE
1191+
1192+
Thrown in case a function option does not return an expected value on execution.
1193+
For example when a function is expected to return a promise.
1194+
11891195
<a id="ERR_INVALID_SYNC_FORK_INPUT"></a>
11901196
### ERR_INVALID_SYNC_FORK_INPUT
11911197

0 commit comments

Comments
 (0)