Mread
Bun

method

fs.promises.FileHandle.read

read<T extends ArrayBufferView<ArrayBufferLike>>(
buffer: T,
offset?: null | number,
length?: null | number,
position?: null | number
): Promise<FileReadResult<T>>;

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.

@param buffer

A buffer that will be filled with the file data read.

@param offset

The location in the buffer at which to start filling.

@param length

The number of bytes to read.

@param position

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.

@returns

Fulfills upon success with an object with two properties:

read<T extends ArrayBufferView<ArrayBufferLike> = Buffer<ArrayBufferLike>>(
buffer: T,
options?: FileReadOptions<T>
): Promise<FileReadResult<T>>;
read<T extends ArrayBufferView<ArrayBufferLike> = Buffer<ArrayBufferLike>>(
options?: FileReadOptions<T>
): Promise<FileReadResult<T>>;