@@ -252,7 +252,7 @@ In particular:
252252 without copying. This behavior can be surprising, and only exists for legacy
253253 compatibility. [ ` TypedArray.prototype.subarray() ` ] [ ] can be used to achieve
254254 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 .
256256* [ ` buf.toString() ` ] [ ] is incompatible with its ` TypedArray ` equivalent.
257257* A number of methods, e.g. [ ` buf.indexOf() ` ] [ ] , support additional arguments.
258258
@@ -2038,7 +2038,7 @@ If `value` is:
20382038* a string, ` value ` is interpreted according to the character encoding in
20392039 ` encoding ` .
20402040* 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 ` ] [ ] .
20422042* a number, ` value ` will be interpreted as an unsigned 8-bit integer
20432043 value between ` 0 ` and ` 255 ` .
20442044
@@ -3371,6 +3371,9 @@ console.log(buf.subarray(-5, -2).toString());
33713371<!-- YAML
33723372added: v0.3.0
33733373changes:
3374+ - version: REPLACEME
3375+ pr-url: https://github.com/nodejs/node/pull/41596
3376+ description: The buf.slice() method has been deprecated.
33743377 - version:
33753378 - v7.1.0
33763379 - v6.9.2
@@ -3388,11 +3391,11 @@ changes:
33883391 ** Default:** [ ` buf.length ` ] [ ] .
33893392* Returns: {Buffer}
33903393
3394+ > Stability: 0 - Deprecated: Use [ ` buf.subarray ` ] [ ] instead.
3395+
33913396Returns a new ` Buffer ` that references the same memory as the original, but
33923397offset and cropped by the ` start ` and ` end ` indices.
33933398
3394- This is the same behavior as ` buf.subarray() ` .
3395-
33963399This method is not compatible with the ` Uint8Array.prototype.slice() ` ,
33973400which is a superclass of ` Buffer ` . To copy the slice, use
33983401` Uint8Array.prototype.slice() ` .
@@ -5349,6 +5352,7 @@ introducing security vulnerabilities into an application.
53495352[ `buf.keys()` ] : #bufkeys
53505353[ `buf.length` ] : #buflength
53515354[ `buf.slice()` ] : #bufslicestart-end
5355+ [ `buf.subarray` ] : #bufsubarraystart-end
53525356[ `buf.toString()` ] : #buftostringencoding-start-end
53535357[ `buf.values()` ] : #bufvalues
53545358[ `buffer.constants.MAX_LENGTH` ] : #bufferconstantsmax_length
0 commit comments