|
6 | 6 |
|
7 | 7 | Prior to the introduction of [`TypedArray`], the JavaScript language had no
|
8 | 8 | mechanism for reading or manipulating streams of binary data. The `Buffer` class
|
9 |
| -was introduced as part of the Node.js API to make it possible to interact with |
10 |
| -octet streams in the context of things like TCP streams and file system |
11 |
| -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. |
12 | 11 |
|
13 | 12 | With [`TypedArray`] now available, the `Buffer` class implements the
|
14 | 13 | [`Uint8Array`] API in a manner that is more optimized and suitable for Node.js.
|
@@ -195,11 +194,11 @@ The character encodings currently supported by Node.js include:
|
195 | 194 | * `'hex'` - Encode each byte as two hexadecimal characters.
|
196 | 195 |
|
197 | 196 | *Note*: Today's browsers follow the [WHATWG Encoding Standard][] which aliases
|
198 |
| -both 'latin1' and ISO-8859-1 to win-1252. This means that while doing something |
199 |
| -like `http.get()`, if the returned charset is one of those listed in the WHATWG |
200 |
| -specification it is possible that the server actually returned |
201 |
| -win-1252-encoded data, and using `'latin1'` encoding may incorrectly decode the |
202 |
| -characters. |
| 197 | +both `'latin1'` and `'ISO-8859-1'` to `'win-1252'`. This means that while doing |
| 198 | +something like `http.get()`, if the returned charset is one of those listed in |
| 199 | +the WHATWG specification it is possible that the server actually returned |
| 200 | +`'win-1252'`-encoded data, and using `'latin1'` encoding may incorrectly decode |
| 201 | +the characters. |
203 | 202 |
|
204 | 203 | ## Buffers and TypedArray
|
205 | 204 | <!-- YAML
|
@@ -338,7 +337,7 @@ Example:
|
338 | 337 | const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
339 | 338 | ```
|
340 | 339 |
|
341 |
| -### new Buffer(arrayBuffer[, byteOffset [, length]]) |
| 340 | +### new Buffer(arrayBuffer[, byteOffset[, length]]) |
342 | 341 | <!-- YAML
|
343 | 342 | added: v3.0.0
|
344 | 343 | deprecated: v6.0.0
|
@@ -407,7 +406,8 @@ changes:
|
407 | 406 |
|
408 | 407 | > Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`] instead.
|
409 | 408 |
|
410 |
| -* `buffer` {Buffer} An existing `Buffer` to copy data from. |
| 409 | +* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which |
| 410 | + to copy data. |
411 | 411 |
|
412 | 412 | Copies the passed `buffer` data onto a new `Buffer` instance.
|
413 | 413 |
|
@@ -862,7 +862,8 @@ A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`] or a
|
862 | 862 | added: v5.10.0
|
863 | 863 | -->
|
864 | 864 |
|
865 |
| -* `buffer` {Buffer} An existing `Buffer` to copy data from. |
| 865 | +* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which |
| 866 | + to copy data. |
866 | 867 |
|
867 | 868 | Copies the passed `buffer` data onto a new `Buffer` instance.
|
868 | 869 |
|
@@ -1983,7 +1984,7 @@ added: v5.10.0
|
1983 | 1984 |
|
1984 | 1985 | * Returns: {Buffer} A reference to `buf`.
|
1985 | 1986 |
|
1986 |
| -Interprets `buf` as an array of unsigned 16-bit integers and swaps the byte-order |
| 1987 | +Interprets `buf` as an array of unsigned 16-bit integers and swaps the byte order |
1987 | 1988 | *in-place*. Throws a `RangeError` if [`buf.length`] is not a multiple of 2.
|
1988 | 1989 |
|
1989 | 1990 | Examples:
|
@@ -2013,7 +2014,7 @@ added: v5.10.0
|
2013 | 2014 |
|
2014 | 2015 | * Returns: {Buffer} A reference to `buf`.
|
2015 | 2016 |
|
2016 |
| -Interprets `buf` as an array of unsigned 32-bit integers and swaps the byte-order |
| 2017 | +Interprets `buf` as an array of unsigned 32-bit integers and swaps the byte order |
2017 | 2018 | *in-place*. Throws a `RangeError` if [`buf.length`] is not a multiple of 4.
|
2018 | 2019 |
|
2019 | 2020 | Examples:
|
@@ -2043,7 +2044,7 @@ added: v6.3.0
|
2043 | 2044 |
|
2044 | 2045 | * Returns: {Buffer} A reference to `buf`.
|
2045 | 2046 |
|
2046 |
| -Interprets `buf` as an array of 64-bit numbers and swaps the byte-order *in-place*. |
| 2047 | +Interprets `buf` as an array of 64-bit numbers and swaps the byte order *in-place*. |
2047 | 2048 | Throws a `RangeError` if [`buf.length`] is not a multiple of 8.
|
2048 | 2049 |
|
2049 | 2050 | Examples:
|
|
0 commit comments