mic-bot/utils/io.ts

11 lines
415 B
TypeScript
Raw Normal View History

2024-10-19 10:00:35 +00:00
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));
}