diff --git a/doc/api/fs.md b/doc/api/fs.md index 63c07566c8917b..69138b6ac4843e 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1298,35 +1298,20 @@ changes: * `path` {string|Buffer|URL} * `options` {string|Object} - * `flags` {string} - * `encoding` {string} - * `fd` {integer} - * `mode` {integer} - * `autoClose` {boolean} + * `flags` {string} **Default:** `'r'` + * `encoding` {string} **Default:** `null` + * `fd` {integer} **Default:** `null` + * `mode` {integer} **Default:** `0o666` + * `autoClose` {boolean} **Default:** `true` * `start` {integer} - * `end` {integer} - * `highWaterMark` {integer} -* Returns: {stream.Readable} - -Returns a new [`ReadStream`][] object. (See [Readable Streams][]). + * `end` {integer} **Default:** `Infinity` + * `highWaterMark` {integer} **Default:** `64 * 1024` +* Returns: {fs.ReadStream} See [Readable Streams][]. Be aware that, unlike the default value set for `highWaterMark` on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter. -`options` is an object or string with the following defaults: - -```js -const defaults = { - flags: 'r', - encoding: null, - fd: null, - mode: 0o666, - autoClose: true, - highWaterMark: 64 * 1024 -}; -``` - `options` can include `start` and `end` values to read a range of bytes from the file instead of the entire file. Both `start` and `end` are inclusive and start counting at 0. If `fd` is specified and `start` is omitted or `undefined`, @@ -1376,27 +1361,13 @@ changes: * `path` {string|Buffer|URL} * `options` {string|Object} - * `flags` {string} - * `encoding` {string} - * `fd` {integer} - * `mode` {integer} - * `autoClose` {boolean} + * `flags` {string} **Default:** `'w'` + * `encoding` {string} **Default:** `'utf8'` + * `fd` {integer} **Default:** `null` + * `mode` {integer} **Default:** `0o666` + * `autoClose` {boolean} **Default:** `true` * `start` {integer} -* Returns: {stream.Writable} - -Returns a new [`WriteStream`][] object. (See [Writable Stream][]). - -`options` is an object or string with the following defaults: - -```js -const defaults = { - flags: 'w', - encoding: 'utf8', - fd: null, - mode: 0o666, - autoClose: true -}; -``` +* Returns: {fs.WriteStream} See [Writable Stream][]. `options` may also include a `start` option to allow writing data at some position past the beginning of the file. Modifying a file rather @@ -1410,7 +1381,7 @@ then the file descriptor won't be closed, even if there's an error. It is the application's responsibility to close it and make sure there's no file descriptor leak. -Like [`ReadStream`][], if `fd` is specified, `WriteStream` will ignore the +Like [`ReadStream`][], if `fd` is specified, [`WriteStream`][] will ignore the `path` argument and will use the specified file descriptor. This means that no `'open'` event will be emitted. Note that `fd` should be blocking; non-blocking `fd`s should be passed to [`net.Socket`][]. @@ -1675,7 +1646,7 @@ added: v0.1.95 * `fd` {integer} * Returns: {fs.Stats} -Synchronous fstat(2). Returns an instance of [`fs.Stats`][]. +Synchronous fstat(2). ## fs.fsync(fd, callback)