11 lines
415 B
TypeScript
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));
|
||
|
}
|