@@ -252,7 +252,7 @@ In particular:
252
252
without copying. This behavior can be surprising, and only exists for legacy
253
253
compatibility. [ ` TypedArray.prototype.subarray() ` ] [ ] can be used to achieve
254
254
the behavior of [ ` Buffer.prototype.slice() ` ] [ `buf.slice()` ] on both ` Buffer ` s
255
- and other ` TypedArray ` s.
255
+ and other ` TypedArray ` s and should be preferred .
256
256
* [ ` buf.toString() ` ] [ ] is incompatible with its ` TypedArray ` equivalent.
257
257
* A number of methods, e.g. [ ` buf.indexOf() ` ] [ ] , support additional arguments.
258
258
@@ -2038,7 +2038,7 @@ If `value` is:
2038
2038
* a string, ` value ` is interpreted according to the character encoding in
2039
2039
` encoding ` .
2040
2040
* a ` Buffer ` or [ ` Uint8Array ` ] [ ] , ` value ` will be used in its entirety.
2041
- To compare a partial ` Buffer ` , use [ ` buf.slice() ` ] [ ] .
2041
+ To compare a partial ` Buffer ` , use [ ` buf.subarray ` ] [ ] .
2042
2042
* a number, ` value ` will be interpreted as an unsigned 8-bit integer
2043
2043
value between ` 0 ` and ` 255 ` .
2044
2044
@@ -3371,6 +3371,9 @@ console.log(buf.subarray(-5, -2).toString());
3371
3371
<!-- YAML
3372
3372
added: v0.3.0
3373
3373
changes:
3374
+ - version: REPLACEME
3375
+ pr-url: https://github.com/nodejs/node/pull/41596
3376
+ description: The buf.slice() method has been deprecated.
3374
3377
- version:
3375
3378
- v7.1.0
3376
3379
- v6.9.2
@@ -3388,11 +3391,11 @@ changes:
3388
3391
** Default:** [ ` buf.length ` ] [ ] .
3389
3392
* Returns: {Buffer}
3390
3393
3394
+ > Stability: 0 - Deprecated: Use [ ` buf.subarray ` ] [ ] instead.
3395
+
3391
3396
Returns a new ` Buffer ` that references the same memory as the original, but
3392
3397
offset and cropped by the ` start ` and ` end ` indices.
3393
3398
3394
- This is the same behavior as ` buf.subarray() ` .
3395
-
3396
3399
This method is not compatible with the ` Uint8Array.prototype.slice() ` ,
3397
3400
which is a superclass of ` Buffer ` . To copy the slice, use
3398
3401
` Uint8Array.prototype.slice() ` .
@@ -5349,6 +5352,7 @@ introducing security vulnerabilities into an application.
5349
5352
[ `buf.keys()` ] : #bufkeys
5350
5353
[ `buf.length` ] : #buflength
5351
5354
[ `buf.slice()` ] : #bufslicestart-end
5355
+ [ `buf.subarray` ] : #bufsubarraystart-end
5352
5356
[ `buf.toString()` ] : #buftostringencoding-start-end
5353
5357
[ `buf.values()` ] : #bufvalues
5354
5358
[ `buffer.constants.MAX_LENGTH` ] : #bufferconstantsmax_length
0 commit comments