Skip to content

Latest commit

 

History

History
138 lines (77 loc) · 3.1 KB

readFile.md

File metadata and controls

138 lines (77 loc) · 3.1 KB

happy-opfsDocs


happy-opfs / readFile

Function: readFile()

Reads the content of a file at the specified path with the specified options.

Template

The type of the content to read from the file.

Param

The path of the file to read.

Param

Optional read options.

readFile(filePath, options)

function readFile(filePath, options): AsyncIOResult<File>

Reads the content of a file at the specified path as a File.

Parameters

Parameter Type Description
filePath string The path of the file to read.
options ReadOptions & { encoding: "blob"; } Read options specifying the 'blob' encoding.

Returns

AsyncIOResult<File>

A promise that resolves to an AsyncIOResult containing the file content.

A promise that resolves to an AsyncIOResult containing the file content as a File.

Template

The type of the content to read from the file.

Param

The path of the file to read.

Param

Optional read options.

Defined in

fs/opfs_core.ts:80

readFile(filePath, options)

function readFile(filePath, options): AsyncIOResult<string>

Reads the content of a file at the specified path as a string.

Parameters

Parameter Type Description
filePath string The path of the file to read.
options ReadOptions & { encoding: "utf8"; } Read options specifying the 'utf8' encoding.

Returns

AsyncIOResult<string>

A promise that resolves to an AsyncIOResult containing the file content.

A promise that resolves to an AsyncIOResult containing the file content as a string.

Template

The type of the content to read from the file.

Param

The path of the file to read.

Param

Optional read options.

Defined in

fs/opfs_core.ts:91

readFile(filePath, options)

function readFile(filePath, options?): AsyncIOResult<ArrayBuffer>

Reads the content of a file at the specified path as an ArrayBuffer by default.

Parameters

Parameter Type Description
filePath string The path of the file to read.
options? ReadOptions & { encoding: "binary"; } Read options specifying the 'binary' encoding.

Returns

AsyncIOResult<ArrayBuffer>

A promise that resolves to an AsyncIOResult containing the file content.

A promise that resolves to an AsyncIOResult containing the file content as an ArrayBuffer.

Template

The type of the content to read from the file.

Param

The path of the file to read.

Param

Optional read options.

Defined in

fs/opfs_core.ts:102