Skip to content

Commit 17fda05

Browse files
committed
doc: document BigInt support in fs.Stats
1 parent 4ee0c9c commit 17fda05

File tree

2 files changed

+121
-26
lines changed

2 files changed

+121
-26
lines changed

doc/api/fs.md

Lines changed: 119 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ A `fs.Stats` object provides information about a file.
415415

416416
Objects returned from [`fs.stat()`][], [`fs.lstat()`][] and [`fs.fstat()`][] and
417417
their synchronous counterparts are of this type.
418+
If `bigint` in the `options` passed to those methods is true, the numeric values
419+
will be `bigint` instead of `number`.
418420

419421
```console
420422
Stats {
@@ -438,6 +440,30 @@ Stats {
438440
birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
439441
```
440442

443+
`bigint` version:
444+
445+
```console
446+
Stats {
447+
dev: 2114n,
448+
ino: 48064969n,
449+
mode: 33188n,
450+
nlink: 1n,
451+
uid: 85n,
452+
gid: 100n,
453+
rdev: 0n,
454+
size: 527n,
455+
blksize: 4096n,
456+
blocks: 8n,
457+
atimeMs: 1318289051000n,
458+
mtimeMs: 1318289051000n,
459+
ctimeMs: 1318289051000n,
460+
birthtimeMs: 1318289051000n,
461+
atime: Mon, 10 Oct 2011 23:24:11 GMT,
462+
mtime: Mon, 10 Oct 2011 23:24:11 GMT,
463+
ctime: Mon, 10 Oct 2011 23:24:11 GMT,
464+
birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
465+
```
466+
441467
### stats.isBlockDevice()
442468
<!-- YAML
443469
added: v0.1.10
@@ -506,61 +532,61 @@ This method is only valid when using [`fs.lstat()`][].
506532

507533
### stats.dev
508534

509-
* {number}
535+
* {number|bigint}
510536

511537
The numeric identifier of the device containing the file.
512538

513539
### stats.ino
514540

515-
* {number}
541+
* {number|bigint}
516542

517543
The file system specific "Inode" number for the file.
518544

519545
### stats.mode
520546

521-
* {number}
547+
* {number|bigint}
522548

523549
A bit-field describing the file type and mode.
524550

525551
### stats.nlink
526552

527-
* {number}
553+
* {number|bigint}
528554

529555
The number of hard-links that exist for the file.
530556

531557
### stats.uid
532558

533-
* {number}
559+
* {number|bigint}
534560

535561
The numeric user identifier of the user that owns the file (POSIX).
536562

537563
### stats.gid
538564

539-
* {number}
565+
* {number|bigint}
540566

541567
The numeric group identifier of the group that owns the file (POSIX).
542568

543569
### stats.rdev
544570

545-
* {number}
571+
* {number|bigint}
546572

547573
A numeric device identifier if the file is considered "special".
548574

549575
### stats.size
550576

551-
* {number}
577+
* {number|bigint}
552578

553579
The size of the file in bytes.
554580

555581
### stats.blksize
556582

557-
* {number}
583+
* {number|bigint}
558584

559585
The file system block size for i/o operations.
560586

561587
### stats.blocks
562588

563-
* {number}
589+
* {number|bigint}
564590

565591
The number of blocks allocated for this file.
566592

@@ -569,7 +595,7 @@ The number of blocks allocated for this file.
569595
added: v8.1.0
570596
-->
571597

572-
* {number}
598+
* {number|bigint}
573599

574600
The timestamp indicating the last time this file was accessed expressed in
575601
milliseconds since the POSIX Epoch.
@@ -579,7 +605,7 @@ milliseconds since the POSIX Epoch.
579605
added: v8.1.0
580606
-->
581607

582-
* {number}
608+
* {number|bigint}
583609

584610
The timestamp indicating the last time this file was modified expressed in
585611
milliseconds since the POSIX Epoch.
@@ -589,7 +615,7 @@ milliseconds since the POSIX Epoch.
589615
added: v8.1.0
590616
-->
591617

592-
* {number}
618+
* {number|bigint}
593619

594620
The timestamp indicating the last time the file status was changed expressed
595621
in milliseconds since the POSIX Epoch.
@@ -599,7 +625,7 @@ in milliseconds since the POSIX Epoch.
599625
added: v8.1.0
600626
-->
601627

602-
* {number}
628+
* {number|bigint}
603629

604630
The timestamp indicating the creation time of this file expressed in
605631
milliseconds since the POSIX Epoch.
@@ -1648,7 +1674,7 @@ added: v0.1.96
16481674

16491675
Synchronous fdatasync(2). Returns `undefined`.
16501676

1651-
## fs.fstat(fd, callback)
1677+
## fs.fstat(fd[, options], callback)
16521678
<!-- YAML
16531679
added: v0.1.95
16541680
changes:
@@ -1660,9 +1686,16 @@ changes:
16601686
pr-url: https://github.com/nodejs/node/pull/7897
16611687
description: The `callback` parameter is no longer optional. Not passing
16621688
it will emit a deprecation warning with id DEP0013.
1689+
- version: REPLACEME
1690+
pr-url: REPLACEME
1691+
description: Accepts an additional `options` object to specify whether
1692+
the numeric values returned should be bigint.
16631693
-->
16641694

16651695
* `fd` {integer}
1696+
* `options` {Object}
1697+
* `bigint` {boolean} Whether the numeric values in the returned
1698+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
16661699
* `callback` {Function}
16671700
* `err` {Error}
16681701
* `stats` {fs.Stats}
@@ -1671,12 +1704,20 @@ Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where
16711704
`stats` is an [`fs.Stats`][] object. `fstat()` is identical to [`stat()`][],
16721705
except that the file to be stat-ed is specified by the file descriptor `fd`.
16731706

1674-
## fs.fstatSync(fd)
1707+
## fs.fstatSync(fd[, options])
16751708
<!-- YAML
16761709
added: v0.1.95
1710+
changes:
1711+
- version: REPLACEME
1712+
pr-url: REPLACEME
1713+
description: Accepts an additional `options` object to specify whether
1714+
the numeric values returned should be bigint.
16771715
-->
16781716

16791717
* `fd` {integer}
1718+
* `options` {Object}
1719+
* `bigint` {boolean} Whether the numeric values in the returned
1720+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
16801721
* Returns: {fs.Stats}
16811722

16821723
Synchronous fstat(2).
@@ -1942,7 +1983,7 @@ changes:
19421983

19431984
Synchronous link(2). Returns `undefined`.
19441985

1945-
## fs.lstat(path, callback)
1986+
## fs.lstat(path[, options], callback)
19461987
<!-- YAML
19471988
added: v0.1.30
19481989
changes:
@@ -1958,9 +1999,16 @@ changes:
19581999
pr-url: https://github.com/nodejs/node/pull/7897
19592000
description: The `callback` parameter is no longer optional. Not passing
19602001
it will emit a deprecation warning with id DEP0013.
2002+
- version: REPLACEME
2003+
pr-url: REPLACEME
2004+
description: Accepts an additional `options` object to specify whether
2005+
the numeric values returned should be bigint.
19612006
-->
19622007

19632008
* `path` {string|Buffer|URL}
2009+
* `options` {Object}
2010+
* `bigint` {boolean} Whether the numeric values in the returned
2011+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
19642012
* `callback` {Function}
19652013
* `err` {Error}
19662014
* `stats` {fs.Stats}
@@ -1970,17 +2018,24 @@ Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where
19702018
except that if `path` is a symbolic link, then the link itself is stat-ed,
19712019
not the file that it refers to.
19722020

1973-
## fs.lstatSync(path)
2021+
## fs.lstatSync(path[, options])
19742022
<!-- YAML
19752023
added: v0.1.30
19762024
changes:
19772025
- version: v7.6.0
19782026
pr-url: https://github.com/nodejs/node/pull/10739
19792027
description: The `path` parameter can be a WHATWG `URL` object using `file:`
19802028
protocol. Support is currently still *experimental*.
2029+
- version: REPLACEME
2030+
pr-url: REPLACEME
2031+
description: Accepts an additional `options` object to specify whether
2032+
the numeric values returned should be bigint.
19812033
-->
19822034

19832035
* `path` {string|Buffer|URL}
2036+
* `options` {Object}
2037+
* `bigint` {boolean} Whether the numeric values in the returned
2038+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
19842039
* Returns: {fs.Stats}
19852040

19862041
Synchronous lstat(2).
@@ -2698,7 +2753,7 @@ Synchronous rmdir(2). Returns `undefined`.
26982753
Using `fs.rmdirSync()` on a file (not a directory) results in an `ENOENT` error
26992754
on Windows and an `ENOTDIR` error on POSIX.
27002755

2701-
## fs.stat(path, callback)
2756+
## fs.stat(path[, options], callback)
27022757
<!-- YAML
27032758
added: v0.0.2
27042759
changes:
@@ -2714,9 +2769,16 @@ changes:
27142769
pr-url: https://github.com/nodejs/node/pull/7897
27152770
description: The `callback` parameter is no longer optional. Not passing
27162771
it will emit a deprecation warning with id DEP0013.
2772+
- version: REPLACEME
2773+
pr-url: REPLACEME
2774+
description: Accepts an additional `options` object to specify whether
2775+
the numeric values returned should be bigint.
27172776
-->
27182777

27192778
* `path` {string|Buffer|URL}
2779+
* `options` {Object}
2780+
* `bigint` {boolean} Whether the numeric values in the returned
2781+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
27202782
* `callback` {Function}
27212783
* `err` {Error}
27222784
* `stats` {fs.Stats}
@@ -2734,17 +2796,24 @@ error raised if the file is not available.
27342796
To check if a file exists without manipulating it afterwards, [`fs.access()`]
27352797
is recommended.
27362798

2737-
## fs.statSync(path)
2799+
## fs.statSync(path[, options])
27382800
<!-- YAML
27392801
added: v0.1.21
27402802
changes:
27412803
- version: v7.6.0
27422804
pr-url: https://github.com/nodejs/node/pull/10739
27432805
description: The `path` parameter can be a WHATWG `URL` object using `file:`
27442806
protocol. Support is currently still *experimental*.
2807+
- version: REPLACEME
2808+
pr-url: REPLACEME
2809+
description: Accepts an additional `options` object to specify whether
2810+
the numeric values returned should be bigint.
27452811
-->
27462812

27472813
* `path` {string|Buffer|URL}
2814+
* `options` {Object}
2815+
* `bigint` {boolean} Whether the numeric values in the returned
2816+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
27482817
* Returns: {fs.Stats}
27492818

27502819
Synchronous stat(2).
@@ -3521,10 +3590,18 @@ returned.
35213590

35223591
The `FileHandle` has to support reading.
35233592

3524-
#### filehandle.stat()
3593+
#### filehandle.stat([options])
35253594
<!-- YAML
35263595
added: v10.0.0
3596+
changes:
3597+
- version: REPLACEME
3598+
pr-url: REPLACEME
3599+
description: Accepts an additional `options` object to specify whether
3600+
the numeric values returned should be bigint.
35273601
-->
3602+
* `options` {Object}
3603+
* `bigint` {boolean} Whether the numeric values in the returned
3604+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
35283605
* Returns: {Promise}
35293606

35303607
Retrieves the [`fs.Stats`][] for the file.
@@ -3849,12 +3926,20 @@ added: v10.0.0
38493926

38503927
Asynchronous link(2). The `Promise` is resolved with no arguments upon success.
38513928

3852-
### fsPromises.lstat(path)
3929+
### fsPromises.lstat(path[, options])
38533930
<!-- YAML
38543931
added: v10.0.0
3932+
changes:
3933+
- version: REPLACEME
3934+
pr-url: REPLACEME
3935+
description: Accepts an additional `options` object to specify whether
3936+
the numeric values returned should be bigint.
38553937
-->
38563938

38573939
* `path` {string|Buffer|URL}
3940+
* `options` {Object}
3941+
* `bigint` {boolean} Whether the numeric values in the returned
3942+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
38583943
* Returns: {Promise}
38593944

38603945
Asynchronous lstat(2). The `Promise` is resolved with the [`fs.Stats`][] object
@@ -4035,12 +4120,20 @@ Using `fsPromises.rmdir()` on a file (not a directory) results in the
40354120
`Promise` being rejected with an `ENOENT` error on Windows and an `ENOTDIR`
40364121
error on POSIX.
40374122

4038-
### fsPromises.stat(path)
4123+
### fsPromises.stat(path[, options])
40394124
<!-- YAML
40404125
added: v10.0.0
4126+
changes:
4127+
- version: REPLACEME
4128+
pr-url: REPLACEME
4129+
description: Accepts an additional `options` object to specify whether
4130+
the numeric values returned should be bigint.
40414131
-->
40424132

40434133
* `path` {string|Buffer|URL}
4134+
* `options` {Object}
4135+
* `bigint` {boolean} Whether the numeric values in the returned
4136+
[`fs.Stats`][] object should be `bigint`. **Default:** `false`.
40444137
* Returns: {Promise}
40454138

40464139
The `Promise` is resolved with the [`fs.Stats`][] object for the given `path`.
@@ -4496,9 +4589,9 @@ the file contents.
44964589
[`fs.chown()`]: #fs_fs_chown_path_uid_gid_callback
44974590
[`fs.copyFile()`]: #fs_fs_copyfile_src_dest_flags_callback
44984591
[`fs.exists()`]: fs.html#fs_fs_exists_path_callback
4499-
[`fs.fstat()`]: #fs_fs_fstat_fd_callback
4592+
[`fs.fstat()`]: #fs_fs_fstat_fd_options_callback
45004593
[`fs.futimes()`]: #fs_fs_futimes_fd_atime_mtime_callback
4501-
[`fs.lstat()`]: #fs_fs_lstat_path_callback
4594+
[`fs.lstat()`]: #fs_fs_lstat_path_options_callback
45024595
[`fs.mkdir()`]: #fs_fs_mkdir_path_mode_callback
45034596
[`fs.mkdtemp()`]: #fs_fs_mkdtemp_prefix_options_callback
45044597
[`fs.open()`]: #fs_fs_open_path_flags_mode_callback
@@ -4507,7 +4600,7 @@ the file contents.
45074600
[`fs.readFileSync()`]: #fs_fs_readfilesync_path_options
45084601
[`fs.realpath()`]: #fs_fs_realpath_path_options_callback
45094602
[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
4510-
[`fs.stat()`]: #fs_fs_stat_path_callback
4603+
[`fs.stat()`]: #fs_fs_stat_path_options_callback
45114604
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
45124605
[`fs.watch()`]: #fs_fs_watch_filename_options_listener
45134606
[`fs.write()`]: #fs_fs_write_fd_buffer_offset_length_position_callback

tools/doc/type-parser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const customTypesMap = {
3131

3232
'AsyncIterator': 'https://github.com/tc39/proposal-async-iteration',
3333

34+
'bigint': 'https://github.com/tc39/proposal-bigint',
35+
3436
'Iterable':
3537
`${jsDocPrefix}Reference/Iteration_protocols#The_iterable_protocol`,
3638
'Iterator':

0 commit comments

Comments
 (0)