Skip to content

buffer: fix return value on inherited ES2023 methods - #68029

Open
LiviaMedeiros wants to merge 2 commits into
nodejs:mainfrom
LiviaMedeiros:buffer-es2023
Open

LiviaMedeiros wants to merge 2 commits into
nodejs:mainfrom
LiviaMedeiros:buffer-es2023

Conversation

@LiviaMedeiros

Copy link
Copy Markdown
Member

This PR makes buffer.toReversed(), buffer.toSorted(), and buffer.with() return Buffer instances.

As noticed in #61146 (comment), currently these methods return Uint8Arrays.

This is intentionally not documented as we don't document every method inherited from Uint8Array.prototype (e.g. buffer.reverse() "just works") and this doesn't change their logic.

The internal implementation details (these methods always return unpooled buffers) are intentionally not tested so any potential Buffer-specific optimization doesn't have to be semver-major.

Signed-off-by: LiviaMedeiros <livia@cirno.name>
@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. needs-ci PRs that need a full CI run. labels Dec 5, 2026
@codecov

codecov Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.57%. Comparing base (c67d87c) to head (63eab21).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #68029      +/-   ##
==========================================
- Coverage   90.58%   90.57%   -0.01%     
==========================================
  Files         802      802              
  Lines      287050   287109      +59     
  Branches    55431    55451      +20     
==========================================
+ Hits       260013   260051      +38     
- Misses      17131    17140       +9     
- Partials     9906     9918      +12     
Files with missing lines Coverage Δ
lib/buffer.js 99.75% <100.00%> (+<0.01%) ⬆️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread lib/buffer.js Resolved
@Renegade334 Renegade334 added the semver-major PRs that contain breaking changes and should be released in the next major version. label Dec 5, 2026
@Renegade334

Copy link
Copy Markdown
Member

May be overkill, but marking as semver-major since this changes the behaviour of eg. buf.toReversed().slice(...).

Signed-off-by: LiviaMedeiros <livia@cirno.name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buffer Issues and PRs related to the buffer subsystem. needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants