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

Commit

Permalink
Merge remote-tracking branch 'upstream/v10.x' into v10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarnung committed Apr 21, 2018
2 parents e75d19a + 0d56982 commit a5cb4e2
Show file tree
Hide file tree
Showing 43 changed files with 442 additions and 500 deletions.
4 changes: 2 additions & 2 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ If you are running tests prior to submitting a Pull Request, the recommended
command is:

```console
$ make test
$ make -j4 test
```

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

Optionally, continue below.
Expand Down
13 changes: 9 additions & 4 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ function and awaits the returned promise to complete. It will then check that
the promise is not rejected.

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

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

If `block` is a function and it throws an error synchronously,
`assert.rejects()` will return a rejected Promise with that error without
checking the error handler.
`assert.rejects()` will return a rejected Promise with that error. If the
function does not return a promise, `assert.rejects()` will return a rejected
Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error
handler is skipped.

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

[`ERR_INVALID_RETURN_VALUE`]: errors.html#errors_err_invalid_return_value
[`Class`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
[`Error.captureStackTrace`]: errors.html#errors_error_capturestacktrace_targetobject_constructoropt
[`Error`]: errors.html#errors_class_error
Expand Down
61 changes: 31 additions & 30 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Buffer

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

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

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

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

## Buffers and TypedArray
<!-- YAML
Expand Down Expand Up @@ -273,7 +271,7 @@ function:

* [`Buffer.from(array)`]
* [`Buffer.from(buffer)`]
* [`Buffer.from(arrayBuffer[, byteOffset [, length]])`][`Buffer.from(arrayBuffer)`]
* [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
* [`Buffer.from(string[, encoding])`][`Buffer.from(string)`]

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

### new Buffer(arrayBuffer[, byteOffset [, length]])
### new Buffer(arrayBuffer[, byteOffset[, length]])
<!-- YAML
added: v3.0.0
deprecated: v6.0.0
Expand All @@ -348,7 +346,7 @@ changes:
-->

> Stability: 0 - Deprecated: Use
> [`Buffer.from(arrayBuffer[, byteOffset [, length]])`][`Buffer.from(arrayBuffer)`]
> [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
> instead.
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`],
Expand Down Expand Up @@ -402,7 +400,8 @@ changes:

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

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

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

* `buffer` {Buffer} An existing `Buffer` to copy data from.
* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which
to copy data.

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

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

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

```js
Expand Down Expand Up @@ -1915,7 +1915,7 @@ added: v5.10.0
* Returns: {Buffer} A reference to `buf`.

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

```js
Expand All @@ -1942,9 +1942,8 @@ added: v6.3.0

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

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

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

* `string` {string} String to be written to `buf`.
* `offset` {integer} Number of bytes to skip before starting to write `string`. **Default:** `0`.
* `length` {integer} Number of bytes to write. **Default:** `buf.length - offset`.
* `string` {string} String to write to `buf`.
* `offset` {integer} Number of bytes to skip before starting to write `string`.
**Default:** `0`.
* `length` {integer} Number of bytes to write. **Default:**
`buf.length - offset`.
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
* Returns: {integer} Number of bytes written.

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

```js
const buf = Buffer.allocUnsafe(256);
const buf = Buffer.alloc(256);

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

Expand Down Expand Up @@ -2213,8 +2214,8 @@ changes:

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

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

Expand Down Expand Up @@ -2246,8 +2247,8 @@ changes:

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

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

Expand Down Expand Up @@ -2605,7 +2606,7 @@ This value may depend on the JS engine that is being used.
[`Buffer.allocUnsafe()`]: #buffer_class_method_buffer_allocunsafe_size
[`Buffer.allocUnsafeSlow()`]: #buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: #buffer_class_method_buffer_from_array
[`Buffer.from(arrayBuffer)`]: #buffer_class_method_buffer_from_arraybuffer_byteoffset_length
[`Buffer.from(arrayBuf)`]: #buffer_class_method_buffer_from_arraybuffer_byteoffset_length
[`Buffer.from(buffer)`]: #buffer_class_method_buffer_from_buffer
[`Buffer.from(string)`]: #buffer_class_method_buffer_from_string_encoding
[`Buffer.poolSize`]: #buffer_class_property_buffer_poolsize
Expand Down
2 changes: 1 addition & 1 deletion doc/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ added: v0.1.104
* `message` {any}
* `...args` {any}

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

```js
Expand Down
6 changes: 6 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,12 @@ An invalid `options.protocol` was passed.
Both `breakEvalOnSigint` and `eval` options were set in the REPL config, which
is not supported.

<a id="ERR_INVALID_RETURN_VALUE"></a>
### ERR_INVALID_RETURN_VALUE

Thrown in case a function option does not return an expected value on execution.
For example when a function is expected to return a promise.

<a id="ERR_INVALID_SYNC_FORK_INPUT"></a>
### ERR_INVALID_SYNC_FORK_INPUT

Expand Down
Loading

0 comments on commit a5cb4e2

Please sign in to comment.