5.0.0 • Published 3 years ago

write-json-file v5.0.0

Weekly downloads
2,875,112
License
MIT
Repository
github
Last release
3 years ago

write-json-file

Stringify and write JSON to a file atomically

Creates directories for you as needed.

Install

$ npm install write-json-file

Usage

import {writeJsonFile} from 'write-json-file';

await writeJsonFile('foo.json', {foo: true});

API

writeJsonFile(filePath, data, options?)

Returns a Promise.

writeJsonFile.sync(filePath, data, options?)

options

Type: object

indent

Type: string | number\ Default: '\t'

Indentation as a string or number of spaces.

Pass in undefined for no formatting.

detectIndent

Type: boolean\ Default: false

Detect indentation automatically if the file exists.

sortKeys

Type: boolean | Function\ Default: false

Sort the keys recursively.

Optionally pass in a compare function.

replacer

Type: Function

Passed into JSON.stringify.

mode

Type: number\ Default: 0o666

The mode used when writing the file.

write-json-file for enterprise

Available as part of the Tidelift Subscription.

The maintainers of write-json-file and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Related

write-pkg@lerna/project@liongard/roarcli@megasaur/init@megasaur/project@vastly/wave-cli@energyweb/migrations@essent/lerna@theia/application-packagehadith-app@liongard/roarcli-shawn@liongard/roarcli2kapilka@frxf/frxf@mcgordonite/theia-application-packagezoos-mp-plugin-routerzoos-mp-servicestrapuxcogoportutilsawsmanbabel7-upgradecreate-maca-projectmoke-images-tinify@everything-registry/sub-chunk-3166nuuppackage-json-sorter-clinpm-multi-publishnow-flowmisciblenode-pmcnh-admin-apppianobar-notifierpdfify-nodepc-npm-script-processpenguin.jsnvestproductnvestproductnewpostinstall-switchpackage-storepackage-previewmy-initpnpm-glitch@devpodio/application-package@cardano-graphql/clizendesk-themer@diablohu/hard-source-webpack-plugin@caseywebb/tempmon@donmahallem/lerna-fixerbyun-cli@cloudflare/memsource-cliboltify@codemayonnaise/extract-react-intl-messagescandlelabssdk@davidreinberger/lerna-versioncardano-graphql-clicargotestcheers-mp-plugin-routercheers-mp-servicechimyra@ftchinese/component-stats@vladfrangu-dev/apify-cli@xjaqil/umi-plugin-pwa@zeit/hard-source-webpack-plugin@zeit/ng-deploywebiny-cli@vidiun-ng/dev-workspace@zhangweijie/breadastra-ufo-sdkawesome-react-starsatvise-scripts@b-flower/bdm-mrocs-packager@bullhorn/bullhorn-cli@blackwall/eslint-config@aw-web-design/lerna-core@aw-web-design/lerna-publish@aw-web-design/lerna-version@bud-tools/application-package@buganto/clientbabel-upgrade@cactus-technologies/utils@bchteam/eslint-configavo@atlaskit/lerna@blinkmobile/json-as-files@blinkmobile/server-cli@blinkmobile/blinkmrc@blinkmobile/bmp-clichrec-core@gedit/application-package@gedit/cliadd-book@wext/test@webiny/cwp-template-aws@webiny/cwp-template-cms@webiny/cwp-template-full@webiny/cli-plugin-scaffold-graphql-api@webiny/cli-plugin-scaffold-graphql-service@webiny/cli-plugin-scaffold-node-package@webiny/cli-plugin-scaffold-react-app@webiny/cli-plugin-scaffold-react-component
5.0.0

3 years ago

4.3.0

4 years ago

4.2.1

4 years ago

4.2.0

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.0

7 years ago

2.0.0

8 years ago

1.2.0

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago