Skip to content

Commit 010ea71

Browse files
doc: add annotation to writeFile data as Object
Fixes: #39152
1 parent 44ecd41 commit 010ea71

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

doc/api/fs.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ changes:
450450
451451
Write `buffer` to the file.
452452
453+
If `buffer` is a plain object, like all variations of `writeFile`, it must have
454+
an own (not inherited) `toString` function property.
455+
453456
The promise is resolved with an object containing two properties:
454457
455458
* `bytesWritten` {integer} the number of bytes written
@@ -1290,8 +1293,8 @@ changes:
12901293
* Returns: {Promise} Fulfills with `undefined` upon success.
12911294
12921295
Asynchronously writes data to a file, replacing the file if it already exists.
1293-
`data` can be a string, a {Buffer}, or an object with an own `toString` function
1294-
property.
1296+
`data` can be a string, a {Buffer}, or, like all variations of `writeFile`, an
1297+
object with an own (not inherited) `toString` function property.
12951298
12961299
The `encoding` option is ignored if `data` is a buffer.
12971300
@@ -3947,7 +3950,9 @@ When `file` is a file descriptor, the behavior is similar to calling
39473950
a file descriptor.
39483951
39493952
The `encoding` option is ignored if `data` is a buffer.
3950-
If `data` is a normal object, it must have an own `toString` function property.
3953+
3954+
If `data` is a plain object, like all variations of `writeFile`, it must have an
3955+
own (not inherited) `toString` function property.
39513956
39523957
```mjs
39533958
import { writeFile } from 'fs';
@@ -5034,6 +5039,9 @@ changes:
50345039
50355040
Returns `undefined`.
50365041
5042+
If `data` is a plain object, like all variations of `writeFile`, it must have an
5043+
own (not inherited) `toString` function property.
5044+
50375045
For detailed information, see the documentation of the asynchronous version of
50385046
this API: [`fs.writeFile()`][].
50395047

0 commit comments

Comments
 (0)