Skip to content

doc: multiple minor fixes to fs.md #20450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
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
19 changes: 7 additions & 12 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1316,9 +1316,8 @@ changes:
* `highWaterMark` {integer} **Default:** `64 * 1024`
* Returns: {fs.ReadStream} See [Readable Streams][].

Be aware that, unlike the default value set for `highWaterMark` on a
readable stream (16 kb), the stream returned by this method has a
default value of 64 kb for the same parameter.
Unlike the 16 kb default `highWaterMark` for a readable stream, the stream
returned by this method has a default `highWaterMark` of 64 kb.

`options` can include `start` and `end` values to read a range of bytes from
the file instead of the entire file. Both `start` and `end` are inclusive and
Expand Down Expand Up @@ -3234,10 +3233,6 @@ The callback will receive the arguments `(err, written, string)` where `written`
specifies how many _bytes_ the passed string required to be written. Note that
bytes written is not the same as string characters. See [`Buffer.byteLength`][].

Unlike when writing `buffer`, the entire string must be written. No substring
may be specified. This is because the byte offset of the resulting data may not
be the same as the string offset.

Note that it is unsafe to use `fs.write` multiple times on the same file
without waiting for the callback. For this scenario,
`fs.createWriteStream` is strongly recommended.
Expand Down Expand Up @@ -3383,11 +3378,11 @@ and will emit a process warning, thereby helping to prevent memory leaks.
Instances of the `FileHandle` object are created internally by the
`fsPromises.open()` method.

Unlike callback-based such as `fs.fstat()`, `fs.fchown()`, `fs.fchmod()`,
`fs.ftruncate()`, `fs.read()`, and `fs.write()`, operations — all of which
use a simple numeric file descriptor, all `fsPromises.*` variations use the
`FileHandle` class in order to help protect against accidental leaking of
unclosed file descriptors after a `Promise` is resolved or rejected.
Unlike the callback-based API (`fs.fstat()`, `fs.fchown()`, `fs.fchmod()`, and
so on), a numeric file descriptor is not used by the promise-based API. Instead,
the promise-based API uses the `FileHandle` class in order to help avoid
accidental leaking of unclosed file descriptors after a `Promise` is resolved or
rejected.

#### filehandle.appendFile(data, options)
<!-- YAML
Expand Down