{"name":"json-file-plus","version":"4.0.0","keywords":["json","json file","formatting","read","write","promise"],"author":{"url":"http://ljharb.codes","name":"Jordan Harband","email":"ljharb@gmail.com"},"license":"MIT","_id":"json-file-plus@4.0.0","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":"8ba15cbb7c491c94ad55bcf9295d9b4347c32f7c","tarball":"http://registry-npm.ywwl.com/json-file-plus/download/json-file-plus-4.0.0.tgz","fileCount":7,"integrity":"sha512-Cttih3C+fzK4HhtgYPrIK/5GDbCDopqdNDat4mKwXk/7rOfdIpvIosTS/QYad/0WGGRaTlWexIVXVCYPWkeKPw==","signatures":[{"sig":"MEUCIQDm4JcTJxrbJZm/9f2KMBpoUyUDh1sTuohn+8Pu0CoqYgIgJkw801Pg7ZlShhIkypODYHr8rH1Vmh+fuXAdz99KhqU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18154,"size":6424,"noattachment":false,"key":"/json-file-plus/-/json-file-plus-4.0.0.tgz"},"main":"index.mjs","engines":{"node":"^16.20.2 || ^18.20.6 || ^20.18.3 || ^22.14.0 || >= 23.8"},"exports":{".":"./index.mjs","./package.json":"./package.json"},"funding":{"url":"https://github.com/sponsors/ljharb"},"gitHead":"62c5ddf35f2a9399d38db3e9bb2ddad11b697a7e","scripts":{"lint":"eslint --ext=js,mjs .","test":"npm run tests-only","prelint":"evalmd README.md","prepack":"npmignore --auto --commentLines=autogenerated","pretest":"npm run lint","postlint":"tsc && attw -P .","posttest":"npx npm@\">= 10.2\" audit --production","prepublish":"not-in-publish || npm run prepublishOnly","tests-only":"nyc tape 'test/**/*.mjs'","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":"[![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-im","directories":{},"sideEffects":false,"_nodeVersion":"23.8.0","dependencies":{"node.extend":"^2.0.3"},"publishConfig":{"ignore":[".attw.json",".editorconfig",".eslintrc",".nycrc",".github/workflows","appveyor.yml","test","tsconfig.json"]},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^10.3.2","tape":"^5.9.0","eslint":"=8.8.0","evalmd":"^0.0.19","hasown":"^2.0.2","npmignore":"^0.3.1","typescript":"next","@types/tape":"^5.8.1","@ljharb/tsconfig":"^0.2.3","es-value-fixtures":"^1.7.1","safe-publish-latest":"^2.0.0","@arethetypeswrong/cli":"^0.17.3","@ljharb/eslint-config":"^21.1.1"},"_npmOperationalInternal":{"tmp":"tmp/json-file-plus_4.0.0_1739492287520_0.4154399573667453","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":1739492287769,"_cnpm_publish_time":1739492287769,"dist-tags":{"latest":"4.0.1"}}