Skip to main content
Version: Next

readTextFile

function readTextFile(path): Promise<string>;

Read a file in text mode, i.e. into a string, without open/close a file descriptor/handle.

Parameters​

ParameterTypeDescription

path

string

File path to read.

Returns​

Promise<string>

It resolves to text string that contains all the file contents.

Throws​

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

Example​

const payload = await Rsvim.fs.readTextFile("README.md");