happy-opfs • Docs
happy-opfs / readFile
Reads the content of a file at the specified path with the specified options.
The type of the content to read from the file.
The path of the file to read.
Optional read options.
function readFile(filePath, options): AsyncIOResult<File>
Reads the content of a file at the specified path as a File.
Parameter | Type | Description |
---|---|---|
filePath |
string |
The path of the file to read. |
options |
ReadOptions & { encoding : "blob" ; } |
Read options specifying the 'blob' encoding. |
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.
The type of the content to read from the file.
The path of the file to read.
Optional read options.
function readFile(filePath, options): AsyncIOResult<string>
Reads the content of a file at the specified path as a string.
Parameter | Type | Description |
---|---|---|
filePath |
string |
The path of the file to read. |
options |
ReadOptions & { encoding : "utf8" ; } |
Read options specifying the 'utf8' encoding. |
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.
The type of the content to read from the file.
The path of the file to read.
Optional read options.
function readFile(filePath, options?): AsyncIOResult<ArrayBuffer>
Reads the content of a file at the specified path as an ArrayBuffer by default.
Parameter | Type | Description |
---|---|---|
filePath |
string |
The path of the file to read. |
options ? |
ReadOptions & { encoding : "binary" ; } |
Read options specifying the 'binary' encoding. |
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.
The type of the content to read from the file.
The path of the file to read.
Optional read options.