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/api
diff options
context:
space:
mode:
authorLucas Holmquist <lholmqui@redhat.com>2020-01-16 17:46:28 +0300
committerAnna Henningsen <anna@addaleax.net>2020-03-11 18:47:29 +0300
commitb6da55f0fda60433f8d05539ee8665f66a35ee86 (patch)
treec2dd9e488ebe8754b3c7aee90cddd72cf4d96198 /doc/api
parent4f87b4f4ba7a0d9256fe01617708b6960c0558f5 (diff)
fs: make fs.read params optional
This makes all the parameters of the `fs.read` function, except for `fd` and the callback(when not using as a promise) optional. They will default to sensible defaults. Fixes: https://github.com/nodejs/node/issues/31237 PR-URL: https://github.com/nodejs/node/pull/31402 Reviewed-By: Robert Nagy <ronagy@icloud.com>
Diffstat (limited to 'doc/api')
-rw-r--r--doc/api/fs.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md
index a70f56f3c92..1ad49948f5a 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -2764,6 +2764,29 @@ The callback is given the three arguments, `(err, bytesRead, buffer)`.
If this method is invoked as its [`util.promisify()`][]ed version, it returns
a `Promise` for an `Object` with `bytesRead` and `buffer` properties.
+## `fs.read(fd, [options,] callback)`
+<!-- YAML
+added: REPLACEME
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/31402
+ description: Options object can be passed in
+ to make Buffer, offset, length and position optional
+-->
+* `fd` {integer}
+* `options` {Object}
+ * `buffer` {Buffer|TypedArray|DataView} **Default:** `Buffer.alloc(16384)`
+ * `offset` {integer} **Default:** `0`
+ * `length` {integer} **Default:** `buffer.length`
+ * `position` {integer} **Default:** `null`
+* `callback` {Function}
+ * `err` {Error}
+ * `bytesRead` {integer}
+ * `buffer` {Buffer}
+
+Similar to the above `fs.read` function, this version takes an optional `options` object.
+If no `options` object is specified, it will default with the above values.
+
## `fs.readdir(path[, options], callback)`
<!-- YAML
added: v0.1.8
@@ -4377,6 +4400,17 @@ Following successful read, the `Promise` is resolved with an object with a
`bytesRead` property specifying the number of bytes read, and a `buffer`
property that is a reference to the passed in `buffer` argument.
+#### `filehandle.read(options)`
+<!-- YAML
+added: REPLACEME
+-->
+* `options` {Object}
+ * `buffer` {Buffer|Uint8Array} **Default:** `Buffer.alloc(16384)`
+ * `offset` {integer} **Default:** `0`
+ * `length` {integer} **Default:** `buffer.length`
+ * `position` {integer} **Default:** `null`
+* Returns: {Promise}
+
#### `filehandle.readFile(options)`
<!-- YAML
added: v10.0.0