diff options
author | Livia Medeiros <74449973+LiviaMedeiros@users.noreply.github.com> | 2022-05-02 21:01:27 +0300 |
---|---|---|
committer | RafaelGSS <rafael.nunu@hotmail.com> | 2022-05-10 15:13:16 +0300 |
commit | 784d84cf346c5c41679fa75d3da27119365e8f0d (patch) | |
tree | ae3f8b35dd346803a288bc8b94f8b40373d6ca7c /doc | |
parent | 68ed3c88d9503ebd6824492e058c7b47c8c55e31 (diff) |
fs: add `read(buffer[, options])` versions
This adds the following:
- `fs.read(fd, buffer[, options], callback)`.
- `filehandle.read(buffer[, options])`.
PR-URL: https://github.com/nodejs/node/pull/42768
Refs: https://github.com/nodejs/node/pull/42601
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/fs.md | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md index 1422bee91fc..c27e1868351 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -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 @@ -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 |