Skip to content

Commit f1f9aff

Browse files
ghaiklorevanlucas
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 2a5c6d7 commit f1f9aff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/api/buffer.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,10 @@ const buf = Buffer.from([1,-2,3,4]);
10541054

10551055
buf.readInt32BE();
10561056
// returns 33424132
1057-
buf.readInt32LE(1);
1057+
buf.readInt32LE();
10581058
// returns 67370497
1059+
buf.readInt32LE(1);
1060+
// throws RangeError: Index out of range
10591061
```
10601062

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

0 commit comments

Comments
 (0)