{"name":"parse-conflict-json","version":"1.0.0","author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"ISC","_id":"parse-conflict-json@1.0.0","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"tap":{"check-coverage":true},"dist":{"shasum":"725e232cf756d4940271aeb39f6554ccc4a6f489","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-1.0.0.tgz","fileCount":10,"integrity":"sha512-ifyNHRk+oxTlrdkZANMyDhzyPlUy0waiJ5Ki3PMmZGqjDoHwqfXtqHHhJRXRJvpfXoQPp5tfZMTiDLVzTrHklw==","signatures":[{"sig":"MEUCIQCdLN6/8Nyv5uYGK5XHgzUxgS3askk3ehdDXrWxUhYK6wIgCg5BzBG7ZUbWRfEv0ftFJ7MumYl8Ivp898CureTxqAk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":126010,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdSy37CRA9TVsSAnZWagAA1xgP/1aMgcOtuipw50zbS4Ky\nIEmI/mXzC/3EJ/OpQhoOCQyReAFHvDK9+89Zq5v2lp2GXxWii1IwDwt1EJ1M\ngpYgiWy+RncxYSagp95wHIGquKz+FRjmi7SkpU0I6n0vAg02fqrNfu9vWQeQ\nknzkw3laowX+lG34HqR3OVw9gago14d/HdmHHxr4cdhpf+hUqpoIJlnxJ7Ra\nh/dcXfkY1cGrP9jmfzP2eKrMgsYUGV9W9iWsrOALcBn+KeQfhcYBzbOlETrZ\niW9O0lnCUReGJdAgyNgnobPqzA0fHU8iWf6pc+14RxQCPPtzSIOPAUAaqZet\nLy+XtsYu1V+GBTYkyBrdgPwqSjnuFN41FbkquAAmL3jn+eJj6vJwDiNTgZsH\nSwvgUaowK6Mun3qyWiZcHUBXQmMZM55z+7vM5wj/pRglUij5mY6F/x06QjcA\n780XT4wf4SWgUhyDyB5mJiKHRpl6p4rk6nQxmw+w0CDQ3BCfVCIflEi7Mtqo\nC5EhgKOyU3oYeDTxY30aykLSW7OR7wFoTKaPMOvTVauQsBXlrMfoBiOqMlYf\n1ijCfPOm3ix97T/u6tTmTglzTsY7zm7OXmU37gUqSdYCM1KOxVct58Fw2vpH\nj9dJ94hbALQwm11sTJm6ztHOlWDakayLv2S3PmumfaibyGxe72RFdtYFvguL\nHR9G\r\n=w9UK\r\n-----END PGP SIGNATURE-----\r\n","size":31622,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-1.0.0.tgz"},"gitHead":"5befd03f167d1bbbda89fc607e8b2730c5a94d74","scripts":{"snap":"tap","test":"tap","preversion":"npm test","postpublish":"git push origin --follow-tags","postversion":"npm publish"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"_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.0_1565208058692_0.005336259628950346","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":1565208058821,"_cnpm_publish_time":1565208058821,"dist-tags":{"latest":"6.0.0"}}