{"name":"parse-conflict-json","version":"5.0.1","author":{"name":"GitHub Inc."},"license":"ISC","_id":"parse-conflict-json@5.0.1","maintainers":[{"name":"gar","email":"gar+npm@danger.computer"},{"name":"saquibkhan","email":"saquibkhan@github.com"},{"name":"npm-cli-ops","email":"npm-cli+bot@github.com"},{"name":"reggi","email":"reggi@github.com"},{"name":"hashtagchris","email":"hashtagchris@github.com"},{"name":"owlstronaut","email":"owlstronaut@github.com"}],"homepage":"https://github.com/npm/parse-conflict-json#readme","bugs":{"url":"https://github.com/npm/parse-conflict-json/issues"},"tap":{"nyc-arg":["--exclude","tap-snapshots/**"],"check-coverage":true},"dist":{"shasum":"db4acd7472fb400c9808eb86611c2ff72f4c84ba","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-5.0.1.tgz","fileCount":4,"integrity":"sha512-ZHEmNKMq1wyJXNwLxyHnluPfRAFSIliBvbK/UiOceROt4Xh9Pz0fq49NytIaeaCUf5VR86hwQ/34FCcNU5/LKQ==","signatures":[{"sig":"MEUCIHbX8pf/qulR29sGmPiSoV7QavqtIWM0KV4UMHLGCr3CAiEA2XyGCiqCRmdHRE1fV9YnAPBpUjQrbes3+f4Eg3kWSLA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/parse-conflict-json@5.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":6398,"size":2973,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-5.0.1.tgz"},"main":"lib","engines":{"node":"^20.17.0 || >=22.9.0"},"gitHead":"51594349f8b8eecf0ed5bae930702732599888c6","scripts":{"lint":"npm run eslint","snap":"tap","test":"tap","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"","lintfix":"npm run eslint -- --fix","postlint":"template-oss-check","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f3a99145-2de3-4deb-941e-3b7d9a796a42"}},"repository":{"url":"git+https://github.com/npm/parse-conflict-json.git","type":"git"},"_npmVersion":"11.6.2","description":"Parse a JSON string that has git merge conflicts, resolving if possible","directories":{},"templateOSS":{"publish":true,"version":"4.27.1","//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten."},"_nodeVersion":"22.20.0","dependencies":{"just-diff":"^6.0.0","just-diff-apply":"^5.2.0","json-parse-even-better-errors":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.0.1","@npmcli/template-oss":"4.27.1","@npmcli/eslint-config":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/parse-conflict-json_5.0.1_1761242462467_0.057304237570827476","host":"s3://npm-registry-packages-npm-production"},"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":1761242462707,"_cnpm_publish_time":1761242462707,"dist-tags":{"latest":"6.0.0"}}