{"name":"parse-conflict-json","version":"2.0.1","author":{"name":"GitHub Inc."},"license":"ISC","_id":"parse-conflict-json@2.0.1","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":"76647dd072e6068bcaff20be6ccea68a18e1fb58","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-2.0.1.tgz","fileCount":4,"integrity":"sha512-Y7nYw+QaSGBto1LB9lgwOR05Rtz5SbuTf+Oe7HJ6SYQ/DHsvRjQ8O03oWdJbvkt6GzDWospgyZbGmjDYL0sDgA==","signatures":[{"sig":"MEUCICmiPHz3kGhNneerp1yhCjYulVUX/3FrKgk4u93arxaXAiEAsqBhwnPLJl8MT7//Uerz/UlfwshrcmNCa929mzVxHAE=","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\nwsFcBAEBCAAQBQJhsR3TCRA9TVsSAnZWagAApoEP/jcg36R6FI6nz0lXcRBq\nkuyuXdZCofQQgUvXjRNxGkbnx+fpLLvWXj1cVDlYm2YLN63xgfytfxl08hk6\neoN4Hvdd+O0YrPVGDljVWqGZQbhe80BoHKHkES7BKbsCUb9cDNjGRmXWKmCs\nlpBXP6vUe4Y9of6bmBfz1ob2jFQGVWiFm2poLqZyVr6wwdyH1OYMCgPR5U8p\n+OPyN0dC6g6xyU6rJIFZhIAKrTb/3TPVOtncbZ9s8GfjfubFBtk0A/ixquen\nVjwLv0L8xbeJ1vyDM2DvOw6lQicAG5WLio8kQ8OQHUGcPxvU+1tnMLlgkhJU\nF30++KJSu6cHu0e6oW7fVf9b7WlSDng4jNYKEogR+gKMmP9v+ECed8+B4o5B\n9lGz95P97M0t4j0n8PKd7kL5L1lzOR7sz0TFwOPNKGloksRVrDH77UDnfQr7\n4O0JdqCw0ZApcRrjauJD7LC5pkPoARy8e7hTGSVX6tRnfCjCm2auMNaPlbTW\nxhGDjnSDSlQSlX9hnOVvee0nOLozmSrEBZdGsTm/wiPNuFUAuI1g/4xY55iv\nL/GYB4KBzAgfkQi5GesZSwcTAUbze+HHy3DfeBYDgh0d3Io6AzB3Hm3rs96u\nPFDHhHUhax5i5eeM/gcdMz+TNdrzRxw3dUaM9bpr4c0gEaY/08L9H5aYnhnI\ntrT9\r\n=/SEV\r\n-----END PGP SIGNATURE-----\r\n","size":2879,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-2.0.1.tgz"},"main":"lib","engines":{"node":"^12.13.0 || ^14.15.0 || >=16"},"gitHead":"3818d0e7996e493c97e2d9f1b1d36d9f2d7053bf","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","json-parse-even-better-errors":"^2.3.1"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^15.1.5","@npmcli/template-oss":"^2.3.1"},"templateVersion":"2.3.1","_npmOperationalInternal":{"tmp":"tmp/parse-conflict-json_2.0.1_1638997459503_0.9041228806333315","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":1638997459919,"_cnpm_publish_time":1638997459919,"dist-tags":{"latest":"6.0.0"}}