Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLiviaMedeiros <livia@cirno.name>2022-04-04 14:07:50 +0300
committerBryan English <bryan@bryanenglish.com>2022-05-30 19:26:50 +0300
commit3e89b7336dbdfb7bec601e52b49d63fa3a0105f4 (patch)
treef0bb0730071dd579374fa5427f88eadcbfa1eeca /doc
parent72a767b7cab21c9e5c57994767e318c6f2041a9c (diff)
fs: make params in writing methods optional
This change allows passing objects as "named parameters": - `fs.write(fd, buffer[, options], callback)` - `fs.writeSync(fd, buffer[, options])` - `filehandle.write(buffer[, options])` Fixes: https://github.com/nodejs/node/issues/41666 PR-URL: https://github.com/nodejs/node/pull/42601 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/fs.md67
1 files changed, 63 insertions, 4 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md
index 272473ab704..c596e1b499f 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -608,7 +608,7 @@ added: v10.0.0
Change the file system timestamps of the object referenced by the {FileHandle}
then resolves the promise with no arguments upon success.
-#### `filehandle.write(buffer[, offset[, length[, position]]])`
+#### `filehandle.write(buffer, offset[, length[, position]])`
<!-- YAML
added: v10.0.0
@@ -621,7 +621,7 @@ changes:
* `buffer` {Buffer|TypedArray|DataView}
* `offset` {integer} The start position from within `buffer` where the data
- to write begins. **Default:** `0`
+ to write begins.
* `length` {integer} The number of bytes from `buffer` to write. **Default:**
`buffer.byteLength - offset`
* `position` {integer|null} The offset from the beginning of the file where the
@@ -646,6 +646,25 @@ On Linux, positional writes do not work when the file is opened in append mode.
The kernel ignores the position argument and always appends the data to
the end of the file.
+#### `filehandle.write(buffer[, options])`
+
+<!-- YAML
+added: REPLACEME
+-->
+
+* `buffer` {Buffer|TypedArray|DataView}
+* `options` {Object}
+ * `offset` {integer} **Default:** `0`
+ * `length` {integer} **Default:** `buffer.byteLength - offset`
+ * `position` {integer} **Default:** `null`
+* Returns: {Promise}
+
+Write `buffer` to the file.
+
+Similar to the above `filehandle.write` function, this version takes an
+optional `options` object. If no `options` object is specified, it will
+default with the above values.
+
#### `filehandle.write(string[, position[, encoding]])`
<!-- YAML
@@ -4372,7 +4391,7 @@ This happens when:
* the file is deleted, followed by a restore
* the file is renamed and then renamed a second time back to its original name
-### `fs.write(fd, buffer[, offset[, length[, position]]], callback)`
+### `fs.write(fd, buffer, offset[, length[, position]], callback)`
<!-- YAML
added: v0.0.2
@@ -4439,6 +4458,29 @@ On Linux, positional writes don't work when the file is opened in append mode.
The kernel ignores the position argument and always appends the data to
the end of the file.
+### `fs.write(fd, buffer[, options], callback)`
+
+<!-- YAML
+added: REPLACEME
+-->
+
+* `fd` {integer}
+* `buffer` {Buffer|TypedArray|DataView}
+* `options` {Object}
+ * `offset` {integer} **Default:** `0`
+ * `length` {integer} **Default:** `buffer.byteLength - offset`
+ * `position` {integer} **Default:** `null`
+* `callback` {Function}
+ * `err` {Error}
+ * `bytesWritten` {integer}
+ * `buffer` {Buffer|TypedArray|DataView}
+
+Write `buffer` to the file specified by `fd`.
+
+Similar to the above `fs.write` function, this version takes an
+optional `options` object. If no `options` object is specified, it will
+default with the above values.
+
### `fs.write(fd, string[, position[, encoding]], callback)`
<!-- YAML
@@ -5787,7 +5829,7 @@ for more details.
For detailed information, see the documentation of the asynchronous version of
this API: [`fs.writeFile()`][].
-### `fs.writeSync(fd, buffer[, offset[, length[, position]]])`
+### `fs.writeSync(fd, buffer, offset[, length[, position]])`
<!-- YAML
added: v0.1.21
@@ -5818,6 +5860,23 @@ changes:
For detailed information, see the documentation of the asynchronous version of
this API: [`fs.write(fd, buffer...)`][].
+### `fs.writeSync(fd, buffer[, options])`
+
+<!-- YAML
+added: REPLACEME
+-->
+
+* `fd` {integer}
+* `buffer` {Buffer|TypedArray|DataView}
+* `options` {Object}
+ * `offset` {integer} **Default:** `0`
+ * `length` {integer} **Default:** `buffer.byteLength - offset`
+ * `position` {integer} **Default:** `null`
+* Returns: {number} The number of bytes written.
+
+For detailed information, see the documentation of the asynchronous version of
+this API: [`fs.write(fd, buffer...)`][].
+
### `fs.writeSync(fd, string[, position[, encoding]])`
<!-- YAML