diff options
author | Rich Trott <rtrott@gmail.com> | 2019-12-24 00:10:25 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-01-03 18:21:49 +0300 |
commit | 0e0d45b02fd0a98baaac428292312e47b0db8e30 (patch) | |
tree | 21a6ef423c83e9b7cdc7b34ad14f70705d34457e /doc/api | |
parent | 32e5895a2f179fc1c1bdbe1844473520a80b2003 (diff) |
doc,buffer: use code markup/markdown in headers
PR-URL: https://github.com/nodejs/node/pull/31086
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'doc/api')
-rw-r--r-- | doc/api/buffer.md | 188 |
1 files changed, 94 insertions, 94 deletions
diff --git a/doc/api/buffer.md b/doc/api/buffer.md index c5b7bf15047..c94f03fa065 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -311,12 +311,12 @@ for (const b of buf) { Additionally, the [`buf.values()`][], [`buf.keys()`][], and [`buf.entries()`][] methods can be used to create iterators. -## Class: Buffer +## Class: `Buffer` The `Buffer` class is a global type for dealing with binary data directly. It can be constructed in a variety of ways. -### new Buffer(array) +### `new Buffer(array)` <!-- YAML deprecated: v6.0.0 changes: @@ -343,7 +343,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 @@ -400,7 +400,7 @@ console.log(buf); // Prints: <Buffer 88 13 70 17> ``` -### new Buffer(buffer) +### `new Buffer(buffer)` <!-- YAML deprecated: v6.0.0 changes: @@ -435,7 +435,7 @@ console.log(buf2.toString()); // Prints: buffer ``` -### new Buffer(size) +### `new Buffer(size)` <!-- YAML deprecated: v6.0.0 changes: @@ -477,7 +477,7 @@ console.log(buf); // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00> ``` -### new Buffer(string\[, encoding\]) +### `new Buffer(string[, encoding])` <!-- YAML deprecated: v6.0.0 changes: @@ -514,7 +514,7 @@ console.log(buf1.toString('ascii')); // Prints: this is a tC)st ``` -### Class Method: Buffer.alloc(size\[, fill\[, encoding\]\]) +### Class Method: `Buffer.alloc(size[, fill[, encoding]])` <!-- YAML added: v5.10.0 changes: @@ -578,7 +578,7 @@ contents will *never contain sensitive data*. A `TypeError` will be thrown if `size` is not a number. -### Class Method: Buffer.allocUnsafe(size) +### Class Method: `Buffer.allocUnsafe(size)` <!-- YAML added: v5.10.0 changes: @@ -626,7 +626,7 @@ pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal difference is subtle but can be important when an application requires the additional performance that [`Buffer.allocUnsafe()`][] provides. -### Class Method: Buffer.allocUnsafeSlow(size) +### Class Method: `Buffer.allocUnsafeSlow(size)` <!-- YAML added: v5.12.0 --> @@ -677,7 +677,7 @@ developer has observed undue memory retention in their applications. A `TypeError` will be thrown if `size` is not a number. -### Class Method: Buffer.byteLength(string\[, encoding\]) +### Class Method: `Buffer.byteLength(string[, encoding])` <!-- YAML added: v0.1.90 changes: @@ -715,7 +715,7 @@ console.log(`${str}: ${str.length} characters, ` + When `string` is a `Buffer`/[`DataView`][]/[`TypedArray`][]/[`ArrayBuffer`][]/ [`SharedArrayBuffer`][], the actual byte length is returned. -### Class Method: Buffer.compare(buf1, buf2) +### Class Method: `Buffer.compare(buf1, buf2)` <!-- YAML added: v0.11.13 changes: @@ -742,7 +742,7 @@ console.log(arr.sort(Buffer.compare)); // (This result is equal to: [buf2, buf1].) ``` -### Class Method: Buffer.concat(list\[, totalLength\]) +### Class Method: `Buffer.concat(list[, totalLength])` <!-- YAML added: v0.7.11 changes: @@ -791,7 +791,7 @@ console.log(bufA.length); // Prints: 42 ``` -### Class Method: Buffer.from(array) +### Class Method: `Buffer.from(array)` <!-- YAML added: v5.10.0 --> @@ -808,7 +808,7 @@ const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); A `TypeError` will be thrown if `array` is not an `Array` or other type appropriate for `Buffer.from()` variants. -### Class Method: Buffer.from(arrayBuffer\[, byteOffset\[, length\]\]) +### Class Method: `Buffer.from(arrayBuffer[, byteOffset[, length]])` <!-- YAML added: v5.10.0 --> @@ -857,7 +857,7 @@ console.log(buf.length); A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`][] or a [`SharedArrayBuffer`][] or other type appropriate for `Buffer.from()` variants. -### Class Method: Buffer.from(buffer) +### Class Method: `Buffer.from(buffer)` <!-- YAML added: v5.10.0 --> @@ -882,7 +882,7 @@ console.log(buf2.toString()); A `TypeError` will be thrown if `buffer` is not a `Buffer` or other type appropriate for `Buffer.from()` variants. -### Class Method: Buffer.from(object\[, offsetOrEncoding\[, length\]\]) +### Class Method: `Buffer.from(object[, offsetOrEncoding[, length]])` <!-- YAML added: v8.2.0 --> @@ -919,7 +919,7 @@ const buf = Buffer.from(new Foo(), 'utf8'); A `TypeError` will be thrown if `object` has not mentioned methods or is not of other type appropriate for `Buffer.from()` variants. -### Class Method: Buffer.from(string\[, encoding\]) +### Class Method: `Buffer.from(string[, encoding])` <!-- YAML added: v5.10.0 --> @@ -945,7 +945,7 @@ console.log(buf1.toString('ascii')); A `TypeError` will be thrown if `string` is not a string or other type appropriate for `Buffer.from()` variants. -### Class Method: Buffer.isBuffer(obj) +### Class Method: `Buffer.isBuffer(obj)` <!-- YAML added: v0.1.101 --> @@ -955,7 +955,7 @@ added: v0.1.101 Returns `true` if `obj` is a `Buffer`, `false` otherwise. -### Class Method: Buffer.isEncoding(encoding) +### Class Method: `Buffer.isEncoding(encoding)` <!-- YAML added: v0.9.1 --> @@ -980,7 +980,7 @@ console.log(Buffer.isEncoding('')); // Prints: false ``` -### Class Property: Buffer.poolSize +### Class Property: `Buffer.poolSize` <!-- YAML added: v0.11.3 --> @@ -990,7 +990,7 @@ added: v0.11.3 This is the size (in bytes) of pre-allocated internal `Buffer` instances used for pooling. This value may be modified. -### buf\[index\] +### `buf[index]` <!-- YAML type: property name: [index] @@ -1020,7 +1020,7 @@ console.log(buf.toString('ascii')); // Prints: Node.js ``` -### buf.buffer +### `buf.buffer` * {ArrayBuffer} The underlying `ArrayBuffer` object based on which this `Buffer` object is created. @@ -1036,7 +1036,7 @@ console.log(buffer.buffer === arrayBuffer); // Prints: true ``` -### buf.byteOffset +### `buf.byteOffset` * {integer} The `byteOffset` on the underlying `ArrayBuffer` object based on which this `Buffer` object is created. @@ -1061,7 +1061,7 @@ const nodeBuffer = new Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); new Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length); ``` -### buf.compare(target\[, targetStart\[, targetEnd\[, sourceStart\[, sourceEnd\]\]\]\]) +### `buf.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]])` <!-- YAML added: v0.11.13 changes: @@ -1132,7 +1132,7 @@ console.log(buf1.compare(buf2, 5, 6, 5)); [`ERR_OUT_OF_RANGE`][] is thrown if `targetStart < 0`, `sourceStart < 0`, `targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`. -### buf.copy(target\[, targetStart\[, sourceStart\[, sourceEnd\]\]\]) +### `buf.copy(target[, targetStart[, sourceStart[, sourceEnd]]])` <!-- YAML added: v0.1.90 --> @@ -1183,7 +1183,7 @@ console.log(buf.toString()); // Prints: efghijghijklmnopqrstuvwxyz ``` -### buf.entries() +### `buf.entries()` <!-- YAML added: v1.1.0 --> @@ -1210,7 +1210,7 @@ for (const pair of buf.entries()) { // [5, 114] ``` -### buf.equals(otherBuffer) +### `buf.equals(otherBuffer)` <!-- YAML added: v0.11.13 changes: @@ -1237,7 +1237,7 @@ console.log(buf1.equals(buf3)); // Prints: false ``` -### buf.fill(value\[, offset\[, end\]\]\[, encoding\]) +### `buf.fill(value[, offset[, end]][, encoding])` <!-- YAML added: v0.5.0 changes: @@ -1309,7 +1309,7 @@ console.log(buf.fill('zz', 'hex')); // Throws an exception. ``` -### buf.includes(value\[, byteOffset\]\[, encoding\]) +### `buf.includes(value[, byteOffset][, encoding])` <!-- YAML added: v5.3.0 --> @@ -1342,7 +1342,7 @@ console.log(buf.includes('this', 4)); // Prints: false ``` -### buf.indexOf(value\[, byteOffset\]\[, encoding\]) +### `buf.indexOf(value[, byteOffset][, encoding])` <!-- YAML added: v1.5.0 changes: @@ -1425,7 +1425,7 @@ If `value` is an empty string or empty `Buffer` and `byteOffset` is less than `buf.length`, `byteOffset` will be returned. If `value` is empty and `byteOffset` is at least `buf.length`, `buf.length` will be returned. -### buf.keys() +### `buf.keys()` <!-- YAML added: v1.1.0 --> @@ -1449,7 +1449,7 @@ for (const key of buf.keys()) { // 5 ``` -### buf.lastIndexOf(value\[, byteOffset\]\[, encoding\]) +### `buf.lastIndexOf(value[, byteOffset][, encoding])` <!-- YAML added: v6.0.0 changes: @@ -1526,7 +1526,7 @@ console.log(b.lastIndexOf('b', [])); If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned. -### buf.length +### `buf.length` <!-- YAML added: v0.1.90 --> @@ -1569,7 +1569,7 @@ console.log(buf.length); // Prints: 5 ``` -### buf.parent +### `buf.parent` <!-- YAML deprecated: v8.0.0 --> @@ -1578,8 +1578,8 @@ deprecated: v8.0.0 The `buf.parent` property is a deprecated alias for `buf.buffer`. -### buf.readBigInt64BE(\[offset\]) -### buf.readBigInt64LE(\[offset\]) +### `buf.readBigInt64BE([offset])` +### `buf.readBigInt64LE([offset])` <!-- YAML added: v12.0.0 --> @@ -1594,8 +1594,8 @@ the specified endian format (`readBigInt64BE()` returns big endian, Integers read from a `Buffer` are interpreted as two's complement signed values. -### buf.readBigUInt64BE(\[offset\]) -### buf.readBigUInt64LE(\[offset\]) +### `buf.readBigUInt64BE([offset])` +### `buf.readBigUInt64LE([offset])` <!-- YAML added: v12.0.0 --> @@ -1618,8 +1618,8 @@ console.log(buf.readBigUInt64LE(0)); // Prints: 18446744069414584320n ``` -### buf.readDoubleBE(\[offset\]) -### buf.readDoubleLE(\[offset\]) +### `buf.readDoubleBE([offset])` +### `buf.readDoubleLE([offset])` <!-- YAML added: v0.11.15 changes: @@ -1648,8 +1648,8 @@ console.log(buf.readDoubleLE(1)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readFloatBE(\[offset\]) -### buf.readFloatLE(\[offset\]) +### `buf.readFloatBE([offset])` +### `buf.readFloatLE([offset])` <!-- YAML added: v0.11.15 changes: @@ -1678,7 +1678,7 @@ console.log(buf.readFloatLE(1)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readInt8(\[offset\]) +### `buf.readInt8([offset])` <!-- YAML added: v0.5.0 changes: @@ -1707,8 +1707,8 @@ console.log(buf.readInt8(2)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readInt16BE(\[offset\]) -### buf.readInt16LE(\[offset\]) +### `buf.readInt16BE([offset])` +### `buf.readInt16LE([offset])` <!-- YAML added: v0.5.5 changes: @@ -1739,8 +1739,8 @@ console.log(buf.readInt16LE(1)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readInt32BE(\[offset\]) -### buf.readInt32LE(\[offset\]) +### `buf.readInt32BE([offset])` +### `buf.readInt32LE([offset])` <!-- YAML added: v0.5.5 changes: @@ -1771,8 +1771,8 @@ console.log(buf.readInt32LE(1)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readIntBE(offset, byteLength) -### buf.readIntLE(offset, byteLength) +### `buf.readIntBE(offset, byteLength)` +### `buf.readIntLE(offset, byteLength)` <!-- YAML added: v0.11.15 changes: @@ -1805,7 +1805,7 @@ console.log(buf.readIntBE(1, 0).toString(16)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readUInt8(\[offset\]) +### `buf.readUInt8([offset])` <!-- YAML added: v0.5.0 changes: @@ -1832,8 +1832,8 @@ console.log(buf.readUInt8(2)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readUInt16BE(\[offset\]) -### buf.readUInt16LE(\[offset\]) +### `buf.readUInt16BE([offset])` +### `buf.readUInt16LE([offset])` <!-- YAML added: v0.5.5 changes: @@ -1866,8 +1866,8 @@ console.log(buf.readUInt16LE(2).toString(16)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readUInt32BE(\[offset\]) -### buf.readUInt32LE(\[offset\]) +### `buf.readUInt32BE([offset])` +### `buf.readUInt32LE([offset])` <!-- YAML added: v0.5.5 changes: @@ -1896,8 +1896,8 @@ console.log(buf.readUInt32LE(1).toString(16)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.readUIntBE(offset, byteLength) -### buf.readUIntLE(offset, byteLength) +### `buf.readUIntBE(offset, byteLength)` +### `buf.readUIntLE(offset, byteLength)` <!-- YAML added: v0.11.15 changes: @@ -1928,7 +1928,7 @@ console.log(buf.readUIntBE(1, 6).toString(16)); // Throws ERR_OUT_OF_RANGE. ``` -### buf.subarray(\[start\[, end\]\]) +### `buf.subarray([start[, end]])` <!-- YAML added: v3.0.0 --> @@ -1988,7 +1988,7 @@ console.log(buf.subarray(-5, -2).toString()); // (Equivalent to buf.subarray(1, 4).) ``` -### buf.slice(\[start\[, end\]\]) +### `buf.slice([start[, end]])` <!-- YAML added: v0.3.0 changes: @@ -2028,7 +2028,7 @@ console.log(buf.toString()); // Prints: buffer ``` -### buf.swap16() +### `buf.swap16()` <!-- YAML added: v5.10.0 --> @@ -2064,7 +2064,7 @@ const buf = Buffer.from('This is little-endian UTF-16', 'utf16le'); buf.swap16(); // Convert to big-endian UTF-16 text. ``` -### buf.swap32() +### `buf.swap32()` <!-- YAML added: v5.10.0 --> @@ -2092,7 +2092,7 @@ buf2.swap32(); // Throws ERR_INVALID_BUFFER_SIZE. ``` -### buf.swap64() +### `buf.swap64()` <!-- YAML added: v6.3.0 --> @@ -2122,7 +2122,7 @@ buf2.swap64(); JavaScript cannot encode 64-bit integers. This method is intended for working with 64-bit floats. -### buf.toJSON() +### `buf.toJSON()` <!-- YAML added: v0.9.2 --> @@ -2149,7 +2149,7 @@ console.log(copy); // Prints: <Buffer 01 02 03 04 05> ``` -### buf.toString(\[encoding\[, start\[, end\]\]\]) +### `buf.toString([encoding[, start[, end]]])` <!-- YAML added: v0.1.90 --> @@ -2191,7 +2191,7 @@ console.log(buf2.toString(undefined, 0, 3)); // Prints: té ``` -### buf.values() +### `buf.values()` <!-- YAML added: v1.1.0 --> @@ -2227,7 +2227,7 @@ for (const value of buf) { // 114 ``` -### buf.write(string\[, offset\[, length\]\]\[, encoding\]) +### `buf.write(string[, offset[, length]][, encoding])` <!-- YAML added: v0.1.90 --> @@ -2254,8 +2254,8 @@ console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); // Prints: 12 bytes: ½ + ¼ = ¾ ``` -### buf.writeBigInt64BE(value\[, offset\]) -### buf.writeBigInt64LE(value\[, offset\]) +### `buf.writeBigInt64BE(value[, offset])` +### `buf.writeBigInt64LE(value[, offset])` <!-- YAML added: v12.0.0 --> @@ -2280,8 +2280,8 @@ console.log(buf); // Prints: <Buffer 01 02 03 04 05 06 07 08> ``` -### buf.writeBigUInt64BE(value\[, offset\]) -### buf.writeBigUInt64LE(value\[, offset\]) +### `buf.writeBigUInt64BE(value[, offset])` +### `buf.writeBigUInt64LE(value[, offset])` <!-- YAML added: v12.0.0 --> @@ -2304,8 +2304,8 @@ console.log(buf); // Prints: <Buffer de fa ce ca fe fa ca de> ``` -### buf.writeDoubleBE(value\[, offset\]) -### buf.writeDoubleLE(value\[, offset\]) +### `buf.writeDoubleBE(value[, offset])` +### `buf.writeDoubleLE(value[, offset])` <!-- YAML added: v0.11.15 changes: @@ -2339,8 +2339,8 @@ console.log(buf); // Prints: <Buffer 77 be 9f 1a 2f dd 5e 40> ``` -### buf.writeFloatBE(value\[, offset\]) -### buf.writeFloatLE(value\[, offset\]) +### `buf.writeFloatBE(value[, offset])` +### `buf.writeFloatLE(value[, offset])` <!-- YAML added: v0.11.15 changes: @@ -2374,7 +2374,7 @@ console.log(buf); // Prints: <Buffer bb fe 4a 4f> ``` -### buf.writeInt8(value\[, offset\]) +### `buf.writeInt8(value[, offset])` <!-- YAML added: v0.5.0 changes: @@ -2405,8 +2405,8 @@ console.log(buf); // Prints: <Buffer 02 fe> ``` -### buf.writeInt16BE(value\[, offset\]) -### buf.writeInt16LE(value\[, offset\]) +### `buf.writeInt16BE(value[, offset])` +### `buf.writeInt16LE(value[, offset])` <!-- YAML added: v0.5.5 changes: @@ -2438,8 +2438,8 @@ console.log(buf); // Prints: <Buffer 01 02 04 03> ``` -### buf.writeInt32BE(value\[, offset\]) -### buf.writeInt32LE(value\[, offset\]) +### `buf.writeInt32BE(value[, offset])` +### `buf.writeInt32LE(value[, offset])` <!-- YAML added: v0.5.5 changes: @@ -2471,8 +2471,8 @@ console.log(buf); // Prints: <Buffer 01 02 03 04 08 07 06 05> ``` -### buf.writeIntBE(value, offset, byteLength) -### buf.writeIntLE(value, offset, byteLength) +### `buf.writeIntBE(value, offset, byteLength)` +### `buf.writeIntLE(value, offset, byteLength)` <!-- YAML added: v0.11.15 changes: @@ -2507,7 +2507,7 @@ console.log(buf); // Prints: <Buffer ab 90 78 56 34 12> ``` -### buf.writeUInt8(value\[, offset\]) +### `buf.writeUInt8(value[, offset])` <!-- YAML added: v0.5.0 changes: @@ -2538,8 +2538,8 @@ console.log(buf); // Prints: <Buffer 03 04 23 42> ``` -### buf.writeUInt16BE(value\[, offset\]) -### buf.writeUInt16LE(value\[, offset\]) +### `buf.writeUInt16BE(value[, offset])` +### `buf.writeUInt16LE(value[, offset])` <!-- YAML added: v0.5.5 changes: @@ -2575,8 +2575,8 @@ console.log(buf); // Prints: <Buffer ad de ef be> ``` -### buf.writeUInt32BE(value\[, offset\]) -### buf.writeUInt32LE(value\[, offset\]) +### `buf.writeUInt32BE(value[, offset])` +### `buf.writeUInt32LE(value[, offset])` <!-- YAML added: v0.5.5 changes: @@ -2610,8 +2610,8 @@ console.log(buf); // Prints: <Buffer ce fa ed fe> ``` -### buf.writeUIntBE(value, offset, byteLength) -### buf.writeUIntLE(value, offset, byteLength) +### `buf.writeUIntBE(value, offset, byteLength)` +### `buf.writeUIntLE(value, offset, byteLength)` <!-- YAML added: v0.5.5 changes: @@ -2646,7 +2646,7 @@ console.log(buf); // Prints: <Buffer ab 90 78 56 34 12> ``` -## buffer.INSPECT_MAX_BYTES +## `buffer.INSPECT_MAX_BYTES` <!-- YAML added: v0.5.4 --> @@ -2660,7 +2660,7 @@ Returns the maximum number of bytes that will be returned when This is a property on the `buffer` module returned by `require('buffer')`, not on the `Buffer` global or a `Buffer` instance. -## buffer.kMaxLength +## `buffer.kMaxLength` <!-- YAML added: v3.0.0 --> @@ -2672,7 +2672,7 @@ An alias for [`buffer.constants.MAX_LENGTH`][]. This is a property on the `buffer` module returned by `require('buffer')`, not on the `Buffer` global or a `Buffer` instance. -## buffer.transcode(source, fromEnc, toEnc) +## `buffer.transcode(source, fromEnc, toEnc)` <!-- YAML added: v7.1.0 changes: @@ -2712,7 +2712,7 @@ with `?` in the transcoded `Buffer`. This is a property on the `buffer` module returned by `require('buffer')`, not on the `Buffer` global or a `Buffer` instance. -## Class: SlowBuffer +## Class: `SlowBuffer` <!-- YAML deprecated: v6.0.0 --> @@ -2750,7 +2750,7 @@ socket.on('readable', () => { Use of `SlowBuffer` should be used only as a last resort *after* a developer has observed undue memory retention in their applications. -### new SlowBuffer(size) +### `new SlowBuffer(size)` <!-- YAML deprecated: v6.0.0 --> @@ -2790,7 +2790,7 @@ added: v8.2.0 `buffer.constants` is a property on the `buffer` module returned by `require('buffer')`, not on the `Buffer` global or a `Buffer` instance. -### buffer.constants.MAX_LENGTH +### `buffer.constants.MAX_LENGTH` <!-- YAML added: v8.2.0 --> @@ -2802,7 +2802,7 @@ On 64-bit architectures, this value is `(2^31)-1` (~2GB). This value is also available as [`buffer.kMaxLength`][]. -### buffer.constants.MAX_STRING_LENGTH +### `buffer.constants.MAX_STRING_LENGTH` <!-- YAML added: v8.2.0 --> |