write-json5-file
Stringify and write JSON to a file atomically
Last updated 4 years ago by zkochan .
MIT · Repository · Original npm · Tarball · package.json
$ npm install write-json5-file 
SYNC missed versions from official npm registry.

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

Current Tags

  • 3.1.0                                ...           latest (4 years ago)
  • 3.1.0                                ...           next (4 years ago)

9 Versions

  • 3.1.0                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           5 years ago
  • 2.1.2                                ...           5 years ago
  • 2.1.1                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE