{"name":"parse-conflict-json","version":"2.0.0","author":{"name":"GitHub Inc."},"license":"ISC","_id":"parse-conflict-json@2.0.0","maintainers":[{"name":"fritzy","email":"fritzy@github.com"},{"name":"darcyclarke","email":"darcy@darcyclarke.me"},{"name":"ruyadorno","email":"ruyadorno@hotmail.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":{"check-coverage":true},"dist":{"shasum":"bc38debd49609614723980547a3866ad4f1e45a3","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-2.0.0.tgz","fileCount":4,"integrity":"sha512-rqslbAGNjg1hayV9MinHdM1IdBntXqF0wGqiC2oCXvi0Z94awZ419vXPcI4V4m+r7eojjSAIKHYlcuWk9Zd0wg==","signatures":[{"sig":"MEQCIByQyBrgwEskU7gA5Gy2AYykbfW2nhjLuP1sb7yNlUynAiApgPetOUN2lLYW0fJacb8X/FvIvRuXAJH1TCY77/CFoQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6201,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhsRwtCRA9TVsSAnZWagAAV5cP/3qRuWDAnL9riayI2s2L\n94tZDSwELs6867xSkPikjJ9Yhak0eRyeuU0S2klcIet4rGNOtSQeV75djTP2\nojQNkPz/HZqQ5SIHihFYgkZwlKCdkHoxUEaDMLJAsZfqb2GOsOaQe0gf8A9E\nDwEu0BP3B9PGqqmwa+6EXuzW2oIdluswZJK3l9kODt+e9iPCLu4bSOMxCNcD\nIAHCrD3qfU3rDkbG6eEEw1VTG/HCNeHnFg/fKAV0GbsLpxPOZiw1KPgLgZnx\nMdDvbsgfDXH4zGrpSn4B7RZF/wHLPICYxD1mu+c3DN/SohMogPzIy1wDitIE\nHV6BEP/dTcOwqLFdaCXJaL3KXOK9CpPin5QPmVuf3uk7LVV1jJIQU5xEH7CM\n0ruAyt0rygk/nrdE+jpXCQT8hS9ydsEbDb0qNc7C/np1wDbPp6NmNv27T3Y6\nGscnjvNFOZQtBZ6fLKQx+hkXVjd1pAtNPu5mcgQSOxORpEvHnWB6RQoaetJf\nUW3vIUWqezqgjoTGmvsUCJvDXavRx9lRAewZLcy9c0TjAXcIve3HL/rvUsiK\n5wJEqykliT7UBMpb22AmuyhIttIPgNqDUFccYUN8ztuqVsUJJYjVQ6YuSWoF\n1ujEZsI5mrFSbKH2xrdWxbmMpiwhdxp16Rql4J8KIYpAaiJeTqucaWPxceKd\nvYfa\r\n=HxAz\r\n-----END PGP SIGNATURE-----\r\n","size":2880,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-2.0.0.tgz"},"main":"lib","engines":{"node":"^12.13.0 || ^14.15.0 || >=16"},"gitHead":"a1483d85b12f2e5a90356a3d42db285f443ef909","scripts":{"lint":"eslint '**/*.js'","snap":"tap","test":"tap","lintfix":"npm run lint -- --fix","postlint":"npm-template-check","posttest":"npm run lint","preversion":"npm test","postpublish":"git push origin --follow-tags","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"gar","email":"gar+npm@danger.computer"},"repository":{"url":"git+https://github.com/npm/parse-conflict-json.git","type":"git"},"_npmVersion":"8.2.0","description":"Parse a JSON string that has git merge conflicts, resolving if possible","directories":{},"_nodeVersion":"16.13.0","dependencies":{"just-diff":"^5.0.1","just-diff-apply":"^4.0.1","@npmcli/template-oss":"^2.3.1","json-parse-even-better-errors":"^2.3.1"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^15.1.5"},"templateVersion":"2.3.1","_npmOperationalInternal":{"tmp":"tmp/parse-conflict-json_2.0.0_1638997037116_0.9554681862104208","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":1638997037269,"_cnpm_publish_time":1638997037269,"dist-tags":{"latest":"6.0.0"}}