Skip to content

Commit 809eb27

Browse files
committed
doc: unify and compact some fragments in fs.md
PR-URL: #20050 Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 9f6742d commit 809eb27

File tree

2 files changed

+25
-51
lines changed

2 files changed

+25
-51
lines changed

doc/api/fs.md

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,35 +1298,20 @@ changes:
12981298

12991299
* `path` {string|Buffer|URL}
13001300
* `options` {string|Object}
1301-
* `flags` {string}
1302-
* `encoding` {string}
1303-
* `fd` {integer}
1304-
* `mode` {integer}
1305-
* `autoClose` {boolean}
1301+
* `flags` {string} **Default:** `'r'`
1302+
* `encoding` {string} **Default:** `null`
1303+
* `fd` {integer} **Default:** `null`
1304+
* `mode` {integer} **Default:** `0o666`
1305+
* `autoClose` {boolean} **Default:** `true`
13061306
* `start` {integer}
1307-
* `end` {integer}
1308-
* `highWaterMark` {integer}
1309-
* Returns: {stream.Readable}
1310-
1311-
Returns a new [`ReadStream`][] object. (See [Readable Streams][]).
1307+
* `end` {integer} **Default:** `Infinity`
1308+
* `highWaterMark` {integer} **Default:** `64 * 1024`
1309+
* Returns: {fs.ReadStream} See [Readable Streams][].
13121310

13131311
Be aware that, unlike the default value set for `highWaterMark` on a
13141312
readable stream (16 kb), the stream returned by this method has a
13151313
default value of 64 kb for the same parameter.
13161314

1317-
`options` is an object or string with the following defaults:
1318-
1319-
```js
1320-
const defaults = {
1321-
flags: 'r',
1322-
encoding: null,
1323-
fd: null,
1324-
mode: 0o666,
1325-
autoClose: true,
1326-
highWaterMark: 64 * 1024
1327-
};
1328-
```
1329-
13301315
`options` can include `start` and `end` values to read a range of bytes from
13311316
the file instead of the entire file. Both `start` and `end` are inclusive and
13321317
start counting at 0. If `fd` is specified and `start` is omitted or `undefined`,
@@ -1376,27 +1361,13 @@ changes:
13761361

13771362
* `path` {string|Buffer|URL}
13781363
* `options` {string|Object}
1379-
* `flags` {string}
1380-
* `encoding` {string}
1381-
* `fd` {integer}
1382-
* `mode` {integer}
1383-
* `autoClose` {boolean}
1364+
* `flags` {string} **Default:** `'w'`
1365+
* `encoding` {string} **Default:** `'utf8'`
1366+
* `fd` {integer} **Default:** `null`
1367+
* `mode` {integer} **Default:** `0o666`
1368+
* `autoClose` {boolean} **Default:** `true`
13841369
* `start` {integer}
1385-
* Returns: {stream.Writable}
1386-
1387-
Returns a new [`WriteStream`][] object. (See [Writable Stream][]).
1388-
1389-
`options` is an object or string with the following defaults:
1390-
1391-
```js
1392-
const defaults = {
1393-
flags: 'w',
1394-
encoding: 'utf8',
1395-
fd: null,
1396-
mode: 0o666,
1397-
autoClose: true
1398-
};
1399-
```
1370+
* Returns: {fs.WriteStream} See [Writable Stream][].
14001371

14011372
`options` may also include a `start` option to allow writing data at
14021373
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.
14101381
It is the application's responsibility to close it and make sure there's no
14111382
file descriptor leak.
14121383

1413-
Like [`ReadStream`][], if `fd` is specified, `WriteStream` will ignore the
1384+
Like [`ReadStream`][], if `fd` is specified, [`WriteStream`][] will ignore the
14141385
`path` argument and will use the specified file descriptor. This means that no
14151386
`'open'` event will be emitted. Note that `fd` should be blocking; non-blocking
14161387
`fd`s should be passed to [`net.Socket`][].
@@ -1675,7 +1646,7 @@ added: v0.1.95
16751646
* `fd` {integer}
16761647
* Returns: {fs.Stats}
16771648

1678-
Synchronous fstat(2). Returns an instance of [`fs.Stats`][].
1649+
Synchronous fstat(2).
16791650

16801651
## fs.fsync(fd, callback)
16811652
<!-- YAML
@@ -1978,7 +1949,7 @@ changes:
19781949
* `path` {string|Buffer|URL}
19791950
* Returns: {fs.Stats}
19801951

1981-
Synchronous lstat(2). Returns an instance of [`fs.Stats`][].
1952+
Synchronous lstat(2).
19821953

19831954
## fs.mkdir(path[, mode], callback)
19841955
<!-- YAML
@@ -2339,10 +2310,9 @@ changes:
23392310
* `path` {string|Buffer|URL}
23402311
* `options` {string|Object}
23412312
* `encoding` {string} **Default:** `'utf8'`
2342-
* Returns: {string[]} An array of filenames
2313+
* Returns: {string[]} An array of filenames excluding `'.'` and `'..'`.
23432314

2344-
Synchronous readdir(3). Returns an array of filenames excluding `'.'` and
2345-
`'..'`.
2315+
Synchronous readdir(3).
23462316

23472317
The optional `options` argument can be a string specifying an encoding, or an
23482318
object with an `encoding` property specifying the character encoding to use for
@@ -2841,7 +2811,7 @@ changes:
28412811
* `path` {string|Buffer|URL}
28422812
* Returns: {fs.Stats}
28432813

2844-
Synchronous stat(2). Returns an instance of [`fs.Stats`][].
2814+
Synchronous stat(2).
28452815

28462816
## fs.symlink(target, path[, type], callback)
28472817
<!-- YAML
@@ -3094,9 +3064,10 @@ changes:
30943064
* `listener` {Function|undefined} **Default:** `undefined`
30953065
* `eventType` {string}
30963066
* `filename` {string|Buffer}
3067+
* Returns: {fs.FSWatcher}
30973068

30983069
Watch for changes on `filename`, where `filename` is either a file or a
3099-
directory. The returned object is a [`fs.FSWatcher`][].
3070+
directory.
31003071

31013072
The second argument is optional. If `options` is provided as a string, it
31023073
specifies the `encoding`. Otherwise `options` should be passed as an object.

tools/doc/type-parser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ const customTypesMap = {
5959
'EventEmitter': 'events.html#events_class_eventemitter',
6060

6161
'FileHandle': 'fs.html#fs_class_filehandle',
62+
'fs.FSWatcher': 'fs.html#fs_class_fs_fswatcher',
63+
'fs.ReadStream': 'fs.html#fs_class_fs_readstream',
6264
'fs.Stats': 'fs.html#fs_class_fs_stats',
65+
'fs.WriteStream': 'fs.html#fs_class_fs_writestream',
6366

6467
'http.Agent': 'http.html#http_class_http_agent',
6568
'http.ClientRequest': 'http.html#http_class_http_clientrequest',

0 commit comments

Comments
 (0)