Skip to content

Commit 33c58df

Browse files
committed
doc: distinguish between fs.Stats and fs.BigIntStats
1 parent f65fc95 commit 33c58df

File tree

1 file changed

+66
-60
lines changed

1 file changed

+66
-60
lines changed

doc/api/fs.md

Lines changed: 66 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,9 @@ changes:
637637
-->
638638
639639
* `options` {Object}
640-
* `bigint` {boolean} Whether the numeric values in the returned
641-
{fs.Stats} object should be `bigint`. **Default:** `false`.
642-
* Returns: {Promise} Fulfills with an {fs.Stats} for the file.
640+
* `bigint` {boolean} Whether the returned object should be
641+
a {fs.BigIntStats} instance. **Default:** `false`.
642+
* Returns: {Promise} Fulfills with an {fs.Stats} or {fs.BigIntStats} for the file.
643643
644644
#### `filehandle.sync()`
645645
@@ -1213,9 +1213,9 @@ changes:
12131213
12141214
* `path` {string|Buffer|URL}
12151215
* `options` {Object}
1216-
* `bigint` {boolean} Whether the numeric values in the returned
1217-
{fs.Stats} object should be `bigint`. **Default:** `false`.
1218-
* Returns: {Promise} Fulfills with the {fs.Stats} object for the given
1216+
* `bigint` {boolean} Whether the returned object should be
1217+
a {fs.BigIntStats} instance. **Default:** `false`.
1218+
* Returns: {Promise} Fulfills with the {fs.Stats} or {fs.BigIntStats} object for the given
12191219
symbolic link `path`.
12201220
12211221
Equivalent to [`fsPromises.stat()`][] unless `path` refers to a symbolic link,
@@ -1291,7 +1291,7 @@ changes:
12911291
* `prefix` {string|Buffer|URL}
12921292
* `options` {string|Object}
12931293
* `encoding` {string} **Default:** `'utf8'`
1294-
* Returns: {Promise} Fulfills with a string containing the file system path
1294+
* Returns: {Promise} Fulfills with a string containing the file system path
12951295
of the newly created temporary directory.
12961296
12971297
Creates a unique temporary directory. A unique directory name is generated by
@@ -1715,9 +1715,9 @@ changes:
17151715
17161716
* `path` {string|Buffer|URL}
17171717
* `options` {Object}
1718-
* `bigint` {boolean} Whether the numeric values in the returned
1719-
{fs.Stats} object should be `bigint`. **Default:** `false`.
1720-
* Returns: {Promise} Fulfills with the {fs.Stats} object for the
1718+
* `bigint` {boolean} Whether the returned object should be
1719+
a {fs.BigIntStats} instance. **Default:** `false`.
1720+
* Returns: {Promise} Fulfills with the {fs.Stats} or {fs.BigIntStats} object for the
17211721
given `path`.
17221722
17231723
### `fsPromises.statfs(path[, options])`
@@ -3044,13 +3044,13 @@ changes:
30443044
30453045
* `fd` {integer}
30463046
* `options` {Object}
3047-
* `bigint` {boolean} Whether the numeric values in the returned
3048-
{fs.Stats} object should be `bigint`. **Default:** `false`.
3047+
* `bigint` {boolean} Whether the returned object should be
3048+
a {fs.BigIntStats} instance. **Default:** `false`.
30493049
* `callback` {Function}
30503050
* `err` {Error}
3051-
* `stats` {fs.Stats}
3051+
* `stats` {fs.Stats|fs.BigIntStats}
30523052
3053-
Invokes the callback with the {fs.Stats} for the file descriptor.
3053+
Invokes the callback with the {fs.Stats} or {fs.BigIntStats} for the file descriptor.
30543054
30553055
See the POSIX fstat(2) documentation for more detail.
30563056
@@ -3404,13 +3404,13 @@ changes:
34043404
34053405
* `path` {string|Buffer|URL}
34063406
* `options` {Object}
3407-
* `bigint` {boolean} Whether the numeric values in the returned
3408-
{fs.Stats} object should be `bigint`. **Default:** `false`.
3407+
* `bigint` {boolean} Whether the returned object should be
3408+
a {fs.BigIntStats} instance. **Default:** `false`.
34093409
* `callback` {Function}
34103410
* `err` {Error}
3411-
* `stats` {fs.Stats}
3411+
* `stats` {fs.Stats|fs.BigIntStats}
34123412
3413-
Retrieves the {fs.Stats} for the symbolic link referred to by the path.
3413+
Retrieves the {fs.Stats} or {fs.BigIntStats} for the symbolic link referred to by the path.
34143414
The callback gets two arguments `(err, stats)` where `stats` is a {fs.Stats}
34153415
object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
34163416
link, then the link itself is stat-ed, not the file that it refers to.
@@ -4427,14 +4427,14 @@ changes:
44274427
44284428
* `path` {string|Buffer|URL}
44294429
* `options` {Object}
4430-
* `bigint` {boolean} Whether the numeric values in the returned
4431-
{fs.Stats} object should be `bigint`. **Default:** `false`.
4430+
* `bigint` {boolean} Whether the returned object should be
4431+
a {fs.BigIntStats} instance. **Default:** `false`.
44324432
* `callback` {Function}
44334433
* `err` {Error}
4434-
* `stats` {fs.Stats}
4434+
* `stats` {fs.Stats|fs.BigIntStats}
44354435
44364436
Asynchronous stat(2). The callback gets two arguments `(err, stats)` where
4437-
`stats` is an {fs.Stats} object.
4437+
`stats` is an {fs.Stats} or {fs.BigIntStats} object.
44384438
44394439
In case of an error, the `err.code` will be one of [Common System Errors][].
44404440
@@ -4922,8 +4922,8 @@ changes:
49224922
* `persistent` {boolean} **Default:** `true`
49234923
* `interval` {integer} **Default:** `5007`
49244924
* `listener` {Function}
4925-
* `current` {fs.Stats}
4926-
* `previous` {fs.Stats}
4925+
* `current` {fs.Stats|fs.BigIntStats}
4926+
* `previous` {fs.Stats|fs.BigIntStats}
49274927
* Returns: {fs.StatWatcher}
49284928
49294929
Watch for changes on `filename`. The callback `listener` will be called each
@@ -4947,8 +4947,8 @@ watchFile('message.text', (curr, prev) => {
49474947
});
49484948
```
49494949
4950-
These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,
4951-
the numeric values in these objects are specified as `BigInt`s.
4950+
These stat objects are instances of `fs.Stats` if `bigint` option is `false`,
4951+
or instances of `fs.BigIntStats` if it's `true`.
49524952
49534953
To be notified when the file was modified, not just accessed, it is necessary
49544954
to compare `curr.mtimeMs` and `prev.mtimeMs`.
@@ -5687,11 +5687,11 @@ changes:
56875687
56885688
* `fd` {integer}
56895689
* `options` {Object}
5690-
* `bigint` {boolean} Whether the numeric values in the returned
5691-
{fs.Stats} object should be `bigint`. **Default:** `false`.
5692-
* Returns: {fs.Stats}
5690+
* `bigint` {boolean} Whether the returned object should be
5691+
a {fs.BigIntStats} instance. **Default:** `false`.
5692+
* Returns: {fs.Stats|fs.BigIntStats}
56935693
5694-
Retrieves the {fs.Stats} for the file descriptor.
5694+
Retrieves the {fs.Stats} or {fs.BigIntStats} for the file descriptor.
56955695
56965696
See the POSIX fstat(2) documentation for more detail.
56975697
@@ -5878,14 +5878,14 @@ changes:
58785878
58795879
* `path` {string|Buffer|URL}
58805880
* `options` {Object}
5881-
* `bigint` {boolean} Whether the numeric values in the returned
5882-
{fs.Stats} object should be `bigint`. **Default:** `false`.
5881+
* `bigint` {boolean} Whether the returned object should be
5882+
a {fs.BigIntStats} instance. **Default:** `false`.
58835883
* `throwIfNoEntry` {boolean} Whether an exception will be thrown
58845884
if no file system entry exists, rather than returning `undefined`.
58855885
**Default:** `true`.
5886-
* Returns: {fs.Stats}
5886+
* Returns: {fs.Stats|fs.BigIntStats}
58875887
5888-
Retrieves the {fs.Stats} for the symbolic link referred to by `path`.
5888+
Retrieves the {fs.Stats} or {fs.BigIntStats} for the symbolic link referred to by `path`.
58895889
58905890
See the POSIX lstat(2) documentation for more details.
58915891
@@ -6409,14 +6409,14 @@ changes:
64096409
64106410
* `path` {string|Buffer|URL}
64116411
* `options` {Object}
6412-
* `bigint` {boolean} Whether the numeric values in the returned
6413-
{fs.Stats} object should be `bigint`. **Default:** `false`.
6412+
* `bigint` {boolean} Whether the returned object should be
6413+
a {fs.BigIntStats} instance. **Default:** `false`.
64146414
* `throwIfNoEntry` {boolean} Whether an exception will be thrown
64156415
if no file system entry exists, rather than returning `undefined`.
64166416
**Default:** `true`.
6417-
* Returns: {fs.Stats}
6417+
* Returns: {fs.Stats|fs.BigIntStats}
64186418
6419-
Retrieves the {fs.Stats} for the path.
6419+
Retrieves the {fs.Stats} or {fs.BigIntStats} for the path.
64206420
64216421
### `fs.statfsSync(path[, options])`
64226422
@@ -7217,10 +7217,11 @@ A {fs.Stats} object provides information about a file.
72177217
72187218
Objects returned from [`fs.stat()`][], [`fs.lstat()`][], [`fs.fstat()`][], and
72197219
their synchronous counterparts are of this type.
7220-
If `bigint` in the `options` passed to those methods is true, the numeric values
7221-
will be `bigint` instead of `number`, and the object will contain additional
7222-
nanosecond-precision properties suffixed with `Ns`.
7223-
`Stat` objects are not to be created directly using the `new` keyword.
7220+
If `bigint` in the `options` passed to those methods is true, the returned objects
7221+
will be instances of {fs.BigIntStats} which numeric values will be `bigint` instead
7222+
of `number`, and the object will contain additional nanosecond-precision properties
7223+
suffixed with `Ns`.
7224+
`Stats` objects are not to be created directly using the `new` keyword.
72247225
72257226
```console
72267227
Stats {
@@ -7244,7 +7245,17 @@ Stats {
72447245
birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
72457246
```
72467247
7247-
`bigint` version:
7248+
### Class: `fs.BigIntStats`
7249+
7250+
<!-- YAML
7251+
added: v12.10.0
7252+
-->
7253+
7254+
{fs.BigIntStats} objects are returned instead of {fs.Stats} when the `bigint` option
7255+
passed to the corresponding function is true.
7256+
Their numeric values are `bigint` instead of `number`, and they contain additional
7257+
nanosecond-precision properties suffixed with `Ns`.
7258+
`BigIntStats` objects are not to be created directly using the `new` keyword.
72487259
72497260
```console
72507261
BigIntStats {
@@ -7280,7 +7291,7 @@ added: v0.1.10
72807291
72817292
* Returns: {boolean}
72827293
7283-
Returns `true` if the {fs.Stats} object describes a block device.
7294+
Returns `true` if the stats object describes a block device.
72847295
72857296
#### `stats.isCharacterDevice()`
72867297
@@ -7290,7 +7301,7 @@ added: v0.1.10
72907301
72917302
* Returns: {boolean}
72927303
7293-
Returns `true` if the {fs.Stats} object describes a character device.
7304+
Returns `true` if the stats object describes a character device.
72947305
72957306
#### `stats.isDirectory()`
72967307
@@ -7300,7 +7311,7 @@ added: v0.1.10
73007311
73017312
* Returns: {boolean}
73027313
7303-
Returns `true` if the {fs.Stats} object describes a file system directory.
7314+
Returns `true` if the stats object describes a file system directory.
73047315
73057316
If the {fs.Stats} object was obtained from calling [`fs.lstat()`][] on a
73067317
symbolic link which resolves to a directory, this method will return `false`.
@@ -7315,7 +7326,7 @@ added: v0.1.10
73157326
73167327
* Returns: {boolean}
73177328
7318-
Returns `true` if the {fs.Stats} object describes a first-in-first-out (FIFO)
7329+
Returns `true` if the stats object describes a first-in-first-out (FIFO)
73197330
pipe.
73207331
73217332
#### `stats.isFile()`
@@ -7326,7 +7337,7 @@ added: v0.1.10
73267337
73277338
* Returns: {boolean}
73287339
7329-
Returns `true` if the {fs.Stats} object describes a regular file.
7340+
Returns `true` if the stats object describes a regular file.
73307341
73317342
#### `stats.isSocket()`
73327343
@@ -7336,7 +7347,7 @@ added: v0.1.10
73367347
73377348
* Returns: {boolean}
73387349
7339-
Returns `true` if the {fs.Stats} object describes a socket.
7350+
Returns `true` if the stats object describes a socket.
73407351
73417352
#### `stats.isSymbolicLink()`
73427353
@@ -7346,7 +7357,7 @@ added: v0.1.10
73467357
73477358
* Returns: {boolean}
73487359
7349-
Returns `true` if the {fs.Stats} object describes a symbolic link.
7360+
Returns `true` if the stats object describes a symbolic link.
73507361
73517362
This method is only valid when using [`fs.lstat()`][].
73527363
@@ -7465,8 +7476,7 @@ added: v12.10.0
74657476
74667477
* Type: {bigint}
74677478
7468-
Only present when `bigint: true` is passed into the method that generates
7469-
the object.
7479+
Only present when on `BigIntStats` objects.
74707480
The timestamp indicating the last time this file was accessed expressed in
74717481
nanoseconds since the POSIX Epoch.
74727482
@@ -7478,8 +7488,7 @@ added: v12.10.0
74787488
74797489
* Type: {bigint}
74807490
7481-
Only present when `bigint: true` is passed into the method that generates
7482-
the object.
7491+
Only present on `BigIntStats` objects.
74837492
The timestamp indicating the last time this file was modified expressed in
74847493
nanoseconds since the POSIX Epoch.
74857494
@@ -7491,8 +7500,7 @@ added: v12.10.0
74917500
74927501
* Type: {bigint}
74937502
7494-
Only present when `bigint: true` is passed into the method that generates
7495-
the object.
7503+
Only present on `BigIntStats` objects.
74967504
The timestamp indicating the last time the file status was changed expressed
74977505
in nanoseconds since the POSIX Epoch.
74987506
@@ -7504,8 +7512,7 @@ added: v12.10.0
75047512
75057513
* Type: {bigint}
75067514
7507-
Only present when `bigint: true` is passed into the method that generates
7508-
the object.
7515+
Only present on `BigIntStats` objects.
75097516
The timestamp indicating the creation time of this file expressed in
75107517
nanoseconds since the POSIX Epoch.
75117518
@@ -7559,8 +7566,7 @@ otherwise they will be [numbers][MDN-Number].
75597566
75607567
The `atimeNs`, `mtimeNs`, `ctimeNs`, `birthtimeNs` properties are
75617568
[bigints][] that hold the corresponding times in nanoseconds. They are
7562-
only present when `bigint: true` is passed into the method that generates
7563-
the object. Their precision is platform specific.
7569+
only present on `BigIntStats` objects. Their precision is platform specific.
75647570
75657571
`atime`, `mtime`, `ctime`, and `birthtime` are
75667572
[`Date`][MDN-Date] object alternate representations of the various times. The

0 commit comments

Comments
 (0)