Skip to content
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

doc: add annotation to writeFile data as Object #39167

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
20 changes: 17 additions & 3 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ changes:

Write `buffer` to the file.

If `buffer` is a plain object, it must have an own (not inherited) `toString`
function property.

The promise is resolved with an object containing two properties:

* `bytesWritten` {integer} the number of bytes written
Expand Down Expand Up @@ -1290,8 +1293,8 @@ changes:
* Returns: {Promise} Fulfills with `undefined` upon success.

Asynchronously writes data to a file, replacing the file if it already exists.
`data` can be a string, a {Buffer}, or an object with an own `toString` function
property.
`data` can be a string, a {Buffer}, or, an object with an own (not inherited)
`toString` function property.

The `encoding` option is ignored if `data` is a buffer.

Expand Down Expand Up @@ -3947,7 +3950,9 @@ When `file` is a file descriptor, the behavior is similar to calling
a file descriptor.

The `encoding` option is ignored if `data` is a buffer.
If `data` is a normal object, it must have an own `toString` function property.

If `data` is a plain object, it must have an own (not inherited) `toString`
function property.

```mjs
import { writeFile } from 'fs';
Expand Down Expand Up @@ -5034,6 +5039,9 @@ changes:

Returns `undefined`.

If `data` is a plain object, it must have an own (not inherited) `toString`
function property.

For detailed information, see the documentation of the asynchronous version of
this API: [`fs.writeFile()`][].

Expand Down Expand Up @@ -5068,6 +5076,9 @@ changes:
* `position` {integer}
* Returns: {number} The number of bytes written.

If `buffer` is a plain object, it must have an own (not inherited) `toString`
function property.

For detailed information, see the documentation of the asynchronous version of
this API: [`fs.write(fd, buffer...)`][].

Expand All @@ -5094,6 +5105,9 @@ changes:
* `encoding` {string}
* Returns: {number} The number of bytes written.

If `string` is a plain object, it must have an own (not inherited) `toString`
function property.

For detailed information, see the documentation of the asynchronous version of
this API: [`fs.write(fd, string...)`][].

Expand Down