UNPKG

write-json-safe

Version:
17 lines (16 loc) 1.06 kB
import { writeFile, writeFileSync } from "write-file-safe"; import stringify from "stringify-json-object"; export async function writeJSON(path, content, options) { var _options_pretty; return writeFile(path, stringify(content, (_options_pretty = options === null || options === void 0 ? void 0 : options.pretty) !== null && _options_pretty !== void 0 ? _options_pretty : true), { recursive: options === null || options === void 0 ? void 0 : options.recursive, appendNewline: options === null || options === void 0 ? void 0 : options.appendNewline }); } export function writeJSONSync(path, content, options) { var _options_pretty; return writeFileSync(path, stringify(content, (_options_pretty = options === null || options === void 0 ? void 0 : options.pretty) !== null && _options_pretty !== void 0 ? _options_pretty : true), { recursive: options === null || options === void 0 ? void 0 : options.recursive, appendNewline: options === null || options === void 0 ? void 0 : options.appendNewline }); }