Skip to content

Conversation

pluris
Copy link
Contributor

@pluris pluris commented Apr 20, 2024

update jsdoc params for read, readSync.

node/doc/api/fs.md

Lines 3626 to 3724 in f7a9cdc

### `fs.read(fd, buffer, offset, length, position, callback)`
<!-- YAML
added: v0.0.2
changes:
- version: v18.0.0
pr-url: https://github.com/nodejs/node/pull/41678
description: Passing an invalid callback to the `callback` argument
now throws `ERR_INVALID_ARG_TYPE` instead of
`ERR_INVALID_CALLBACK`.
- version: v10.10.0
pr-url: https://github.com/nodejs/node/pull/22150
description: The `buffer` parameter can now be any `TypedArray`, or a
`DataView`.
- version: v7.4.0
pr-url: https://github.com/nodejs/node/pull/10382
description: The `buffer` parameter can now be a `Uint8Array`.
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/4518
description: The `length` parameter can now be `0`.
-->
* `fd` {integer}
* `buffer` {Buffer|TypedArray|DataView} The buffer that the data will be
written to.
* `offset` {integer} The position in `buffer` to write the data to.
* `length` {integer} The number of bytes to read.
* `position` {integer|bigint|null} Specifies where to begin reading from in the
file. If `position` is `null` or `-1 `, data will be read from the current
file position, and the file position will be updated. If `position` is
a non-negative integer, the file position will be unchanged.
* `callback` {Function}
* `err` {Error}
* `bytesRead` {integer}
* `buffer` {Buffer}
Read data from the file specified by `fd`.
The callback is given the three arguments, `(err, bytesRead, buffer)`.
If the file is not modified concurrently, the end-of-file is reached when the
number of bytes read is zero.
If this method is invoked as its [`util.promisify()`][]ed version, it returns
a promise for an `Object` with `bytesRead` and `buffer` properties.
### `fs.read(fd[, options], callback)`
<!-- YAML
added:
- v13.11.0
- v12.17.0
changes:
- version:
- v13.11.0
- v12.17.0
pr-url: https://github.com/nodejs/node/pull/31402
description: Options object can be passed in
to make buffer, offset, length, and position optional.
-->
* `fd` {integer}
* `options` {Object}
* `buffer` {Buffer|TypedArray|DataView} **Default:** `Buffer.alloc(16384)`
* `offset` {integer} **Default:** `0`
* `length` {integer} **Default:** `buffer.byteLength - offset`
* `position` {integer|bigint|null} **Default:** `null`
* `callback` {Function}
* `err` {Error}
* `bytesRead` {integer}
* `buffer` {Buffer}
Similar to the [`fs.read()`][] function, this version takes an optional
`options` object. If no `options` object is specified, it will default with the
above values.
### `fs.read(fd, buffer[, options], callback)`
<!-- YAML
added:
- v18.2.0
- v16.17.0
-->
* `fd` {integer}
* `buffer` {Buffer|TypedArray|DataView} The buffer that the data will be
written to.
* `options` {Object}
* `offset` {integer} **Default:** `0`
* `length` {integer} **Default:** `buffer.byteLength - offset`
* `position` {integer|bigint} **Default:** `null`
* `callback` {Function}
* `err` {Error}
* `bytesRead` {integer}
* `buffer` {Buffer}
Similar to the [`fs.read()`][] function, this version takes an optional
`options` object. If no `options` object is specified, it will default with the
above values.

node/doc/api/fs.md

Lines 5962 to 6017 in f7a9cdc

### `fs.readSync(fd, buffer, offset, length[, position])`
<!-- YAML
added: v0.1.21
changes:
- version: v10.10.0
pr-url: https://github.com/nodejs/node/pull/22150
description: The `buffer` parameter can now be any `TypedArray` or a
`DataView`.
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/4518
description: The `length` parameter can now be `0`.
-->
* `fd` {integer}
* `buffer` {Buffer|TypedArray|DataView}
* `offset` {integer}
* `length` {integer}
* `position` {integer|bigint|null} **Default:** `null`
* Returns: {number}
Returns the number of `bytesRead`.
For detailed information, see the documentation of the asynchronous version of
this API: [`fs.read()`][].
### `fs.readSync(fd, buffer[, options])`
<!-- YAML
added:
- v13.13.0
- v12.17.0
changes:
- version:
- v13.13.0
- v12.17.0
pr-url: https://github.com/nodejs/node/pull/32460
description: Options object can be passed in
to make offset, length, and position optional.
-->
* `fd` {integer}
* `buffer` {Buffer|TypedArray|DataView}
* `options` {Object}
* `offset` {integer} **Default:** `0`
* `length` {integer} **Default:** `buffer.byteLength - offset`
* `position` {integer|bigint|null} **Default:** `null`
* Returns: {number}
Returns the number of `bytesRead`.
Similar to the above `fs.readSync` function, this version takes an optional `options` object.
If no `options` object is specified, it will default with the above values.
For detailed information, see the documentation of the asynchronous version of
this API: [`fs.read()`][].

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Apr 20, 2024
@VoltrexKeyva
Copy link
Member

A PR is already open for this: #52603

@pluris pluris closed this Apr 20, 2024
@pluris
Copy link
Contributor Author

pluris commented Apr 20, 2024

@VoltrexKeyva Thank you, I missed it. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants