| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e500d11 commit 2e7bf00
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3045,6 +3045,22 @@ const w = new Writable({ | |||
| 3045 | 3045 | }); | |
| 3046 | 3046 | ``` | |
| 3047 | 3047 | ||
| 3048 | + ### DEP0158: `buffer.slice(start, end)` | ||
| 3049 | + | ||
| 3050 | + <!-- YAML | ||
| 3051 | + changes: | ||
| 3052 | + - version: REPLACEME | ||
| 3053 | + pr-url: https://github.com/nodejs/node/pull/41596 | ||
| 3054 | + description: Documentation-only deprecation. | ||
| 3055 | + --> | ||
| 3056 | + | ||
| 3057 | + Type: Documentation-only | ||
| 3058 | + | ||
| 3059 | + This method was deprecated because it is not compatible with | ||
| 3060 | + `Uint8Array.prototype.slice()`, which is a superclass of `Buffer`. | ||
| 3061 | + | ||
| 3062 | + Use [`buffer.subarray`][] which does the same thing instead. | ||
| 3063 | + | ||
| 3048 | 3064 | [Legacy URL API]: url.md#legacy-url-api | |
| 3049 | 3065 | [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 3050 | 3066 | [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 | |
@@ -3067,6 +3083,7 @@ const w = new Writable({ | |||
| 3067 | 3083 | [`WriteStream.open()`]: fs.md#class-fswritestream | |
| 3068 | 3084 | [`assert`]: assert.md | |
| 3069 | 3085 | [`asyncResource.runInAsyncScope()`]: async_context.md#asyncresourceruninasyncscopefn-thisarg-args | |
| 3086 | + [`buffer.subarray`]: buffer.md#bufsubarraystart-end | ||
| 3070 | 3087 | [`child_process`]: child_process.md | |
| 3071 | 3088 | [`clearInterval()`]: timers.md#clearintervaltimeout | |
| 3072 | 3089 | [`clearTimeout()`]: timers.md#cleartimeouttimeout | |
| Back | FazBrowse Home | New Git URL |
0 commit comments