Skip to content

Commit 540ee65

Browse files
vsemozhetbytBridgeAR
authored andcommitted
doc: unify and compact some fragments in fs.md
PR-URL: nodejs#20050 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent ea1bf5c commit 540ee65

2 files changed

Lines changed: 26 additions & 51 deletions

File tree

doc/api/fs.md

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

12831283
* `path` {string|Buffer|URL}
12841284
* `options` {string|Object}
1285-
* `flags` {string}
1286-
* `encoding` {string}
1287-
* `fd` {integer}
1288-
* `mode` {integer}
1289-
* `autoClose` {boolean}
1285+
* `flags` {string} **Default:** `'r'`
1286+
* `encoding` {string} **Default:** `null`
1287+
* `fd` {integer} **Default:** `null`
1288+
* `mode` {integer} **Default:** `0o666`
1289+
* `autoClose` {boolean} **Default:** `true`
12901290
* `start` {integer}
1291-
* `end` {integer}
1292-
* `highWaterMark` {integer}
1293-
* Returns: {ReadStream}
1294-
1295-
Returns a new [`ReadStream`][] object. (See [Readable Streams][]).
1291+
* `end` {integer} **Default:** `Infinity`
1292+
* `highWaterMark` {integer} **Default:** `64 * 1024`
1293+
* Returns: {fs.ReadStream} See [Readable Streams][].
12961294

12971295
Be aware that, unlike the default value set for `highWaterMark` on a
12981296
readable stream (16 kb), the stream returned by this method has a
12991297
default value of 64 kb for the same parameter.
13001298

1301-
`options` is an object or string with the following defaults:
1302-
1303-
```js
1304-
const defaults = {
1305-
flags: 'r',
1306-
encoding: null,
1307-
fd: null,
1308-
mode: 0o666,
1309-
autoClose: true,
1310-
highWaterMark: 64 * 1024
1311-
};
1312-
```
1313-
13141299
`options` can include `start` and `end` values to read a range of bytes from
13151300
the file instead of the entire file. Both `start` and `end` are inclusive and
13161301
start counting at 0. If `fd` is specified and `start` is omitted or `undefined`,
@@ -1360,27 +1345,13 @@ changes:
13601345

13611346
* `path` {string|Buffer|URL}
13621347
* `options` {string|Object}
1363-
* `flags` {string}
1364-
* `encoding` {string}
1365-
* `fd` {integer}
1366-
* `mode` {integer}
1367-
* `autoClose` {boolean}
1348+
* `flags` {string} **Default:** `'w'`
1349+
* `encoding` {string} **Default:** `'utf8'`
1350+
* `fd` {integer} **Default:** `null`
1351+
* `mode` {integer} **Default:** `0o666`
1352+
* `autoClose` {boolean} **Default:** `true`
13681353
* `start` {integer}
1369-
* Returns: {WriteStream}
1370-
1371-
Returns a new [`WriteStream`][] object. (See [Writable Stream][]).
1372-
1373-
`options` is an object or string with the following defaults:
1374-
1375-
```js
1376-
const defaults = {
1377-
flags: 'w',
1378-
encoding: 'utf8',
1379-
fd: null,
1380-
mode: 0o666,
1381-
autoClose: true
1382-
};
1383-
```
1354+
* Returns: {fs.WriteStream} See [Writable Stream][].
13841355

13851356
`options` may also include a `start` option to allow writing data at
13861357
some position past the beginning of the file. Modifying a file rather
@@ -1394,7 +1365,7 @@ then the file descriptor won't be closed, even if there's an error.
13941365
It is the application's responsibility to close it and make sure there's no
13951366
file descriptor leak.
13961367

1397-
Like [`ReadStream`][], if `fd` is specified, `WriteStream` will ignore the
1368+
Like [`ReadStream`][], if `fd` is specified, [`WriteStream`][] will ignore the
13981369
`path` argument and will use the specified file descriptor. This means that no
13991370
`'open'` event will be emitted. Note that `fd` should be blocking; non-blocking
14001371
`fd`s should be passed to [`net.Socket`][].
@@ -1643,7 +1614,7 @@ added: v0.1.95
16431614
* `fd` {integer}
16441615
* Returns: {fs.Stats}
16451616

1646-
Synchronous fstat(2). Returns an instance of [`fs.Stats`][].
1617+
Synchronous fstat(2).
16471618

16481619
## fs.fsync(fd, callback)
16491620
<!-- YAML
@@ -1918,7 +1889,7 @@ changes:
19181889
* `path` {string|Buffer|URL}
19191890
* Returns: {fs.Stats}
19201891

1921-
Synchronous lstat(2). Returns an instance of [`fs.Stats`][].
1892+
Synchronous lstat(2).
19221893

19231894
## fs.mkdir(path[, mode], callback)
19241895
<!-- YAML
@@ -2267,10 +2238,9 @@ changes:
22672238
* `path` {string|Buffer|URL}
22682239
* `options` {string|Object}
22692240
* `encoding` {string} **Default:** `'utf8'`
2270-
* Returns: {string[]} An array of filenames
2241+
* Returns: {string[]} An array of filenames excluding `'.'` and `'..'`.
22712242

2272-
Synchronous readdir(3). Returns an array of filenames excluding `'.'` and
2273-
`'..'`.
2243+
Synchronous readdir(3).
22742244

22752245
The optional `options` argument can be a string specifying an encoding, or an
22762246
object with an `encoding` property specifying the character encoding to use for
@@ -2747,7 +2717,7 @@ changes:
27472717
* `path` {string|Buffer|URL}
27482718
* Returns: {fs.Stats}
27492719

2750-
Synchronous stat(2). Returns an instance of [`fs.Stats`][].
2720+
Synchronous stat(2).
27512721

27522722
## fs.symlink(target, path[, type], callback)
27532723
<!-- YAML
@@ -2988,9 +2958,10 @@ changes:
29882958
* `listener` {Function|undefined} **Default:** `undefined`
29892959
* `eventType` {string}
29902960
* `filename` {string|Buffer}
2961+
* Returns: {fs.FSWatcher}
29912962

29922963
Watch for changes on `filename`, where `filename` is either a file or a
2993-
directory. The returned object is a [`fs.FSWatcher`][].
2964+
directory.
29942965

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

tools/doc/type-parser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ const customTypesMap = {
5858

5959
'EventEmitter': 'events.html#events_class_eventemitter',
6060

61+
'FileHandle': 'fs.html#fs_class_filehandle',
62+
'fs.FSWatcher': 'fs.html#fs_class_fs_fswatcher',
63+
'fs.ReadStream': 'fs.html#fs_class_fs_readstream',
6164
'fs.Stats': 'fs.html#fs_class_fs_stats',
65+
'fs.WriteStream': 'fs.html#fs_class_fs_writestream',
6266

6367
'http.Agent': 'http.html#http_class_http_agent',
6468
'http.ClientRequest': 'http.html#http_class_http_clientrequest',

0 commit comments

Comments
 (0)