write-json-safe
Write formatted JSON to a file
Last updated 2 years ago by bconnorwhite .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install write-json-safe 
SYNC missed versions from official npm registry.

write-json-safe

NPM TypeScript Coverage Status

Write formatted JSON to a file.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


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;
};

Dependenciesdependencies


Dev Dependencies

  • @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

License license

MIT


Related Packages

Current Tags

  • 4.0.0                                ...           latest (2 years ago)

8 Versions

  • 4.0.0                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (4)

Copyright 2013 - present © cnpmjs.org | Home |