{"name":"jsonfile","version":"6.0.1","description":"Easily read/write JSON files.","repository":{"type":"git","url":"git+ssh://git@github.com/jprichardson/node-jsonfile.git"},"keywords":["read","write","file","json","fs","fs-extra"],"author":{"name":"JP Richardson","email":"jprichardson@gmail.com"},"license":"MIT","dependencies":{"universalify":"^1.0.0","graceful-fs":"^4.1.6"},"optionalDependencies":{"graceful-fs":"^4.1.6"},"devDependencies":{"mocha":"^5.2.0","rimraf":"^2.4.0","standard":"^12.0.1"},"main":"index.js","scripts":{"lint":"standard","test":"npm run lint && npm run unit","unit":"mocha"},"gitHead":"78937d20c95efd259574b7604a4efeb55d1a2b7a","bugs":{"url":"https://github.com/jprichardson/node-jsonfile/issues"},"homepage":"https://github.com/jprichardson/node-jsonfile#readme","_id":"jsonfile@6.0.1","_nodeVersion":"13.7.0","_npmVersion":"6.13.6","dist":{"integrity":"sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==","shasum":"98966cba214378c8c84b82e085907b40bf614179","tarball":"http://registry-npm.ywwl.com/jsonfile/download/jsonfile-6.0.1.tgz","fileCount":6,"unpackedSize":18795,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeY7lfCRA9TVsSAnZWagAAvW4QAJWNB0aB0VdNdfoQV0Io\n8pG9pY4hus8KZLVii9AAJ3Rn3JiS2HEfR3fSyZjnAxv9npuQn6+4TpZ25LxE\nN1sr7m3KMF0GuvJHKVCvcghVELGoFRRzxK0eLPnKHD8WFPSIXMl4LhNkWUMg\nURSb6TDQ9OBvWTRloujaOr81vm4V29GgoQj4FxpW8OA7d14UPLIYpo0CtVnJ\nNqPJVccV9lVf59LFDqP5+9TapJEF2U69EOSgr0I105sX+9cVpvxTuKZcnOdK\nV0uTK1UQRi5vVhLIq05TA5d08OlE68DCNZ5do309iL9o1y4xsDWhYAhWtmQM\n11Gold7qobpwR1o8cnYvF37Iv1ZjTmmmYbSz2TcEGDfLXPXIh8o4CHpcX6Qa\nMlpci28vS2qyyMZGWZ4ng6Uv9o6lFB6dCmxkedGNCpIeHU5lg0oy4wqa+uBV\nkBjPRYXl4BrPFRYiZE2k79UaryShvVZda/SmBNdxk2lIrPne3jbkjRhSaAoW\nRuRV3qHYLU/opYgRCLkUFDkaxt83YQRGkf2eVqdZiTUMbuirxTfJqZy0A8TC\npSXd6vYGFATM9qIzNt7vrihK87w56VMPg3nYlGTmj4mU7pCA4/CzQCUFVwvd\n29/eXnxAqUl+p+Qr89wm12tojOOA53LXit0v0NdaCwMPfp4E5jz+uMxIMO+A\nx75R\r\n=PX44\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCyUO1o+c1Ie7VEfRPX1dktIYyz5BBTPKx0Rl7jR9xb4wIgL9eQfVztmiCObGQ1DiMnJ6FDeHBQcel3w04zhaj3uO8="}],"size":5672,"noattachment":false,"key":"/jsonfile/-/jsonfile-6.0.1.tgz"},"maintainers":[{"name":"jprichardson","email":"jprichardson@gmail.com"},{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsonfile_6.0.1_1583593822667_0.38017978131454977"},"_hasShrinkwrap":false,"readme":"Node.js - jsonfile\n================\n\nEasily read/write JSON files in Node.js. _Note: this module cannot be used in the browser._\n\n[![npm Package](https://img.shields.io/npm/v/jsonfile.svg?style=flat-square)](https://www.npmjs.org/package/jsonfile)\n[![build status](https://secure.travis-ci.org/jprichardson/node-jsonfile.svg)](http://travis-ci.org/jprichardson/node-jsonfile)\n[![windows Build status](https://img.shields.io/appveyor/ci/jprichardson/node-jsonfile/master.svg?label=windows%20build)](https://ci.appveyor.com/project/jprichardson/node-jsonfile/branch/master)\n\n<a href=\"https://github.com/feross/standard\"><img src=\"https://cdn.rawgit.com/feross/standard/master/sticker.svg\" alt=\"Standard JavaScript\" width=\"100\"></a>\n\nWhy?\n----\n\nWriting `JSON.stringify()` and then `fs.writeFile()` and `JSON.parse()` with `fs.readFile()` enclosed in `try/catch` blocks became annoying.\n\n\n\nInstallation\n------------\n\n    npm install --save jsonfile\n\n\n\nAPI\n---\n\n* [`readFile(filename, [options], callback)`](#readfilefilename-options-callback)\n* [`readFileSync(filename, [options])`](#readfilesyncfilename-options)\n* [`writeFile(filename, obj, [options], callback)`](#writefilefilename-obj-options-callback)\n* [`writeFileSync(filename, obj, [options])`](#writefilesyncfilename-obj-options)\n\n----\n\n### readFile(filename, [options], callback)\n\n`options` (`object`, default `undefined`): Pass in any [`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).\n  - `throws` (`boolean`, default: `true`). If `JSON.parse` throws an error, pass this error to the callback.\n  If `false`, returns `null` for the object.\n\n\n```js\nconst jsonfile = require('jsonfile')\nconst file = '/tmp/data.json'\njsonfile.readFile(file, function (err, obj) {\n  if (err) console.error(err)\n  console.dir(obj)\n})\n```\n\nYou can also use this method with promises. The `readFile` method will return a promise if you do not pass a callback function.\n\n```js\nconst jsonfile = require('jsonfile')\nconst file = '/tmp/data.json'\njsonfile.readFile(file)\n  .then(obj => console.dir(obj))\n  .catch(error => console.error(error))\n```\n\n----\n\n### readFileSync(filename, [options])\n\n`options` (`object`, default `undefined`): Pass in any [`fs.readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).\n- `throws` (`boolean`, default: `true`). If an error is encountered reading or parsing the file, throw the error. If `false`, returns `null` for the object.\n\n```js\nconst jsonfile = require('jsonfile')\nconst file = '/tmp/data.json'\n\nconsole.dir(jsonfile.readFileSync(file))\n```\n\n----\n\n### writeFile(filename, obj, [options], callback)\n\n`options`: Pass in any [`fs.writeFile`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.\n\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, function (err) {\n  if (err) console.error(err)\n})\n```\nOr use with promises as follows:\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj)\n  .then(res => {\n    console.log('Write complete')\n  })\n  .catch(error => console.error(error))\n```\n\n\n**formatting with spaces:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { spaces: 2 }, function (err) {\n  if (err) console.error(err)\n})\n```\n\n**overriding EOL:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { spaces: 2, EOL: '\\r\\n' }, function (err) {\n  if (err) console.error(err)\n})\n```\n\n\n**disabling the EOL at the end of file:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { spaces: 2, finalEOL: false }, function (err) {\n  if (err) console.log(err)\n})\n```\n\n**appending to an existing JSON file:**\n\nYou can use `fs.writeFile` option `{ flag: 'a' }` to achieve this.\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/mayAlreadyExistedData.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { flag: 'a' }, function (err) {\n  if (err) console.error(err)\n})\n```\n\n----\n\n### writeFileSync(filename, obj, [options])\n\n`options`: Pass in any [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj)\n```\n\n**formatting with spaces:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { spaces: 2 })\n```\n\n**overriding EOL:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { spaces: 2, EOL: '\\r\\n' })\n```\n\n**disabling the EOL at the end of file:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { spaces: 2, finalEOL: false })\n```\n\n**appending to an existing JSON file:**\n\nYou can use `fs.writeFileSync` option `{ flag: 'a' }` to achieve this.\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/mayAlreadyExistedData.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { flag: 'a' })\n```\n\nLicense\n-------\n\n(MIT License)\n\nCopyright 2012-2016, JP Richardson  <jprichardson@gmail.com>\n","publish_time":1583593822836,"_cnpm_publish_time":1583593822836,"dist-tags":{"latest":"6.2.1"}}