{"name":"parse-conflict-json","version":"3.0.1","author":{"name":"GitHub Inc."},"license":"ISC","_id":"parse-conflict-json@3.0.1","maintainers":[{"name":"npm-cli-ops","email":"npm-cli+bot@github.com"},{"name":"saquibkhan","email":"saquibkhan@github.com"},{"name":"fritzy","email":"fritzy@github.com"},{"name":"nlf","email":"quitlahok@gmail.com"},{"name":"gar","email":"gar+npm@danger.computer"},{"name":"lukekarrys","email":"luke@lukekarrys.com"},{"name":"isaacs","email":"i@izs.me"}],"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":"67dc55312781e62aa2ddb91452c7606d1969960c","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-3.0.1.tgz","fileCount":4,"integrity":"sha512-01TvEktc68vwbJOtWZluyWeVGWjP+bZwXtPDMQVbBKzbJ/vZBif0L69KH1+cHv1SZ6e0FKLvjyHe8mqsIqYOmw==","signatures":[{"sig":"MEUCIACUwDsIruTetaghA90SDSxvMt6KDSFExdQnCuRBSPfSAiEA6RKjMahFqw1a2dmrJGfnjwyoQNVMdf9KNJtSEAoGC38=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6330,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGfywACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqG0Q//TrOKE6uHFKZxoS/TacJ7t0VphBGJlSpg/tnEodFJnR7S5+Ov\r\nJZVZVUDgQba2ZDAOvFd16SzXZTiBkg8VI9AMLPTjTVWqNGWLicORWGznYYW2\r\nRzPQXzVrHRpC81cri7brCCtZ4kkP9qf8cNnwRjeDTqKnTb/zlojWO1GU4Kfl\r\n8TnZfM2M8uJV6s6HXGKO6FxgUI/sIwxKOr3/0qeyh5+yb++aFtmqzP55a2bY\r\nnYFfg40CvYpOwMiXz3nIp99BDTPuhIhDbECgdnZOoXTRPqRR1RLz7jSqeqS/\r\nAumnUMm67PLAPPC6IQY1xV5zaCE3cjSOzCC8sM7sFzZ4qz8aJ+NcmL+2MqMS\r\n+olhFTgfxR8qsu4fLDH3SGNnFTo/2iMleMs/sgkhcAjEpcdrvlGTfa5OA/L9\r\nEfMDfua3o8BZHQevhjMVedtZuDU4wFv98rHFp54DQ0j72n/alelzhsAkVVWe\r\n1qnoWapE4lJbEFRukZoxbH1YHTlg9oa7j7w1o8ZlvDsVOruyaMoB/TSM/MQp\r\n8fkYVuXdT3fT8vR/OS33/Ne88UWnKEEFnjFXK7bQdYgej6hfDodf/fWPPJxT\r\nP6TdlD+cN/e8JDsSltzHfW+Ybj840D8fmEgbZKhJoKUUIsH8v9q1WJs5pB9x\r\ne4NrDS4MT0ZweeEVUGMjYatoARtDzDcQP04=\r\n=fG3Q\r\n-----END PGP SIGNATURE-----\r\n","size":2931,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-3.0.1.tgz"},"main":"lib","engines":{"node":"^14.17.0 || ^16.13.0 || >=18.0.0"},"scripts":{"lint":"eslint \"**/*.js\"","snap":"tap","test":"tap","lintfix":"npm run lint -- --fix","postlint":"template-oss-check","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"_npmUser":{"name":"gar","email":"gar+npm@danger.computer"},"repository":{"url":"git+https://github.com/npm/parse-conflict-json.git","type":"git"},"_npmVersion":"9.6.1","description":"Parse a JSON string that has git merge conflicts, resolving if possible","directories":{},"templateOSS":{"version":"4.12.0","//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten."},"_nodeVersion":"18.13.0","dependencies":{"just-diff":"^6.0.0","just-diff-apply":"^5.2.0","json-parse-even-better-errors":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.0.1","@npmcli/template-oss":"4.12.0","@npmcli/eslint-config":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/parse-conflict-json_3.0.1_1679424687909_0.3349093562856711","host":"s3://npm-registry-packages"},"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":1679424688067,"_cnpm_publish_time":1679424688067,"dist-tags":{"latest":"6.0.0"}}