fs: support caller-supplied readFile() buffers#63634
Open
mcollina wants to merge 1 commit into
Open
Conversation
mcollina
added a commit
to mcollina/node
that referenced
this pull request
May 29, 2026
PR-URL: nodejs#63634 Signed-off-by: Matteo Collina <hello@matteocollina.com>
50d050d to
e04e121
Compare
PR-URL: nodejs#63634 Signed-off-by: Matteo Collina <matteo.collina@gmail.com>
e04e121 to
2f1e60f
Compare
Renegade334
reviewed
May 29, 2026
Comment on lines
+708
to
+710
| * `buffer` {Buffer|TypedArray|DataView} A buffer to read into. | ||
| * `getBuffer` {Function} A synchronous function called with the file size and | ||
| returning the buffer to read into. |
Member
There was a problem hiding this comment.
Could we not consolidate these two? Plenty of places across the API surface have options with "either a thing or a thing-like function" types.
Contributor
There was a problem hiding this comment.
Agreed. It should be quite cheap to check typeof options.buffer === 'function' at the start.
| } | ||
| }); | ||
|
|
||
| const validateReadFileBufferOptions = hideStackFrames((options) => { |
Member
There was a problem hiding this comment.
I would personally advocate for this to throw if both buffer and encoding are provided – directly contradictory patterns should fail validation.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63634 +/- ##
==========================================
+ Coverage 90.29% 90.30% +0.01%
==========================================
Files 730 730
Lines 234782 235056 +274
Branches 43953 44007 +54
==========================================
+ Hits 211993 212269 +276
Misses 14501 14501
+ Partials 8288 8286 -2
🚀 New features to boost your workflow:
|
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.
Fixes: #63600