Skip to main content
Version: Next

readFile

function readFile(path): Promise<Uint8Array<ArrayBufferLike>>;

Read a file in binary mode, i.e. into an array of bytes buffer, without open/close a file descriptor/handle.

Parameters

ParameterTypeDescription

path

string

File path to read.

Returns

Promise<Uint8Array<ArrayBufferLike>>

It resolves to Uint8Array that contains all the file contents as bytes array.

Throws

Throws TypeError if the file name is invalid. Or throws Error if failed to read the file.

Example

const buffer = await Rsvim.fs.readFile("README.md");