66
77Prior to the introduction of [ ` TypedArray ` ] , the JavaScript language had no
88mechanism 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.
1211
1312With [ ` TypedArray ` ] now available, the ` Buffer ` class implements the
1413[ ` Uint8Array ` ] API in a manner that is more optimized and suitable for Node.js.
@@ -193,8 +192,8 @@ Modern Web browsers follow the [WHATWG Encoding Standard][] which aliases
193192both ` 'latin1' ` and ` 'ISO-8859-1' ` to ` 'win-1252' ` . This means that while doing
194193something like ` http.get() ` , if the returned charset is one of those listed in
195194the WHATWG specification it is possible that the server actually returned
196- win-1252-encoded data, and using ` 'latin1' ` encoding may incorrectly decode the
197- characters.
195+ ` ' win-1252' ` -encoded data, and using ` 'latin1' ` encoding may incorrectly decode
196+ the characters.
198197
199198## Buffers and TypedArray
200199<!-- YAML
@@ -326,7 +325,7 @@ Allocates a new `Buffer` using an `array` of octets.
326325const buf = new Buffer ([0x62 , 0x75 , 0x66 , 0x66 , 0x65 , 0x72 ]);
327326```
328327
329- ### new Buffer(arrayBuffer[ , byteOffset [ , length]] )
328+ ### new Buffer(arrayBuffer[ , byteOffset[ , length]] )
330329<!-- YAML
331330added: v3.0.0
332331deprecated: v6.0.0
@@ -401,7 +400,8 @@ changes:
401400
402401> Stability: 0 - Deprecated: Use [ ` Buffer.from(buffer) ` ] instead.
403402
404- * ` buffer ` {Buffer} An existing ` Buffer ` to copy data from.
403+ * ` buffer ` {Buffer|Uint8Array} An existing ` Buffer ` or [ ` Uint8Array ` ] from which
404+ to copy data.
405405
406406Copies the passed ` buffer ` data onto a new ` Buffer ` instance.
407407
@@ -841,7 +841,8 @@ A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`] or a
841841added: v5.10.0
842842-->
843843
844- * ` buffer ` {Buffer} An existing ` Buffer ` to copy data from.
844+ * ` buffer ` {Buffer|Uint8Array} An existing ` Buffer ` or [ ` Uint8Array ` ] from which
845+ to copy data.
845846
846847Copies the passed ` buffer ` data onto a new ` Buffer ` instance.
847848
@@ -1886,7 +1887,7 @@ added: v5.10.0
18861887* Returns: {Buffer} A reference to ` buf ` .
18871888
18881889Interprets ` buf ` as an array of unsigned 16-bit integers and swaps the
1889- 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
18901891not a multiple of 2.
18911892
18921893``` js
@@ -1914,7 +1915,7 @@ added: v5.10.0
19141915* Returns: {Buffer} A reference to ` buf ` .
19151916
19161917Interprets ` buf ` as an array of unsigned 32-bit integers and swaps the
1917- 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
19181919not a multiple of 4.
19191920
19201921``` js
@@ -1941,9 +1942,8 @@ added: v6.3.0
19411942
19421943* Returns: {Buffer} A reference to ` buf ` .
19431944
1944- Interprets ` buf ` as an array of 64-bit numbers and swaps the byte-order
1945- * in-place* . Throws [ ` ERR_INVALID_BUFFER_SIZE ` ] if [ ` buf.length ` ] is not a
1946- 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.
19471947
19481948``` js
19491949const buf1 = Buffer .from ([0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 ]);
0 commit comments