diff options
-rw-r--r-- | doc/api/buffer.md | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 10ad944b371..e0f2e812f32 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1525,10 +1525,7 @@ console.log(buf.readDoubleBE(0)); console.log(buf.readDoubleLE(0)); // Prints: 5.447603722011605e-270 console.log(buf.readDoubleLE(1)); -// Throws an exception: RangeError: Index out of range -console.log(buf.readDoubleLE(1, true)); -// Warning: reads passed end of buffer! -// This will result in a segmentation fault! Don't do this! +// Throws ERR_OUT_OF_RANGE ``` ### buf.readFloatBE(offset) @@ -1558,10 +1555,7 @@ console.log(buf.readFloatBE(0)); console.log(buf.readFloatLE(0)); // Prints: 1.539989614439558e-36 console.log(buf.readFloatLE(1)); -// Throws an exception: RangeError: Index out of range -console.log(buf.readFloatLE(1, true)); -// Warning: reads passed end of buffer! -// This will result in a segmentation fault! Don't do this! +// Throws ERR_OUT_OF_RANGE ``` ### buf.readInt8(offset) @@ -1590,7 +1584,7 @@ console.log(buf.readInt8(0)); console.log(buf.readInt8(1)); // Prints: 5 console.log(buf.readInt8(2)); -// Throws an exception: RangeError: Index out of range +// Throws ERR_OUT_OF_RANGE ``` ### buf.readInt16BE(offset) @@ -1622,7 +1616,7 @@ console.log(buf.readInt16BE(0)); console.log(buf.readInt16LE(0)); // Prints: 1280 console.log(buf.readInt16LE(1)); -// Throws an exception: RangeError: Index out of range +// Throws ERR_OUT_OF_RANGE ``` ### buf.readInt32BE(offset) @@ -1654,7 +1648,7 @@ console.log(buf.readInt32BE(0)); console.log(buf.readInt32LE(0)); // Prints: 83886080 console.log(buf.readInt32LE(1)); -// Throws an exception: RangeError: Index out of range +// Throws ERR_OUT_OF_RANGE ``` ### buf.readIntBE(offset, byteLength) @@ -1686,9 +1680,9 @@ console.log(buf.readIntLE(0, 6).toString(16)); console.log(buf.readIntBE(0, 6).toString(16)); // Prints: 1234567890ab console.log(buf.readIntBE(1, 6).toString(16)); -// Throws ERR_INDEX_OUT_OF_RANGE: +// Throws ERR_INDEX_OUT_OF_RANGE console.log(buf.readIntBE(1, 0).toString(16)); -// Throws ERR_OUT_OF_RANGE: +// Throws ERR_OUT_OF_RANGE ``` ### buf.readUInt8(offset) @@ -1715,7 +1709,7 @@ console.log(buf.readUInt8(0)); console.log(buf.readUInt8(1)); // Prints: 254 console.log(buf.readUInt8(2)); -// Throws an exception: RangeError: Index out of range +// Throws ERR_OUT_OF_RANGE ``` ### buf.readUInt16BE(offset) @@ -1749,7 +1743,7 @@ console.log(buf.readUInt16BE(1).toString(16)); console.log(buf.readUInt16LE(1).toString(16)); // Prints: 5634 console.log(buf.readUInt16LE(2).toString(16)); -// Throws an exception: RangeError: Index out of range +// Throws ERR_OUT_OF_RANGE ``` ### buf.readUInt32BE(offset) @@ -1779,7 +1773,7 @@ console.log(buf.readUInt32BE(0).toString(16)); console.log(buf.readUInt32LE(0).toString(16)); // Prints: 78563412 console.log(buf.readUInt32LE(1).toString(16)); -// Throws an exception: RangeError: Index out of range +// Throws ERR_OUT_OF_RANGE ``` ### buf.readUIntBE(offset, byteLength) @@ -1811,7 +1805,7 @@ console.log(buf.readUIntBE(0, 6).toString(16)); console.log(buf.readUIntLE(0, 6).toString(16)); // Prints: ab9078563412 console.log(buf.readUIntBE(1, 6).toString(16)); -// Throws an exception: RangeError: Index out of range +// Throws ERR_OUT_OF_RANGE ``` ### buf.slice([start[, end]]) @@ -1907,7 +1901,7 @@ console.log(buf1); const buf2 = Buffer.from([0x1, 0x2, 0x3]); buf2.swap16(); -// Throws an exception: RangeError: Buffer size must be a multiple of 16-bits +// Throws ERR_INVALID_BUFFER_SIZE ``` ### buf.swap32() @@ -1934,7 +1928,7 @@ console.log(buf1); const buf2 = Buffer.from([0x1, 0x2, 0x3]); buf2.swap32(); -// Throws an exception: RangeError: Buffer size must be a multiple of 32-bits +// Throws ERR_INVALID_BUFFER_SIZE ``` ### buf.swap64() @@ -1961,7 +1955,7 @@ console.log(buf1); const buf2 = Buffer.from([0x1, 0x2, 0x3]); buf2.swap64(); -// Throws an exception: RangeError: Buffer size must be a multiple of 64-bits +// Throws ERR_INVALID_BUFFER_SIZE ``` Note that JavaScript cannot encode 64-bit integers. This method is intended |