$ gnpm install write-json-safe
Write formatted JSON to a file.
If I should maintain this repo, please ⭐️
DM me on Twitter if you have questions or suggestions.
yarn add write-json-safe
npm install write-json-safe
pnpm add write-json-safe
import { writeJSON, writeJSONSync, Options, OptionalJSONValue } from "write-json-safe";
function writeJSON(path: string, content?: OptionalJSONValue, options?: Options): Promise<boolean>;
function writeJSONSync(path: string, content?: OptionalJSONValue, 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 |