$ cnpm install write-json-safe
Write formatted JSON to a file.
yarn add write-json-safe
npm install write-json-safe
import { writeJSON, writeJSONSync, Options, JSONObject } from "write-json-safe";
function writeJSON(path: string, content?: JSONObject, options?: Options): Promise<boolean>;
function writeJSONSync(path: string, content?: JSONObject, options?: Options): boolean;
type Options = {
/**
* Output formatted JSON. Default: `true`
*/
pretty?: boolean;
/**
* Recursively create parent directories if needed. Default: `true`
*/
recursive?: boolean;
/**
* Ensure file ends with a newline. Default: `true`
*/
appendNewline?: boolean;
/**
* Write even if file already exists. Default: `true`
*/
overwrite?: boolean;
}
Copyright 2013 - present © cnpmjs.org | Home |