diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 983d2bbe453c57..9aa7d0d9cbbbda 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -138,6 +138,15 @@ extra care *must* be taken in order to avoid introducing security vulnerabilities into an application. ## Buffers and Character Encodings + `Buffer` instances are commonly used to represent sequences of encoded characters such as UTF-8, UCS2, Base64 or even Hex-encoded data. It is possible to @@ -188,6 +197,12 @@ that the server actually returned win-1252-encoded data, and using `'latin1'` encoding may incorrectly decode the characters. ## Buffers and TypedArray + `Buffer` instances are also [`Uint8Array`] instances. However, there are subtle incompatibilities with the TypedArray specification in ECMAScript 2015. @@ -298,6 +313,13 @@ It can be constructed in a variety of ways. ### new Buffer(array) > Stability: 0 - Deprecated: Use [`Buffer.from(array)`] instead. @@ -315,7 +337,18 @@ const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); ### new Buffer(arrayBuffer[, byteOffset [, length]]) > Stability: 0 - Deprecated: Use @@ -360,6 +393,13 @@ console.log(buf); ### new Buffer(buffer) > Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`] instead. @@ -386,6 +426,13 @@ console.log(buf2.toString()); ### new Buffer(size) > Stability: 0 - Deprecated: Use [`Buffer.alloc()`] instead (also see @@ -419,6 +466,13 @@ console.log(buf); ### new Buffer(string[, encoding]) > Stability: 0 - Deprecated: @@ -508,6 +562,10 @@ A `TypeError` will be thrown if `size` is not a number. ### Class Method: Buffer.allocUnsafe(size) * `size` {Integer} The desired length of the new `Buffer` @@ -606,6 +664,14 @@ A `TypeError` will be thrown if `size` is not a number. ### Class Method: Buffer.byteLength(string[, encoding]) * `string` {String | Buffer | TypedArray | DataView | ArrayBuffer} A value to @@ -886,6 +952,10 @@ console.log(buf.toString('ascii')); ### buf.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]]) * `target` {Buffer} A `Buffer` to compare to @@ -1066,6 +1136,10 @@ console.log(buf1.equals(buf3)); ### buf.fill(value[, offset[, end]][, encoding]) * `value` {String | Buffer | Integer} The value to fill `buf` with @@ -1144,6 +1218,11 @@ console.log(buf.includes('this', 4)); ### buf.indexOf(value[, byteOffset][, encoding]) * `value` {String | Buffer | Integer} What to search for @@ -1710,6 +1789,15 @@ console.log(buf.readUIntBE(1, 6).toString(16)); ### buf.slice([start[, end]]) * `start` {Integer} Where the new `Buffer` will start. **Default:** `0`