$ npm install write-json5-file
Stringify and write JSON to a file atomically
<npm|yarn|pnpm> add write-json5-file
const writeJson5File = require('write-json5-file')
writeJson5File('foo.json5', {foo: true}).then(() => {
console.log('done')
})
writeJson5File(filepath, data, [options])
Returns a promise.
writeJson5File.sync(filepath, data, [options])
Type: string
, number
Default: \t
Indentation as a string or number of spaces.
Pass in null
for no formatting.
Type: boolean
, function
Default: false
Sort the keys recursively.
Optionally pass in a compare
function.
Type: function
Passed into JSON.stringify
.
Type: number
Default 438
(0666 in octal)
Mode used when writing the file.
© 2010 - cnpmjs.org x YWFE | Home | YWFE