@@ -254,7 +254,7 @@ In particular:
254254 without copying. This behavior can be surprising, and only exists for legacy
255255 compatibility. [ ` TypedArray.prototype.subarray() ` ] [ ] can be used to achieve
256256 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 .
258258* [ ` buf.toString() ` ] [ ] is incompatible with its ` TypedArray ` equivalent.
259259* A number of methods, e.g. [ ` buf.indexOf() ` ] [ ] , support additional arguments.
260260
@@ -2056,7 +2056,7 @@ If `value` is:
20562056* a string, ` value ` is interpreted according to the character encoding in
20572057 ` encoding ` .
20582058* 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 ` ] [ ] .
20602060* a number, ` value ` will be interpreted as an unsigned 8-bit integer
20612061 value between ` 0 ` and ` 255 ` .
20622062
@@ -3389,6 +3389,9 @@ console.log(buf.subarray(-5, -2).toString());
33893389<!-- YAML
33903390added: v0.3.0
33913391changes:
3392+ - version: REPLACEME
3393+ pr-url: https://github.com/nodejs/node/pull/41596
3394+ description: The buf.slice() method has been deprecated.
33923395 - version:
33933396 - v7.1.0
33943397 - v6.9.2
@@ -3406,11 +3409,11 @@ changes:
34063409 ** Default:** [ ` buf.length ` ] [ ] .
34073410* Returns: {Buffer}
34083411
3412+ > Stability: 0 - Deprecated: Use [ ` buf.subarray ` ] [ ] instead.
3413+
34093414Returns a new ` Buffer ` that references the same memory as the original, but
34103415offset and cropped by the ` start ` and ` end ` indices.
34113416
3412- This is the same behavior as ` buf.subarray() ` .
3413-
34143417This method is not compatible with the ` Uint8Array.prototype.slice() ` ,
34153418which is a superclass of ` Buffer ` . To copy the slice, use
34163419` Uint8Array.prototype.slice() ` .
@@ -5355,6 +5358,7 @@ introducing security vulnerabilities into an application.
53555358[ `buf.keys()` ] : #bufkeys
53565359[ `buf.length` ] : #buflength
53575360[ `buf.slice()` ] : #bufslicestart-end
5361+ [ `buf.subarray` ] : #bufsubarraystart-end
53585362[ `buf.toString()` ] : #buftostringencoding-start-end
53595363[ `buf.values()` ] : #bufvalues
53605364[ `buffer.constants.MAX_LENGTH` ] : #bufferconstantsmax_length
0 commit comments