@@ -1525,10 +1525,7 @@ console.log(buf.readDoubleBE(0));
1525
1525
console .log (buf .readDoubleLE (0 ));
1526
1526
// Prints: 5.447603722011605e-270
1527
1527
console .log (buf .readDoubleLE (1 ));
1528
- // Throws an exception: RangeError: Index out of range
1529
- console .log (buf .readDoubleLE (1 , true ));
1530
- // Warning: reads passed end of buffer!
1531
- // This will result in a segmentation fault! Don't do this!
1528
+ // Throws ERR_OUT_OF_RANGE
1532
1529
```
1533
1530
1534
1531
### buf.readFloatBE(offset)
@@ -1558,10 +1555,7 @@ console.log(buf.readFloatBE(0));
1558
1555
console .log (buf .readFloatLE (0 ));
1559
1556
// Prints: 1.539989614439558e-36
1560
1557
console .log (buf .readFloatLE (1 ));
1561
- // Throws an exception: RangeError: Index out of range
1562
- console .log (buf .readFloatLE (1 , true ));
1563
- // Warning: reads passed end of buffer!
1564
- // This will result in a segmentation fault! Don't do this!
1558
+ // Throws ERR_OUT_OF_RANGE
1565
1559
```
1566
1560
1567
1561
### buf.readInt8(offset)
@@ -1590,7 +1584,7 @@ console.log(buf.readInt8(0));
1590
1584
console .log (buf .readInt8 (1 ));
1591
1585
// Prints: 5
1592
1586
console .log (buf .readInt8 (2 ));
1593
- // Throws an exception: RangeError: Index out of range
1587
+ // Throws ERR_OUT_OF_RANGE
1594
1588
```
1595
1589
1596
1590
### buf.readInt16BE(offset)
@@ -1622,7 +1616,7 @@ console.log(buf.readInt16BE(0));
1622
1616
console .log (buf .readInt16LE (0 ));
1623
1617
// Prints: 1280
1624
1618
console .log (buf .readInt16LE (1 ));
1625
- // Throws an exception: RangeError: Index out of range
1619
+ // Throws ERR_OUT_OF_RANGE
1626
1620
```
1627
1621
1628
1622
### buf.readInt32BE(offset)
@@ -1654,7 +1648,7 @@ console.log(buf.readInt32BE(0));
1654
1648
console .log (buf .readInt32LE (0 ));
1655
1649
// Prints: 83886080
1656
1650
console .log (buf .readInt32LE (1 ));
1657
- // Throws an exception: RangeError: Index out of range
1651
+ // Throws ERR_OUT_OF_RANGE
1658
1652
```
1659
1653
1660
1654
### buf.readIntBE(offset, byteLength)
@@ -1686,9 +1680,9 @@ console.log(buf.readIntLE(0, 6).toString(16));
1686
1680
console .log (buf .readIntBE (0 , 6 ).toString (16 ));
1687
1681
// Prints: 1234567890ab
1688
1682
console .log (buf .readIntBE (1 , 6 ).toString (16 ));
1689
- // Throws ERR_INDEX_OUT_OF_RANGE:
1683
+ // Throws ERR_INDEX_OUT_OF_RANGE
1690
1684
console .log (buf .readIntBE (1 , 0 ).toString (16 ));
1691
- // Throws ERR_OUT_OF_RANGE:
1685
+ // Throws ERR_OUT_OF_RANGE
1692
1686
```
1693
1687
1694
1688
### buf.readUInt8(offset)
@@ -1715,7 +1709,7 @@ console.log(buf.readUInt8(0));
1715
1709
console .log (buf .readUInt8 (1 ));
1716
1710
// Prints: 254
1717
1711
console .log (buf .readUInt8 (2 ));
1718
- // Throws an exception: RangeError: Index out of range
1712
+ // Throws ERR_OUT_OF_RANGE
1719
1713
```
1720
1714
1721
1715
### buf.readUInt16BE(offset)
@@ -1749,7 +1743,7 @@ console.log(buf.readUInt16BE(1).toString(16));
1749
1743
console .log (buf .readUInt16LE (1 ).toString (16 ));
1750
1744
// Prints: 5634
1751
1745
console .log (buf .readUInt16LE (2 ).toString (16 ));
1752
- // Throws an exception: RangeError: Index out of range
1746
+ // Throws ERR_OUT_OF_RANGE
1753
1747
```
1754
1748
1755
1749
### buf.readUInt32BE(offset)
@@ -1779,7 +1773,7 @@ console.log(buf.readUInt32BE(0).toString(16));
1779
1773
console .log (buf .readUInt32LE (0 ).toString (16 ));
1780
1774
// Prints: 78563412
1781
1775
console .log (buf .readUInt32LE (1 ).toString (16 ));
1782
- // Throws an exception: RangeError: Index out of range
1776
+ // Throws ERR_OUT_OF_RANGE
1783
1777
```
1784
1778
1785
1779
### buf.readUIntBE(offset, byteLength)
@@ -1811,7 +1805,7 @@ console.log(buf.readUIntBE(0, 6).toString(16));
1811
1805
console .log (buf .readUIntLE (0 , 6 ).toString (16 ));
1812
1806
// Prints: ab9078563412
1813
1807
console .log (buf .readUIntBE (1 , 6 ).toString (16 ));
1814
- // Throws an exception: RangeError: Index out of range
1808
+ // Throws ERR_OUT_OF_RANGE
1815
1809
```
1816
1810
1817
1811
### buf.slice([ start[ , end]] )
@@ -1907,7 +1901,7 @@ console.log(buf1);
1907
1901
const buf2 = Buffer .from ([0x1 , 0x2 , 0x3 ]);
1908
1902
1909
1903
buf2 .swap16 ();
1910
- // Throws an exception: RangeError: Buffer size must be a multiple of 16-bits
1904
+ // Throws ERR_INVALID_BUFFER_SIZE
1911
1905
```
1912
1906
1913
1907
### buf.swap32()
@@ -1934,7 +1928,7 @@ console.log(buf1);
1934
1928
const buf2 = Buffer .from ([0x1 , 0x2 , 0x3 ]);
1935
1929
1936
1930
buf2 .swap32 ();
1937
- // Throws an exception: RangeError: Buffer size must be a multiple of 32-bits
1931
+ // Throws ERR_INVALID_BUFFER_SIZE
1938
1932
```
1939
1933
1940
1934
### buf.swap64()
@@ -1961,7 +1955,7 @@ console.log(buf1);
1961
1955
const buf2 = Buffer .from ([0x1 , 0x2 , 0x3 ]);
1962
1956
1963
1957
buf2 .swap64 ();
1964
- // Throws an exception: RangeError: Buffer size must be a multiple of 64-bits
1958
+ // Throws ERR_INVALID_BUFFER_SIZE
1965
1959
```
1966
1960
1967
1961
Note that JavaScript cannot encode 64-bit integers. This method is intended
0 commit comments