Skip to content

Commit 05d7460

Browse files
JakobJingleheimertargos
authored andcommitted
doc: add annotation to writeFile data as Object
Fixes: #39152 PR-URL: #39167 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 2ef61b9 commit 05d7460

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

doc/api/fs.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ changes:
435435
436436
Write `buffer` to the file.
437437
438+
If `buffer` is a plain object, it must have an own (not inherited) `toString`
439+
function property.
440+
438441
The promise is resolved with an object containing two properties:
439442
440443
* `bytesWritten` {integer} the number of bytes written
@@ -1273,8 +1276,8 @@ changes:
12731276
* Returns: {Promise} Fulfills with `undefined` upon success.
12741277
12751278
Asynchronously writes data to a file, replacing the file if it already exists.
1276-
`data` can be a string, a {Buffer}, or an object with an own `toString` function
1277-
property.
1279+
`data` can be a string, a {Buffer}, or, an object with an own (not inherited)
1280+
`toString` function property.
12781281
12791282
The `encoding` option is ignored if `data` is a buffer.
12801283
@@ -3893,7 +3896,9 @@ When `file` is a file descriptor, the behavior is similar to calling
38933896
a file descriptor.
38943897
38953898
The `encoding` option is ignored if `data` is a buffer.
3896-
If `data` is a normal object, it must have an own `toString` function property.
3899+
3900+
If `data` is a plain object, it must have an own (not inherited) `toString`
3901+
function property.
38973902
38983903
```mjs
38993904
import { writeFile } from 'fs';
@@ -4973,6 +4978,9 @@ changes:
49734978
49744979
Returns `undefined`.
49754980
4981+
If `data` is a plain object, it must have an own (not inherited) `toString`
4982+
function property.
4983+
49764984
For detailed information, see the documentation of the asynchronous version of
49774985
this API: [`fs.writeFile()`][].
49784986
@@ -5007,6 +5015,9 @@ changes:
50075015
* `position` {integer}
50085016
* Returns: {number} The number of bytes written.
50095017
5018+
If `buffer` is a plain object, it must have an own (not inherited) `toString`
5019+
function property.
5020+
50105021
For detailed information, see the documentation of the asynchronous version of
50115022
this API: [`fs.write(fd, buffer...)`][].
50125023
@@ -5033,6 +5044,9 @@ changes:
50335044
* `encoding` {string}
50345045
* Returns: {number} The number of bytes written.
50355046
5047+
If `string` is a plain object, it must have an own (not inherited) `toString`
5048+
function property.
5049+
50365050
For detailed information, see the documentation of the asynchronous version of
50375051
this API: [`fs.write(fd, string...)`][].
50385052

0 commit comments

Comments
 (0)