Skip to content

Commit 1213535

Browse files
ghaiklorthefourtheye
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 41feaa8 commit 1213535

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
@@ -1067,8 +1067,10 @@ const buf = Buffer.from([1,-2,3,4]);
10671067

10681068
buf.readInt32BE();
10691069
// returns 33424132
1070-
buf.readInt32LE(1);
1070+
buf.readInt32LE();
10711071
// returns 67370497
1072+
buf.readInt32LE(1);
1073+
// throws RangeError: Index out of range
10721074
```
10731075

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

0 commit comments

Comments
 (0)