Skip to content

Commit 6e2bfbe

Browse files
ghaiklorMyles Borins
authored andcommitted
doc: fix doc for Buffer.readInt32LE()
Update example of readInt32LE method. buf.readInt32LE(1) is supposed to throw an error as it has only four elements and it tries to read 32 bits from three bytes. Fixes: #5889 PR-URL: #5890 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent d275cdf commit 6e2bfbe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/api/buffer.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,10 @@ const buf = new Buffer([1,-2,3,4]);
739739

740740
buf.readInt32BE();
741741
// returns 33424132
742-
buf.readInt32LE(1);
742+
buf.readInt32LE();
743743
// returns 67370497
744+
buf.readInt32LE(1);
745+
// throws RangeError: Index out of range
744746
```
745747

746748
### buf.readIntBE(offset, byteLength[, noAssert])

0 commit comments

Comments
 (0)