{"name":"json-file-plus","version":"3.3.2","keywords":["json","json file","formatting","read","write","promise","promiseback"],"author":{"url":"http://ljharb.codes","name":"Jordan Harband","email":"ljharb@gmail.com"},"license":"MIT","_id":"json-file-plus@3.3.2","maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"}],"contributors":[{"url":"http://ljharb.codes","name":"Jordan Harband","email":"ljharb@gmail.com"}],"homepage":"https://github.com/ljharb/json-file-plus#readme","bugs":{"url":"https://github.com/ljharb/json-file-plus/issues"},"dist":{"shasum":"8cf2a6fe249cd62c816c980526119db3256ecaf1","tarball":"http://registry-npm.ywwl.com/json-file-plus/download/json-file-plus-3.3.2.tgz","fileCount":14,"integrity":"sha512-KusE5Yl1vm5gjkHdPKEe2JcFO8u6DGRou9EW02sI3a0CjzvKwplTATPL59fHSbGw2eZR6mxU+LIpGGo881e+Eg==","signatures":[{"sig":"MEUCIFt5JxBBC/5FzuVOktEYoKDOBI5rAjd7H6KRW3n0KhQ4AiEA9PHfgQYt/6c0SuUPk6b0bqpBd+E8zGxWdKGF16dFJbg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30158,"size":9220,"noattachment":false,"key":"/json-file-plus/-/json-file-plus-3.3.2.tgz"},"main":"index.js","engines":{"node":">= 0.4"},"funding":{"url":"https://github.com/sponsors/ljharb"},"gitHead":"c63a2772314577f660efa8d5c0432000ea673ae0","scripts":{"lint":"eslint --ext=js,mjs .","test":"npm run tests-only","prelint":"evalmd README.md","pretest":"npm run lint","posttest":"npx npm@\">= 10.2\" audit --production","prepublish":"not-in-publish || npm run prepublishOnly","tests-only":"nyc tape 'test/**/*.js'","prepublishOnly":"safe-publish-latest"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"repository":{"url":"git://github.com/ljharb/json-file-plus.git","type":"git"},"_npmVersion":"10.9.2","description":"Read from and write to a JSON file, minimizing diffs and preserving formatting.","directories":{},"_nodeVersion":"23.7.0","dependencies":{"is":"^3.3.0","node.extend":"^2.0.3","promiseback":"^2.0.3","safer-buffer":"^2.1.2","object.assign":"^4.1.7"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^10.3.2","tape":"^5.9.0","eslint":"=8.8.0","evalmd":"^0.0.19","hasown":"^2.0.2","for-each":"^0.3.4","object-keys":"^1.1.1","safe-publish-latest":"^2.0.0","@ljharb/eslint-config":"^21.1.1"},"_npmOperationalInternal":{"tmp":"tmp/json-file-plus_3.3.2_1738883343489_0.4990462688615833","host":"s3://npm-registry-packages-npm-production"},"readme":"# json-file-plus <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![dependency status][deps-svg]][deps-url]\n[![dev dependency status][dev-deps-svg]][dev-deps-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][npm-url]\n\nA module to read from and write to JSON files, without losing formatting, to minimize diffs.\n\n## Example\n```js\nconst jsonFile = require('json-file-plus');\nconst path = require('path');\nconst fs = require('fs');\nconst assert = require('assert');\n\nconst filename = path.join(process.cwd(), 'package.json');\n\nconst originalContents = String(fs.readFileSync(filename));\n\njsonFile(filename).then((file) => {\n\tfile.data; // Direct access to the data from the file\n\tfile.format; // extracted formatting data. change at will.\n\n\tfile.get('version'); // get top-level keys. returns a Promise\n\tfile.get(); // get entire data. returns a Promise\n\n\t/* pass any plain object into \"set\" to merge in a deep copy */\n\t/* please note: references will be broken. */\n\t/* if a non-plain object is passed, will throw a TypeError. */\n\tfile.set({\n\t\tfoo: 'bar',\n\t\tbar: {\n\t\t\tbaz: true,\n\t\t},\n\t});\n\n\tfile.remove('description'); // remove a specific key-value pair. returns a Promise\n\n\t/* change the filename if desired */\n\tfile.filename = path.join(process.cwd(), 'new-package.json');\n\n\t/* Save the file, preserving formatting. returns a Promise. */\n\tfile.save().then(() => {\n\t\tconsole.log('success!');\n\n\t\tconst finalContents = String(fs.readFileSync(filename));\n\t\tassert.equal(originalContents, finalContents);\n\t}).catch((err) => {\n\t\tconsole.log('error!', err);\n\t\tprocess.exitCode = 1;\n\t}).finally(() => {\n\t\tfs.writeFileSync(filename, originalContents, { encoding: 'utf8' });\n\t});\n});\n```\n\n## Tests\nSimply run `npm test` in the repo\n\n[npm-url]: https://npmjs.org/package/json-file-plus\n[npm-version-svg]: https://versionbadg.es/ljharb/json-file-plus.svg\n[deps-svg]: https://david-dm.org/ljharb/json-file-plus.svg\n[deps-url]: https://david-dm.org/ljharb/json-file-plus\n[dev-deps-svg]: https://david-dm.org/ljharb/json-file-plus/dev-status.svg\n[dev-deps-url]: https://david-dm.org/ljharb/json-file-plus#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/json-file-plus.png?downloads=true&stars=true\n[license-image]: https://img.shields.io/npm/l/json-file-plus.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/json-file-plus.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=json-file-plus\n[codecov-image]: https://codecov.io/gh/ljharb/json-file-plus/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/ljharb/json-file-plus/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/json-file-plus\n[actions-url]: https://github.com/ljharb/json-file-plus/actions\n","publish_time":1738883343760,"_cnpm_publish_time":1738883343760,"dist-tags":{"latest":"4.0.1"}}