4.0.0 • Published 1 year ago

write-json-safe v4.0.0

Weekly downloads
19
License
MIT
Repository
github
Last release
1 year ago

If I should maintain this repo, please ⭐️

DM me on Twitter if you have questions or suggestions.


Installation

yarn add write-json-safe
npm install write-json-safe
pnpm add write-json-safe

Usage

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;
};
  • @types/mock-fs: TypeScript definitions for mock-fs
  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.
  • mock-fs: A configurable mock file system. You know, for testing.
  • read-file-safe: Read files without try catch

MIT

Related Packages