{"name":"parse-conflict-json","version":"1.0.1","author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"ISC","_id":"parse-conflict-json@1.0.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":"780b559bda5d6fd64846291dde9a38704a2132d2","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-1.0.1.tgz","fileCount":4,"integrity":"sha512-htogfp+nUg/kCA7SnyH6Z0ZRAp6Pij1pgGeXWpbXCFCEdlC1S/sGcu6bUScj3cr140PU5fGKzjwm5i5rdQBWCw==","signatures":[{"sig":"MEQCIEs4k6Uqvx47EdoH7nXPeX3Hlhk7fn7RzJLMNw/zDPUTAiA5TT8WmHKPpu5zsiHDBobWqcDRXtzXClKFuX+u7SSP3Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5477,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdTQumCRA9TVsSAnZWagAAZjAP/1GA+xHDleoEorL++O7X\n93pkE9j8ioJWtrALS7s+0M4oYzvG1R3CxI2B3cf4cAeJcNQpeeUFbkUzcm9N\nqTGhclYdLYluNVnweFD7G0qNaYU0/YkuC+r365w4UJ0JWz3lQOvbY50obfvX\n5KL8yP8dyEJhVeJxsoq8yEbkAjZrdrZ1XyPAcMSc93NlXIZuSDX4gM0WSnnU\nulKrsSXWZutHrNY1WXaTRbXt0t2t2RX29BQ2fVZlId/N63TTC6WIZU68agwK\n/uYoJM4y/sozuQX48q8SzYz51INvirWrd+ccGecfhgLziiN9kjHT4kZe82vx\nU7NBY11jThhV56wdHfD6md3AsABn3fecL4sU5OjdDmpnDdUllEl1b/3Jj5W1\nn0GrBFgJmFG+AXjPR8DoDDTJjAs2qzsvM4SgHIQ50KvECqJr/q+pH47RQ08W\nJ+YOhV8i/9+l/kGCcS5asABzWsJiCgAM49o2MxRFqB+o3y6y54nuPHdmesKM\n5lhbKaU4URo9eB0EfMG5gH7Dq9/vwFRg1Fnx9Ii/pgQ+ZYKxBavl75lSEEw+\nRP/CTmol3iHUHXW54iFoqOZ/eEar9eHyTuoY9YTzT2vUgHXT8f7hRzWmggAx\nDG01Jb9nMMk7v4+vlKZz3z+zjhZIr30fOG5S6rkf+OoQuBgWDGZojrItSIjj\nPqQQ\r\n=zGmv\r\n-----END PGP SIGNATURE-----\r\n","size":2605,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-1.0.1.tgz"},"gitHead":"4ef9e12063132499a7e08529c2ee709452465782","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":"6.10.3","description":"Parse a JSON string that has git merge conflicts, resolving if possible","directories":{},"_nodeVersion":"12.6.0","dependencies":{"just-diff":"^3.0.1","just-diff-apply":"^3.0.0","json-parse-better-errors":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^14.6.1"},"_npmOperationalInternal":{"tmp":"tmp/parse-conflict-json_1.0.1_1565330341839_0.2392140954416646","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":1565330341957,"_cnpm_publish_time":1565330341957,"dist-tags":{"latest":"6.0.0"}}