mic-bot/utils/io.ts
2024-10-19 12:00:35 +02:00

11 lines
415 B
TypeScript

export const readJsonFile = async <T>(filePath: string): Promise<T> => {
const decoder = new TextDecoder("utf-8");
const data = await Deno.readFile(filePath);
return JSON.parse(decoder.decode(data));
}
export const readJsonFileSync = <T>(filePath: string): T => {
const decoder = new TextDecoder("utf-8");
const data = Deno.readFileSync(filePath);
return JSON.parse(decoder.decode(data));
}