Visitar URL original
fs: support caller-supplied readFile() buffers by mcollina · Pull Request #63634 · nodejs/node · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
doc: add Buffer import to examples to satisfy lint
PR-URL: #63634
Signed-off-by: matteo <matteo@example.com>
  • Loading branch information
mcollina committed Jun 10, 2026
commit e6c1949c90e79f808c7addd6c6574e2a654aedab
6 changes: 6 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ of the file.
An example using the `buffer` option with a pre-allocated buffer:

```mjs
import { Buffer } from 'node:buffer';
import { open } from 'node:fs/promises';

const file = await open('./some/file/to/read');
Expand All @@ -745,6 +746,7 @@ try {
An example using the `buffer` option with a function returning a buffer:

```mjs
import { Buffer } from 'node:buffer';
import { open } from 'node:fs/promises';

const file = await open('./some/file/to/read');
Expand Down Expand Up @@ -1902,6 +1904,7 @@ Any specified {FileHandle} has to support reading.
An example using the `buffer` option with a pre-allocated buffer:

```mjs
import { Buffer } from 'node:buffer';
import { readFile } from 'node:fs/promises';

const buf = Buffer.alloc(16384);
Expand All @@ -1912,6 +1915,7 @@ console.log(contents); // A view over `buf` containing only the bytes read
An example using the `buffer` option with a function returning a buffer:

```mjs
import { Buffer } from 'node:buffer';
import { readFile } from 'node:fs/promises';

const contents = await readFile('/path/to/file', {
Expand Down Expand Up @@ -4420,6 +4424,7 @@ system requests but rather the internal buffering `fs.readFile` performs.
An example using the `buffer` option with a pre-allocated buffer:

```mjs
import { Buffer } from 'node:buffer';
import { readFile } from 'node:fs';

const buf = Buffer.alloc(16384);
Expand All @@ -4432,6 +4437,7 @@ readFile('/path/to/file', { buffer: buf }, (err, data) => {
An example using the `buffer` option with a function returning a buffer:

```mjs
import { Buffer } from 'node:buffer';
import { readFile } from 'node:fs';

readFile('/path/to/file', {
Expand Down
Loading