main
| 1 | import fs from "fs/promises" |
| 2 | |
| 3 | export const readJson = async (filePath: string): Promise<unknown> => { |
| 4 | const jsonString = await fs.readFile(filePath, "utf8") |
| 5 | return JSON.parse(jsonString) |
| 6 | } |
| 7 | |
| 8 | export const writeJson = async ( |
| 9 | filePath: string, |
| 10 | jsonObject: unknown |
| 11 | ): Promise<void> => { |
| 12 | const jsonString = JSON.stringify(jsonObject) |
| 13 | await fs.writeFile(filePath, jsonString, "utf8") |
| 14 | } |