{"name":"parse-conflict-json","version":"4.0.0","description":"Parse a JSON string that has git merge conflicts, resolving if possible","author":{"name":"GitHub Inc."},"license":"ISC","main":"lib","scripts":{"test":"tap","snap":"tap","lint":"npm run eslint","postlint":"template-oss-check","lintfix":"npm run eslint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""},"tap":{"check-coverage":true,"nyc-arg":["--exclude","tap-snapshots/**"]},"devDependencies":{"@npmcli/eslint-config":"^5.0.0","@npmcli/template-oss":"4.23.3","tap":"^16.0.1"},"dependencies":{"json-parse-even-better-errors":"^4.0.0","just-diff":"^6.0.0","just-diff-apply":"^5.2.0"},"repository":{"type":"git","url":"git+https://github.com/npm/parse-conflict-json.git"},"engines":{"node":"^18.17.0 || >=20.5.0"},"templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.23.3","publish":true},"_id":"parse-conflict-json@4.0.0","gitHead":"d0655a9ec0a9e640ae00611c0b62ddc0a513a138","bugs":{"url":"https://github.com/npm/parse-conflict-json/issues"},"homepage":"https://github.com/npm/parse-conflict-json#readme","_nodeVersion":"22.9.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-37CN2VtcuvKgHUs8+0b1uJeEsbGn61GRHz469C94P5xiOoqpDYJYwjg4RY9Vmz39WyZAVkR5++nbJwLMIgOCnQ==","shasum":"996b1edfc0c727583b56c7644dbb3258fc9e9e4b","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-4.0.0.tgz","fileCount":4,"unpackedSize":6398,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/parse-conflict-json@4.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBOP4li27513ppmccNWjA/7y7mkDt0jMi8XLJo3TTH3jAiEA5OHGCL44EDhS7cAuJyGyLuL+/jnou4ImGXUvNxFMvMc="}],"size":2974,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-4.0.0.tgz"},"_npmUser":{"name":"npm-cli-ops","email":"npm-cli+bot@github.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parse-conflict-json_4.0.0_1727284847711_0.362585997362203"},"_hasShrinkwrap":false,"readme":"# parse-conflict-json\n\nParse a JSON string that has git merge conflicts, resolving if possible.\n\nIf the JSON is valid, it just does `JSON.parse` as normal.\n\nIf either side of the conflict is invalid JSON, then an error is thrown for\nthat.\n\n## USAGE\n\n```js\n// after a git merge that left some conflicts there\nconst data = fs.readFileSync('package-lock.json', 'utf8')\n\n// reviverFunction is passed to JSON.parse as the reviver function\n// preference defaults to 'ours', set to 'theirs' to prefer the other\n// side's changes.\nconst parsed = parseConflictJson(data, reviverFunction, preference)\n\n// returns true if the data looks like a conflicted diff file\nparsed.isDiff(data)\n```\n\n## Algorithm\n\nIf `prefer` is set to `theirs`, then the vaules of `theirs` and `ours` are\nswitched in the resolver function.  (Ie, we'll apply their changes on top\nof our object, rather than the other way around.)\n\n- Parse the conflicted file into 3 pieces: `ours`, `theirs`, and `parent`\n\n- Get the [diff](https://github.com/angus-c/just#just-diff) from `parent`\n  to `ours`.\n\n- [Apply](https://github.com/angus-c/just#just-diff-apply) each change of\n  that diff to `theirs`.\n\n    If any change in the diff set cannot be applied (ie, because they\n    changed an object into a non-object and we changed a field on that\n    object), then replace the object at the specified path with the object\n    at the path in `ours`.\n","publish_time":1727284847906,"maintainers":[{"name":"hashtagchris","email":"hashtagchris@github.com"},{"name":"reggi","email":"reggi@github.com"},{"name":"npm-cli-ops","email":"npm-cli+bot@github.com"},{"name":"saquibkhan","email":"saquibkhan@github.com"},{"name":"fritzy","email":"fritzy@github.com"},{"name":"gar","email":"gar+npm@danger.computer"}],"_cnpm_publish_time":1727284847906,"dist-tags":{"latest":"6.0.0"}}