UNPKG

@thi.ng/file-io

Version:

Assorted file I/O utils (with logging support) for NodeJS/Bun

13 lines (12 loc) 318 B
import { readText, writeText } from "./text.js"; const readJSON = (path, logger) => JSON.parse(readText(path, logger)); const writeJSON = (path, obj, replacer, space, logger, dryRun = false) => writeText( path, JSON.stringify(obj, replacer, space) + "\n", logger, dryRun ); export { readJSON, writeJSON };