(content: string)
| 3 | import { readFile, mkdir, writeFile } from 'node:fs/promises'; |
| 4 | |
| 5 | export function strictJSONParse<T extends object = object>(content: string): T { |
| 6 | const obj = JSON.parse(content) as T; |
| 7 | if (!obj || typeof obj !== 'object') { |
| 8 | throw new Error('JSON string is not object'); |
| 9 | } |
| 10 | return obj; |
| 11 | } |
| 12 | |
| 13 | export function readJSONSync<T = any>(filepath: string): T { |
| 14 | return JSON.parse(readFileSync(filepath, 'utf8')) as T; |
no outgoing calls
no test coverage detected
searching dependent graphs…