@@ -254,7 +254,7 @@ In particular:
254
254
without copying. This behavior can be surprising, and only exists for legacy
255
255
compatibility. [ ` TypedArray.prototype.subarray() ` ] [ ] can be used to achieve
256
256
the behavior of [ ` Buffer.prototype.slice() ` ] [ `buf.slice()` ] on both ` Buffer ` s
257
- and other ` TypedArray ` s.
257
+ and other ` TypedArray ` s and should be preferred .
258
258
* [ ` buf.toString() ` ] [ ] is incompatible with its ` TypedArray ` equivalent.
259
259
* A number of methods, e.g. [ ` buf.indexOf() ` ] [ ] , support additional arguments.
260
260
@@ -2056,7 +2056,7 @@ If `value` is:
2056
2056
* a string, ` value ` is interpreted according to the character encoding in
2057
2057
` encoding ` .
2058
2058
* a ` Buffer ` or [ ` Uint8Array ` ] [ ] , ` value ` will be used in its entirety.
2059
- To compare a partial ` Buffer ` , use [ ` buf.slice() ` ] [ ] .
2059
+ To compare a partial ` Buffer ` , use [ ` buf.subarray ` ] [ ] .
2060
2060
* a number, ` value ` will be interpreted as an unsigned 8-bit integer
2061
2061
value between ` 0 ` and ` 255 ` .
2062
2062
@@ -3389,6 +3389,9 @@ console.log(buf.subarray(-5, -2).toString());
3389
3389
<!-- YAML
3390
3390
added: v0.3.0
3391
3391
changes:
3392
+ - version: REPLACEME
3393
+ pr-url: https://github.com/nodejs/node/pull/41596
3394
+ description: The buf.slice() method has been deprecated.
3392
3395
- version:
3393
3396
- v7.1.0
3394
3397
- v6.9.2
@@ -3406,11 +3409,11 @@ changes:
3406
3409
** Default:** [ ` buf.length ` ] [ ] .
3407
3410
* Returns: {Buffer}
3408
3411
3412
+ > Stability: 0 - Deprecated: Use [ ` buf.subarray ` ] [ ] instead.
3413
+
3409
3414
Returns a new ` Buffer ` that references the same memory as the original, but
3410
3415
offset and cropped by the ` start ` and ` end ` indices.
3411
3416
3412
- This is the same behavior as ` buf.subarray() ` .
3413
-
3414
3417
This method is not compatible with the ` Uint8Array.prototype.slice() ` ,
3415
3418
which is a superclass of ` Buffer ` . To copy the slice, use
3416
3419
` Uint8Array.prototype.slice() ` .
@@ -5371,6 +5374,7 @@ introducing security vulnerabilities into an application.
5371
5374
[ `buf.keys()` ] : #bufkeys
5372
5375
[ `buf.length` ] : #buflength
5373
5376
[ `buf.slice()` ] : #bufslicestart-end
5377
+ [ `buf.subarray` ] : #bufsubarraystart-end
5374
5378
[ `buf.toString()` ] : #buftostringencoding-start-end
5375
5379
[ `buf.values()` ] : #bufvalues
5376
5380
[ `buffer.constants.MAX_LENGTH` ] : #bufferconstantsmax_length
0 commit comments