roseking's picture
Add professional benchmark suite
9f5cf6f verified
raw
history blame contribute delete
631 Bytes
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import { dirname } from 'node:path'
export async function readJsonFile<T>(path: string): Promise<T> {
const raw = await readFile(path, 'utf8')
return JSON.parse(raw) as T
}
export async function writeJsonFile(path: string, value: unknown): Promise<void> {
await mkdir(dirname(path), { recursive: true })
await writeFile(path, JSON.stringify(value, null, 2), 'utf8')
}
export async function writeTextFile(path: string, value: string): Promise<void> {
await mkdir(dirname(path), { recursive: true })
await writeFile(path, value, 'utf8')
}