{"name":"json-file-plus","version":"4.0.1","author":{"name":"Jordan Harband","email":"ljharb@gmail.com","url":"http://ljharb.codes"},"funding":{"url":"https://github.com/sponsors/ljharb"},"contributors":[{"name":"Jordan Harband","email":"ljharb@gmail.com","url":"http://ljharb.codes"}],"license":"MIT","main":"index.mjs","exports":{".":"./index.mjs","./package.json":"./package.json"},"sideEffects":false,"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublishOnly":"safe-publish-latest","prepublish":"not-in-publish || npm run prepublishOnly","prelint":"evalmd README.md","lint":"eslint .","postlint":"tsc && attw -P .","pretest":"npm run lint","test":"npm run tests-only","tests-only":"c8 tape 'test/**/*.mjs'","posttest":"npx npm@\">= 10.2\" audit --production"},"repository":{"type":"git","url":"git://github.com/ljharb/json-file-plus.git"},"keywords":["json","json file","formatting","read","write","promise"],"dependencies":{"node.extend":"^2.0.3"},"devDependencies":{"@arethetypeswrong/cli":"^0.18.2","@ljharb/eslint-config":"^22.1.3","@ljharb/tsconfig":"^0.3.2","@types/tape":"^5.8.1","c8":"^9.1.0","es-value-fixtures":"^1.7.1","eslint":"^9.39.2","evalmd":"^0.0.19","hasown":"^2.0.2","npmignore":"^0.3.2","safe-publish-latest":"^2.0.0","tape":"^5.9.0","typescript":"next"},"engines":{"node":"^16.20.2 || ^18.20.6 || ^20.18.3 || ^22.14.0 || >= 23.8"},"publishConfig":{"ignore":[".attw.json",".editorconfig","eslint.config.mjs",".nycrc",".github/workflows","appveyor.yml","test","tsconfig.json"]},"gitHead":"1a8572f3074f1baff0264ccc8f7d62e50525c3fd","_id":"json-file-plus@4.0.1","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","bugs":{"url":"https://github.com/ljharb/json-file-plus/issues"},"homepage":"https://github.com/ljharb/json-file-plus#readme","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-3ZDj5pi7HCaFRpJ91LHoYfEdBkyzQijAWDE15W09dw/kwLF8Nz8zVIeSMYpetPHtgeQPE2swz7z6MGq6Ce0OWg==","shasum":"3307f325e04c4965307885a841f546326ddb5594","tarball":"http://registry-npm.ywwl.com/json-file-plus/download/json-file-plus-4.0.1.tgz","fileCount":7,"unpackedSize":18931,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAlEr3cgoBL7nRoRVPgpx0Bom3SZBZ3cTLvRpXA65SgGAiB77ONwz3Y/puh8d1JVKe1WA9xMB/E0TE6FchdGszUd5A=="}],"size":6583,"noattachment":false,"key":"/json-file-plus/-/json-file-plus-4.0.1.tgz"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"directories":{},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/json-file-plus_4.0.1_1766039731941_0.5938403038776867"},"_hasShrinkwrap":false,"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":1766039732113,"_cnpm_publish_time":1766039732113,"dist-tags":{"latest":"4.0.1"}}