From ced774827ca7a717d4d273780bb6f293ff57d9ca Mon Sep 17 00:00:00 2001 From: Jacob <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sun, 27 Jun 2021 10:24:04 +0200 Subject: [PATCH] doc: add annotation to writeFile `data` as `Object` Fixes: https://github.com/nodejs/node/issues/39152 --- doc/api/fs.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index b4f2c1e11a14b0..00a5def4f6e9c2 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1280,8 +1280,8 @@ changes: --> * `file` {string|Buffer|URL|FileHandle} filename or `FileHandle` -* `data` {string|Buffer|TypedArray|DataView|Object|AsyncIterable|Iterable - |Stream} +* `data` {string|Buffer|TypedArray|DataView|AsyncIterable|Iterable|Stream| +Object}* * `options` {Object|string} * `encoding` {string|null} **Default:** `'utf8'` * `mode` {integer} **Default:** `0o666` @@ -1290,8 +1290,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, like all variations of `writeFile`, an +object with an own (not inherited) `toString` function property. The `encoding` option is ignored if `data` is a buffer. @@ -3930,7 +3930,7 @@ changes: --> * `file` {string|Buffer|URL|integer} filename or file descriptor -* `data` {string|Buffer|TypedArray|DataView|Object} +* `data` {string|Buffer|TypedArray|DataView|Object}* * `options` {Object|string} * `encoding` {string|null} **Default:** `'utf8'` * `mode` {integer} **Default:** `0o666` @@ -3947,7 +3947,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 normal object, it must have an own (not inherited) `toString` +function property. ```mjs import { writeFile } from 'fs'; @@ -5026,7 +5028,7 @@ changes: --> * `file` {string|Buffer|URL|integer} filename or file descriptor -* `data` {string|Buffer|TypedArray|DataView|Object} +* `data` {string|Buffer|TypedArray|DataView|Object}* * `options` {Object|string} * `encoding` {string|null} **Default:** `'utf8'` * `mode` {integer} **Default:** `0o666`