Repository navigation
fix: return empty results for reversed buffer ranges - #191
Merged
Merged
Conversation
rvagg
approved these changes
Nov 21, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 21, 2026
## [7.0.16](v7.0.15...v7.0.16) (2026-11-21) ### Bug Fixes * handle reversed buffer ranges consistently ([#191](#191)) ([33296e7](33296e7))
|
🎉 This PR is included in version 7.0.16 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reading a reversed range depends on the internal chunk layout: for example,
new BufferList(['abcd', 'efgh']).slice(5, 2)returnsf, whileshallowSlice(5, 2)throws. A native Buffer returns an empty slice for that range. Copying a reversed range can also modify the destination or throw when the range starts inside a later chunk.Return an empty result, or leave the copy destination unchanged, after normalizing a range whose end does not follow its start. The regression covers both exported classes, single and multiple chunks, negative slice offsets, and ordinary/equal-range controls.
Validation:
npm run test:cipassed on Node 20.20.2, 22.23.2, and 26.13.0 (lint, 983 runtime assertions, declaration build, TypeScript consumer checks, and 55 generated API assertions). The added regression produces 32 failed assertions on the unchanged upstream source. A separate public API matrix, including a piped stream consumer and shallow-memory sharing control, passed 2,927 checks per runtime; upstream failed 326 of those checks on Node 22.