Skip to content

Commit

Permalink
squash: add doc entries
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMedeiros committed Apr 17, 2022
1 parent aec64ca commit 42c9c40
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,33 @@ Reads data from the file and stores that in the given buffer.
If the file is not modified concurrently, the end-of-file is reached when the
number of bytes read is zero.
#### `filehandle.read(buffer[, options])`
<!-- YAML
added: REPLACEME
-->
* `buffer` {Buffer|TypedArray|DataView} A buffer that will be filled with the
file data read.
* `options` {Object}
* `offset` {integer} The location in the buffer at which to start filling.
**Default:** `0`
* `length` {integer} The number of bytes to read. **Default:**
`buffer.byteLength - offset`
* `position` {integer} The location where to begin reading data from the
file. If `null`, data will be read from the current file position, and
the position will be updated. If `position` is an integer, the current
file position will remain unchanged. **Default:**: `null`
* Returns: {Promise} Fulfills upon success with an object with two properties:
* `bytesRead` {integer} The number of bytes read
* `buffer` {Buffer|TypedArray|DataView} A reference to the passed in `buffer`
argument.
Reads data from the file and stores that in the given buffer.
If the file is not modified concurrently, the end-of-file is reached when the
number of bytes read is zero.
#### `filehandle.readableWebStream()`
<!-- YAML
Expand Down Expand Up @@ -3243,6 +3270,28 @@ 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: REPLACEME
-->
* `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.
### `fs.readdir(path[, options], callback)`
<!-- YAML
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-read-offset-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let filehandle = null;
(async () => {
filehandle = await fsPromises.open(filepath, 'r');
assert.rejects(
async () => await filehandle.read(buf, { offset: null }),
async () => filehandle.read(buf, { offset: null }),
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
Expand Down

0 comments on commit 42c9c40

Please sign in to comment.