write-json5-file
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

write-json5-file

Stringify and write JSON to a file atomically

npm version

Installation

<npm|yarn|pnpm> add write-json5-file

Usage

const writeJson5File = require('write-json5-file')

writeJson5File('foo.json5', {foo: true}).then(() => {
	console.log('done')
})

API

writeJson5File(filepath, data, [options])

Returns a promise.

writeJson5File.sync(filepath, data, [options])

options

indent

Type: string, number Default: \t

Indentation as a string or number of spaces. Pass in null for no formatting.

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 438 (0666 in octal)

Mode used when writing the file.

Related

License

MIT © Zoltan Kochan

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 3.1.0
    294
    • latest
  • 3.1.0
    294
    • next

Version History

Package Sidebar

Install

npm i write-json5-file

Weekly Downloads

1,306

Version

3.1.0

License

MIT

Unpacked Size

6.7 kB

Total Files

6

Last publish

Collaborators

  • zkochan