readTextFile
Reads a text file and returns its content.
Example
ts
import { SF } from "@duplojs/server-utils";
import { E, unwrap } from "@duplojs/utils";
const result = await SF.readTextFile("/tmp/file.txt");
// result: FileSystemLeft | E.Success<string>
if (E.isRight(result)) {
const fileContent = unwrap(result);
// fileContent: string
}Syntax
typescript
function readTextFile(
path: string | URL
): Promise<FileSystemLeft | E.Success<string>>Parameters
path: path of the file to read.
Return value
E.Success<string>: the file content.FileSystemLeft: if the read fails.
See also
readFile- Reads a binary file.
