Skip to content

Commit 10f296f

Browse files
LiviaMedeirosjuanarbol
authored andcommitted
doc: clarify some default values in fs.md
PR-URL: #42892 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
1 parent 0fd9371 commit 10f296f

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

doc/api/fs.md

+33-33
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ added: v10.0.0
374374
file data read.
375375
* `offset` {integer} The location in the buffer at which to start filling.
376376
* `length` {integer} The number of bytes to read.
377-
* `position` {integer} The location where to begin reading data from the
377+
* `position` {integer|null} The location where to begin reading data from the
378378
file. If `null`, data will be read from the current file position, and
379379
the position will be updated. If `position` is an integer, the current
380380
file position will remain unchanged.
@@ -403,7 +403,7 @@ added:
403403
**Default:** `0`
404404
* `length` {integer} The number of bytes to read. **Default:**
405405
`buffer.byteLength - offset`
406-
* `position` {integer} The location where to begin reading data from the
406+
* `position` {integer|null} The location where to begin reading data from the
407407
file. If `null`, data will be read from the current file position, and
408408
the position will be updated. If `position` is an integer, the current
409409
file position will remain unchanged. **Default:**: `null`
@@ -450,9 +450,9 @@ added:
450450
-->
451451
452452
* `buffers` {Buffer\[]|TypedArray\[]|DataView\[]}
453-
* `position` {integer} The offset from the beginning of the file where the data
454-
should be read from. If `position` is not a `number`, the data will be read
455-
from the current position.
453+
* `position` {integer|null} The offset from the beginning of the file where
454+
the data should be read from. If `position` is not a `number`, the data will
455+
be read from the current position. **Default:** `null`
456456
* Returns: {Promise} Fulfills upon success an object containing two properties:
457457
* `bytesRead` {integer} the number of bytes read
458458
* `buffers` {Buffer\[]|TypedArray\[]|DataView\[]} property containing
@@ -550,10 +550,10 @@ changes:
550550
to write begins. **Default:** `0`
551551
* `length` {integer} The number of bytes from `buffer` to write. **Default:**
552552
`buffer.byteLength - offset`
553-
* `position` {integer} The offset from the beginning of the file where the
553+
* `position` {integer|null} The offset from the beginning of the file where the
554554
data from `buffer` should be written. If `position` is not a `number`,
555555
the data will be written at the current position. See the POSIX pwrite(2)
556-
documentation for more detail.
556+
documentation for more detail. **Default:** `null`
557557
* Returns: {Promise}
558558
559559
Write `buffer` to the file.
@@ -584,10 +584,10 @@ changes:
584584
-->
585585
586586
* `string` {string}
587-
* `position` {integer} The offset from the beginning of the file where the
587+
* `position` {integer|null} The offset from the beginning of the file where the
588588
data from `string` should be written. If `position` is not a `number` the
589589
data will be written at the current position. See the POSIX pwrite(2)
590-
documentation for more detail.
590+
documentation for more detail. **Default:** `null`
591591
* `encoding` {string} The expected string encoding. **Default:** `'utf8'`
592592
* Returns: {Promise}
593593
@@ -650,9 +650,9 @@ added: v12.9.0
650650
-->
651651
652652
* `buffers` {Buffer\[]|TypedArray\[]|DataView\[]}
653-
* `position` {integer} The offset from the beginning of the file where the
653+
* `position` {integer|null} The offset from the beginning of the file where the
654654
data from `buffers` should be written. If `position` is not a `number`,
655-
the data will be written at the current position.
655+
the data will be written at the current position. **Default:** `null`
656656
* Returns: {Promise}
657657
658658
Write an array of {ArrayBufferView}s to the file.
@@ -3009,7 +3009,7 @@ changes:
30093009
written to.
30103010
* `offset` {integer} The position in `buffer` to write the data to.
30113011
* `length` {integer} The number of bytes to read.
3012-
* `position` {integer|bigint} Specifies where to begin reading from in the
3012+
* `position` {integer|bigint|null} Specifies where to begin reading from in the
30133013
file. If `position` is `null` or `-1 `, data will be read from the current
30143014
file position, and the file position will be updated. If `position` is an
30153015
integer, the file position will be unchanged.
@@ -3048,7 +3048,7 @@ changes:
30483048
* `buffer` {Buffer|TypedArray|DataView} **Default:** `Buffer.alloc(16384)`
30493049
* `offset` {integer} **Default:** `0`
30503050
* `length` {integer} **Default:** `buffer.byteLength - offset`
3051-
* `position` {integer|bigint} **Default:** `null`
3051+
* `position` {integer|bigint|null} **Default:** `null`
30523052
* `callback` {Function}
30533053
* `err` {Error}
30543054
* `bytesRead` {integer}
@@ -3290,7 +3290,7 @@ added:
32903290

32913291
* `fd` {integer}
32923292
* `buffers` {ArrayBufferView\[]}
3293-
* `position` {integer}
3293+
* `position` {integer|null} **Default:** `null`
32943294
* `callback` {Function}
32953295
* `err` {Error}
32963296
* `bytesRead` {integer}
@@ -3679,7 +3679,7 @@ changes:
36793679

36803680
* `target` {string|Buffer|URL}
36813681
* `path` {string|Buffer|URL}
3682-
* `type` {string}
3682+
* `type` {string|null} **Default:** `null`
36833683
* `callback` {Function}
36843684
* `err` {Error}
36853685

@@ -3690,8 +3690,8 @@ See the POSIX symlink(2) documentation for more details.
36903690

36913691
The `type` argument is only available on Windows and ignored on other platforms.
36923692
It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
3693-
not set, Node.js will autodetect `target` type and use `'file'` or `'dir'`. If
3694-
the `target` does not exist, `'file'` will be used. Windows junction points
3693+
not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`.
3694+
If the `target` does not exist, `'file'` will be used. Windows junction points
36953695
require the destination path to be absolute. When using `'junction'`, the
36963696
`target` argument will automatically be normalized to absolute path.
36973697

@@ -4096,9 +4096,9 @@ changes:
40964096
40974097
* `fd` {integer}
40984098
* `buffer` {Buffer|TypedArray|DataView}
4099-
* `offset` {integer}
4100-
* `length` {integer}
4101-
* `position` {integer}
4099+
* `offset` {integer} **Default:** `0`
4100+
* `length` {integer} **Default:** `buffer.byteLength - offset`
4101+
* `position` {integer|null} **Default:** `null`
41024102
* `callback` {Function}
41034103
* `err` {Error}
41044104
* `bytesWritten` {integer}
@@ -4159,7 +4159,7 @@ changes:
41594159
41604160
* `fd` {integer}
41614161
* `string` {string|Object}
4162-
* `position` {integer}
4162+
* `position` {integer|null} **Default:** `null`
41634163
* `encoding` {string} **Default:** `'utf8'`
41644164
* `callback` {Function}
41654165
* `err` {Error}
@@ -4348,7 +4348,7 @@ added: v12.9.0
43484348
43494349
* `fd` {integer}
43504350
* `buffers` {ArrayBufferView\[]}
4351-
* `position` {integer}
4351+
* `position` {integer|null} **Default:** `null`
43524352
* `callback` {Function}
43534353
* `err` {Error}
43544354
* `bytesWritten` {integer}
@@ -5061,7 +5061,7 @@ object with an `encoding` property specifying the character encoding to use for
50615061
the link path returned. If the `encoding` is set to `'buffer'`,
50625062
the link path returned will be passed as a {Buffer} object.
50635063
5064-
### `fs.readSync(fd, buffer, offset, length, position)`
5064+
### `fs.readSync(fd, buffer, offset, length[, position])`
50655065
50665066
<!-- YAML
50675067
added: v0.1.21
@@ -5079,7 +5079,7 @@ changes:
50795079
* `buffer` {Buffer|TypedArray|DataView}
50805080
* `offset` {integer}
50815081
* `length` {integer}
5082-
* `position` {integer|bigint}
5082+
* `position` {integer|bigint|null} **Default:** `null`
50835083
* Returns: {number}
50845084
50855085
Returns the number of `bytesRead`.
@@ -5107,7 +5107,7 @@ changes:
51075107
* `options` {Object}
51085108
* `offset` {integer} **Default:** `0`
51095109
* `length` {integer} **Default:** `buffer.byteLength - offset`
5110-
* `position` {integer|bigint} **Default:** `null`
5110+
* `position` {integer|bigint|null} **Default:** `null`
51115111
* Returns: {number}
51125112
51135113
Returns the number of `bytesRead`.
@@ -5128,7 +5128,7 @@ added:
51285128
51295129
* `fd` {integer}
51305130
* `buffers` {ArrayBufferView\[]}
5131-
* `position` {integer}
5131+
* `position` {integer|null} **Default:** `null`
51325132
* Returns: {number} The number of bytes read.
51335133
51345134
For detailed information, see the documentation of the asynchronous version of
@@ -5350,7 +5350,7 @@ changes:
53505350
53515351
* `target` {string|Buffer|URL}
53525352
* `path` {string|Buffer|URL}
5353-
* `type` {string}
5353+
* `type` {string|null} **Default:** `null`
53545354
53555355
Returns `undefined`.
53565356
@@ -5482,9 +5482,9 @@ changes:
54825482
54835483
* `fd` {integer}
54845484
* `buffer` {Buffer|TypedArray|DataView}
5485-
* `offset` {integer}
5486-
* `length` {integer}
5487-
* `position` {integer}
5485+
* `offset` {integer} **Default:** `0`
5486+
* `length` {integer} **Default:** `buffer.byteLength - offset`
5487+
* `position` {integer|null} **Default:** `null`
54885488
* Returns: {number} The number of bytes written.
54895489
54905490
For detailed information, see the documentation of the asynchronous version of
@@ -5506,8 +5506,8 @@ changes:
55065506
55075507
* `fd` {integer}
55085508
* `string` {string}
5509-
* `position` {integer}
5510-
* `encoding` {string}
5509+
* `position` {integer|null} **Default:** `null`
5510+
* `encoding` {string} **Default:** `'utf8'`
55115511
* Returns: {number} The number of bytes written.
55125512
55135513
For detailed information, see the documentation of the asynchronous version of
@@ -5521,7 +5521,7 @@ added: v12.9.0
55215521
55225522
* `fd` {integer}
55235523
* `buffers` {ArrayBufferView\[]}
5524-
* `position` {integer}
5524+
* `position` {integer|null} **Default:** `null`
55255525
* Returns: {number} The number of bytes written.
55265526
55275527
For detailed information, see the documentation of the asynchronous version of

lib/fs.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ function openSync(path, flags, mode) {
593593
* @param {Buffer | TypedArray | DataView} buffer
594594
* @param {number} offset
595595
* @param {number} length
596-
* @param {number | bigint} position
596+
* @param {number | bigint | null} position
597597
* @param {(
598598
* err?: Error,
599599
* bytesRead?: number,
@@ -678,7 +678,7 @@ ObjectDefineProperty(read, internalUtil.customPromisifyArgs,
678678
* @param {{
679679
* offset?: number;
680680
* length?: number;
681-
* position?: number | bigint;
681+
* position?: number | bigint | null;
682682
* }} [offset]
683683
* @returns {number}
684684
*/
@@ -734,7 +734,7 @@ function readSync(fd, buffer, offset, length, position) {
734734
* and writes to an array of `ArrayBufferView`s.
735735
* @param {number} fd
736736
* @param {ArrayBufferView[]} buffers
737-
* @param {number} [position]
737+
* @param {number | null} [position]
738738
* @param {(
739739
* err?: Error,
740740
* bytesRead?: number,
@@ -769,7 +769,7 @@ ObjectDefineProperty(readv, internalUtil.customPromisifyArgs,
769769
* of `ArrayBufferView`s.
770770
* @param {number} fd
771771
* @param {ArrayBufferView[]} buffers
772-
* @param {number} [position]
772+
* @param {number | null} [position]
773773
* @returns {number}
774774
*/
775775
function readvSync(fd, buffers, position) {
@@ -792,7 +792,7 @@ function readvSync(fd, buffers, position) {
792792
* @param {Buffer | TypedArray | DataView | string | object} buffer
793793
* @param {number} [offset]
794794
* @param {number} [length]
795-
* @param {number} [position]
795+
* @param {number | null} [position]
796796
* @param {(
797797
* err?: Error,
798798
* bytesWritten?: number;
@@ -857,7 +857,7 @@ ObjectDefineProperty(write, internalUtil.customPromisifyArgs,
857857
* @param {Buffer | TypedArray | DataView | string} buffer
858858
* @param {number} [offset]
859859
* @param {number} [length]
860-
* @param {number} [position]
860+
* @param {number | null} [position]
861861
* @returns {number}
862862
*/
863863
function writeSync(fd, buffer, offset, length, position) {
@@ -895,7 +895,7 @@ function writeSync(fd, buffer, offset, length, position) {
895895
* specified `fd` (file descriptor).
896896
* @param {number} fd
897897
* @param {ArrayBufferView[]} buffers
898-
* @param {number} [position]
898+
* @param {number | null} [position]
899899
* @param {(
900900
* err?: Error,
901901
* bytesWritten?: number,
@@ -936,7 +936,7 @@ ObjectDefineProperty(writev, internalUtil.customPromisifyArgs, {
936936
* to the specified `fd` (file descriptor).
937937
* @param {number} fd
938938
* @param {ArrayBufferView[]} buffers
939-
* @param {number} [position]
939+
* @param {number | null} [position]
940940
* @returns {number}
941941
*/
942942
function writevSync(fd, buffers, position) {
@@ -1594,7 +1594,7 @@ function readlinkSync(path, options) {
15941594
* Creates the link called `path` pointing to `target`.
15951595
* @param {string | Buffer | URL} target
15961596
* @param {string | Buffer | URL} path
1597-
* @param {string} [type_]
1597+
* @param {string | null} [type_]
15981598
* @param {(err?: Error) => any} callback_
15991599
* @returns {void}
16001600
*/
@@ -1647,7 +1647,7 @@ function symlink(target, path, type_, callback_) {
16471647
* pointing to `target`.
16481648
* @param {string | Buffer | URL} target
16491649
* @param {string | Buffer | URL} path
1650-
* @param {string} [type]
1650+
* @param {string | null} [type]
16511651
* @returns {void}
16521652
*/
16531653
function symlinkSync(target, path, type) {

0 commit comments

Comments
 (0)