@@ -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
@@ -2054,7 +2054,7 @@ If `value` is:
2054
2054
* a string, ` value ` is interpreted according to the character encoding in
2055
2055
` encoding ` .
2056
2056
* a ` Buffer ` or [ ` Uint8Array ` ] [ ] , ` value ` will be used in its entirety.
2057
- To compare a partial ` Buffer ` , use [ ` buf.slice() ` ] [ ] .
2057
+ To compare a partial ` Buffer ` , use [ ` buf.subarray ` ] [ ] .
2058
2058
* a number, ` value ` will be interpreted as an unsigned 8-bit integer
2059
2059
value between ` 0 ` and ` 255 ` .
2060
2060
@@ -3387,6 +3387,9 @@ console.log(buf.subarray(-5, -2).toString());
3387
3387
<!-- YAML
3388
3388
added: v0.3.0
3389
3389
changes:
3390
+ - version: REPLACEME
3391
+ pr-url: https://github.com/nodejs/node/pull/41596
3392
+ description: The buf.slice() method has been deprecated.
3390
3393
- version:
3391
3394
- v7.1.0
3392
3395
- v6.9.2
@@ -3404,11 +3407,11 @@ changes:
3404
3407
** Default:** [ ` buf.length ` ] [ ] .
3405
3408
* Returns: {Buffer}
3406
3409
3410
+ > Stability: 0 - Deprecated: Use [ ` buf.subarray ` ] [ ] instead.
3411
+
3407
3412
Returns a new ` Buffer ` that references the same memory as the original, but
3408
3413
offset and cropped by the ` start ` and ` end ` indices.
3409
3414
3410
- This is the same behavior as ` buf.subarray() ` .
3411
-
3412
3415
This method is not compatible with the ` Uint8Array.prototype.slice() ` ,
3413
3416
which is a superclass of ` Buffer ` . To copy the slice, use
3414
3417
` Uint8Array.prototype.slice() ` .
@@ -5369,6 +5372,7 @@ introducing security vulnerabilities into an application.
5369
5372
[ `buf.keys()` ] : #bufkeys
5370
5373
[ `buf.length` ] : #buflength
5371
5374
[ `buf.slice()` ] : #bufslicestart-end
5375
+ [ `buf.subarray` ] : #bufsubarraystart-end
5372
5376
[ `buf.toString()` ] : #buftostringencoding-start-end
5373
5377
[ `buf.values()` ] : #bufvalues
5374
5378
[ `buffer.constants.MAX_LENGTH` ] : #bufferconstantsmax_length
0 commit comments