{"name":"parse-conflict-json","version":"1.1.1","author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"ISC","_id":"parse-conflict-json@1.1.1","maintainers":[{"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":"54ec175bde0f2d70abf6be79e0e042290b86701b","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-1.1.1.tgz","fileCount":4,"integrity":"sha512-4gySviBiW5TRl7XHvp1agcS7SOe0KZOjC//71dzZVWJrY9hCrgtvl5v3SyIxCZ4fZF47TxD9nfzmxcx76xmbUw==","signatures":[{"sig":"MEUCIQCQCezR3xoXYQcy21VZxWXF3Qj8uFQRDl3oA1kWKF41MAIgNY09rH9rfX84DHfuMoFmeEoDrT/Gn/1Rd2wSIuIj3Dc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5597,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPusbCRA9TVsSAnZWagAAnAEP/1MvPo0lkSszA+3Z7JBX\n+xxaEhuntuK3KE2WX5Vj9CSU8XqVSxYx3iOOxs0bGNiGrewTZu5QRT8LMp8p\nV2EZ5tc6R8AsVPlWkrjnP2Ew0dqRyEFohwU9HLEBzXDDY+yUwRZMxkMS/WgG\nyt/2LxaBMvx+GTIqd25jsljCvz/gGsGO4z/MryGF8YCiknEn3XuxbqdR2t2o\neKm/DFl98o9++KZEGbescSBCJY0F3stLkkDhZbQRm7iX0iqfOp7nLJZVtLIM\nIjyTngfW77JtuHCwFy5yQsXU/fZ3/FvaYc/zqt9Ln/BsVbnzUx8cvjkgz6uY\nZk+I1nX+RT3K/s2WUlb7lBnSbt2mrz5IFXzt6o0zojPWbXQik1vXo55HRDqx\nxGEckUhRwtgF3tr7VgfJiozDOJTLGUfHNqP9uf5qzQ5v2otmdKePqVWBSFLR\nvuphHtBKpzlXW82eN4xqo8uT/SfFFIvTrpntlvbO64/VQZzJLpq5vNp0mm0t\n2FUWB0W7h21QymziiX/BAMvmfG6EqbrSeZjqOs82ndVJdrEyYkuAREq0+UU9\n2Raw86Xpg/86YL0+ypCOHlaaDlXQISTE5MbR6YfEEkDSLJz5KGzf1PSxYZZe\nNpm/S3huycGSAfbZy4T9iQxsVfBeld9FfdeAM16zjIsuH8+NTF3RsnlnnQ3B\n+AZg\r\n=Na6C\r\n-----END PGP SIGNATURE-----\r\n","size":2667,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-1.1.1.tgz"},"gitHead":"0d3265f821c67ec475b85aac6cff359eaea8bf78","scripts":{"snap":"tap","test":"tap","preversion":"npm test","postpublish":"git push origin --follow-tags","postversion":"npm publish"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"repository":{"url":"git+https://github.com/npm/parse-conflict-json.git","type":"git"},"_npmVersion":"7.0.0-beta.5","description":"Parse a JSON string that has git merge conflicts, resolving if possible","directories":{},"_nodeVersion":"14.8.0","dependencies":{"just-diff":"^3.0.1","just-diff-apply":"^3.0.0","json-parse-even-better-errors":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^14.6.1"},"_npmOperationalInternal":{"tmp":"tmp/parse-conflict-json_1.1.1_1597958938711_0.9859568921054687","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":1597958938814,"_cnpm_publish_time":1597958938814,"dist-tags":{"latest":"6.0.0"}}