@@ -442,9 +442,9 @@ changes:
442
442
443
443
* ` size ` {integer} The desired length of the new ` Buffer ` .
444
444
445
- Allocates a new ` Buffer ` of ` size ` bytes. If the ` size ` is larger than
446
- [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, a [ ` RangeError ` ] will be
447
- thrown. A zero-length ` Buffer ` will be created if ` size ` is 0.
445
+ Allocates a new ` Buffer ` of ` size ` bytes. If ` size ` is larger than
446
+ [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, [ ` ERR_INVALID_OPT_VALUE ` ] is
447
+ thrown. A zero-length ` Buffer ` is created if ` size ` is 0.
448
448
449
449
Prior to Node.js 8.0.0, the underlying memory for ` Buffer ` instances
450
450
created in this way is * not initialized* . The contents of a newly created
@@ -530,9 +530,9 @@ console.log(buf);
530
530
// Prints: <Buffer 00 00 00 00 00>
531
531
```
532
532
533
- Allocates a new ` Buffer ` of ` size ` bytes. If the ` size ` is larger than
534
- [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, a [ ` RangeError ` ] will be
535
- thrown. A zero-length ` Buffer ` will be created if ` size ` is 0.
533
+ Allocates a new ` Buffer ` of ` size ` bytes. If ` size ` is larger than
534
+ [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, [ ` ERR_INVALID_OPT_VALUE ` ] is
535
+ thrown. A zero-length ` Buffer ` is created if ` size ` is 0.
536
536
537
537
If ` fill ` is specified, the allocated ` Buffer ` will be initialized by calling
538
538
[ ` buf.fill(fill) ` ] [ `buf.fill()` ] .
@@ -571,9 +571,9 @@ changes:
571
571
572
572
* ` size ` {integer} The desired length of the new ` Buffer ` .
573
573
574
- Allocates a new ` Buffer ` of ` size ` bytes. If the ` size ` is larger than
575
- [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, a [ ` RangeError ` ] will be
576
- thrown. A zero-length ` Buffer ` will be created if ` size ` is 0.
574
+ Allocates a new ` Buffer ` of ` size ` bytes. If ` size ` is larger than
575
+ [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, [ ` ERR_INVALID_OPT_VALUE ` ] is
576
+ thrown. A zero-length ` Buffer ` is created if ` size ` is 0.
577
577
578
578
The underlying memory for ` Buffer ` instances created in this way is * not
579
579
initialized* . The contents of the newly created ` Buffer ` are unknown and
@@ -615,9 +615,9 @@ added: v5.12.0
615
615
616
616
* ` size ` {integer} The desired length of the new ` Buffer ` .
617
617
618
- Allocates a new ` Buffer ` of ` size ` bytes. If the ` size ` is larger than
619
- [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, a [ ` RangeError ` ] will be
620
- thrown. A zero-length ` Buffer ` will be created if ` size ` is 0.
618
+ Allocates a new ` Buffer ` of ` size ` bytes. If ` size ` is larger than
619
+ [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, [ ` ERR_INVALID_OPT_VALUE ` ] is
620
+ thrown. A zero-length ` Buffer ` is created if ` size ` is 0.
621
621
622
622
The underlying memory for ` Buffer ` instances created in this way is * not
623
623
initialized* . The contents of the newly created ` Buffer ` are unknown and
@@ -1058,8 +1058,8 @@ console.log(buf1.compare(buf2, 5, 6, 5));
1058
1058
// Prints: 1
1059
1059
```
1060
1060
1061
- A ` RangeError ` will be thrown if: ` targetStart < 0 ` , ` sourceStart < 0 ` ,
1062
- ` targetEnd > target.byteLength ` or ` sourceEnd > source.byteLength ` .
1061
+ [ ` ERR_INDEX_OUT_OF_RANGE ` ] is thrown if ` targetStart < 0 ` , ` sourceStart < 0 ` ,
1062
+ ` targetEnd > target.byteLength ` , or ` sourceEnd > source.byteLength ` .
1063
1063
1064
1064
### buf.copy(target[ , targetStart[ , sourceStart[ , sourceEnd]]] )
1065
1065
<!-- YAML
@@ -1884,8 +1884,9 @@ added: v5.10.0
1884
1884
1885
1885
* Returns: {Buffer} A reference to ` buf ` .
1886
1886
1887
- Interprets ` buf ` as an array of unsigned 16-bit integers and swaps the byte-order
1888
- * in-place* . Throws a ` RangeError ` if [ ` buf.length ` ] is not a multiple of 2.
1887
+ Interprets ` buf ` as an array of unsigned 16-bit integers and swaps the
1888
+ byte-order * in-place* . Throws [ ` ERR_INVALID_BUFFER_SIZE ` ] if [ ` buf.length ` ] is
1889
+ not a multiple of 2.
1889
1890
1890
1891
``` js
1891
1892
const buf1 = Buffer .from ([0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 ]);
@@ -1911,8 +1912,9 @@ added: v5.10.0
1911
1912
1912
1913
* Returns: {Buffer} A reference to ` buf ` .
1913
1914
1914
- Interprets ` buf ` as an array of unsigned 32-bit integers and swaps the byte-order
1915
- * in-place* . Throws a ` RangeError ` if [ ` buf.length ` ] is not a multiple of 4.
1915
+ Interprets ` buf ` as an array of unsigned 32-bit integers and swaps the
1916
+ byte-order * in-place* . Throws [ ` ERR_INVALID_BUFFER_SIZE ` ] if [ ` buf.length ` ] is
1917
+ not a multiple of 4.
1916
1918
1917
1919
``` js
1918
1920
const buf1 = Buffer .from ([0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 ]);
@@ -1938,8 +1940,9 @@ added: v6.3.0
1938
1940
1939
1941
* Returns: {Buffer} A reference to ` buf ` .
1940
1942
1941
- Interprets ` buf ` as an array of 64-bit numbers and swaps the byte-order * in-place* .
1942
- Throws a ` RangeError ` if [ ` buf.length ` ] is not a multiple of 8.
1943
+ Interprets ` buf ` as an array of 64-bit numbers and swaps the byte-order
1944
+ * in-place* . Throws [ ` ERR_INVALID_BUFFER_SIZE ` ] if [ ` buf.length ` ] is not a
1945
+ multiple of 8.
1943
1946
1944
1947
``` js
1945
1948
const buf1 = Buffer .from ([0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 ]);
@@ -2539,9 +2542,9 @@ deprecated: v6.0.0
2539
2542
2540
2543
* ` size ` {integer} The desired length of the new ` SlowBuffer ` .
2541
2544
2542
- Allocates a new ` Buffer ` of ` size ` bytes. If the ` size ` is larger than
2543
- [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, a [ ` RangeError ` ] will be
2544
- thrown. A zero-length ` Buffer ` will be created if ` size ` is 0.
2545
+ Allocates a new ` Buffer ` of ` size ` bytes. If ` size ` is larger than
2546
+ [ ` buffer.constants.MAX_LENGTH ` ] or smaller than 0, [ ` ERR_INVALID_OPT_VALUE ` ] is
2547
+ thrown. A zero-length ` Buffer ` is created if ` size ` is 0.
2545
2548
2546
2549
The underlying memory for ` SlowBuffer ` instances is * not initialized* . The
2547
2550
contents of a newly created ` SlowBuffer ` are unknown and may contain sensitive
@@ -2605,8 +2608,10 @@ This value may depend on the JS engine that is being used.
2605
2608
[ `Buffer.from(string)` ] : #buffer_class_method_buffer_from_string_encoding
2606
2609
[ `Buffer.poolSize` ] : #buffer_class_property_buffer_poolsize
2607
2610
[ `DataView` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
2611
+ [ `ERR_INDEX_OUT_OF_RANGE` ] : errors.html#ERR_INDEX_OUT_OF_RANGE
2612
+ [ `ERR_INVALID_BUFFER_SIZE` ] : errors.html#ERR_INVALID_BUFFER_SIZE
2613
+ [ `ERR_INVALID_OPT_VALUE` ] : errors.html#ERR_INVALID_OPT_VALUE
2608
2614
[ `JSON.stringify()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
2609
- [ `RangeError` ] : errors.html#errors_class_rangeerror
2610
2615
[ `SharedArrayBuffer` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
2611
2616
[ `String#indexOf()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
2612
2617
[ `String#lastIndexOf()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf
0 commit comments