From a100709fa8c810911a5ff31e7382c339191d471a Mon Sep 17 00:00:00 2001 From: Lucas Holmquist Date: Tue, 24 Mar 2020 11:23:33 -0400 Subject: [PATCH] fs: make parameters optional for readSync This makes the offset, length and position parameters optional by passing in an options object. PR-URL: https://github.com/nodejs/node/pull/32460 Reviewed-By: Anna Henningsen --- doc/api/fs.md | 26 ++++++++++++++++++ lib/fs.js | 12 +++++++++ .../test-fs-readSync-optional-params.js | 27 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 test/parallel/test-fs-readSync-optional-params.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 9cca6599b16525..bbbf40c47a173e 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -3080,6 +3080,32 @@ Returns the number of `bytesRead`. For detailed information, see the documentation of the asynchronous version of this API: [`fs.read()`][]. +## `fs.readSync(fd, buffer, [options])` + + +* `fd` {integer} +* `buffer` {Buffer|TypedArray|DataView} +* `options` {Object} + * `offset` {integer} **Default:** `0` + * `length` {integer} **Default:** `buffer.length` + * `position` {integer} **Default:** `null` +* Returns: {number} + +Returns the number of `bytesRead`. + +Similar to the above `fs.readSync` function, this version takes an optional `options` object. +If no `options` object is specified, it will default with the above values. + +For detailed information, see the documentation of the asynchronous version of +this API: [`fs.read()`][]. + ## `fs.readv(fd, buffers[, position], callback)`