Skip to content

Conversation

@araujogui
Copy link
Member

Fixes #53700

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Dec 24, 2025
@araujogui araujogui marked this pull request as draft December 24, 2025 18:16
@araujogui araujogui marked this pull request as ready for review December 25, 2025 15:53
@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

❌ Patch coverage is 86.59794% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.52%. Comparing base (4f24aff) to head (90e196e).
⚠️ Report is 112 commits behind head on main.

Files with missing lines Patch % Lines
src/node_buffer.cc 67.50% 7 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61168      +/-   ##
==========================================
- Coverage   88.53%   88.52%   -0.01%     
==========================================
  Files         703      704       +1     
  Lines      208546   208797     +251     
  Branches    40217    40283      +66     
==========================================
+ Hits       184634   184840     +206     
- Misses      15926    15944      +18     
- Partials     7986     8013      +27     
Files with missing lines Coverage Δ
lib/buffer.js 99.85% <100.00%> (-0.15%) ⬇️
src/node_buffer.cc 69.18% <67.50%> (+0.30%) ⬆️

... and 72 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.

@bakkot
Copy link
Contributor

bakkot commented Dec 26, 2025

There's been some efforts (notably by @jasnell) to bring the native JS buffer/TA types into alignment with Buffer, at least for major use cases. See also #41588.

Adding new functionality to Buffer seems contrary to that effort. I'm not necessarily opposed, but it's probably worth thinking through what it would look like for this functionality to exist in pure JS, or alternatively what alternatives would exist in JS such that it would enable people to migrate away from use of Buffer.

@araujogui
Copy link
Member Author

@bakkot I created and verified with benchmarks, and you're right. The standard Web API dst.set(new Uint8Array(src)) consistently outperforms this PR.

Since the standard approach is both more idiomatic and more performant, there’s no reason to add more surface area to Buffer.

I guess we can close this PR

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. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Buffer.copy to take an ArrayBuffer

3 participants