File size: 336 Bytes
2cae2a9
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { promises as fs } from "fs"

export async function readPlainText(filePath: string): Promise<string> {
  try {
    const plainText = await fs.readFile(filePath, "utf-8");

    return plainText;
  } catch (error) {
    // Handle errors (e.g., file not found, no permissions, etc.)
    console.error(error);
    throw error;
  }
}