{"name":"parse-conflict-json","version":"1.1.0","author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"ISC","_id":"parse-conflict-json@1.1.0","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":"93d7c5e86badffbd7249411250737e5a175b1294","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-1.1.0.tgz","fileCount":4,"integrity":"sha512-l9DnPN7S2TDgSm/KklvxUDkV8QMqfTLaIniSSUpY1Wbm+0Dc4qonmCC3hnVhmtJgVLQNIX0O9pOBIkkubjo9wQ==","signatures":[{"sig":"MEQCIBvPASM2GOUtUf24VUOyiB2+XVU55EyUsm0AbFdEOBfpAiBTiw3LTdK2GeyZx/P0UblKXWPoXnjqrbwb4ATWq6SgzQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5587,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDP43CRA9TVsSAnZWagAAzgQQAKIknbqjxQ/j4ZQuz6jn\niocigNkxw8jtLSi/FeSKI8C8aCZvOfEC0xVAZlKnZHeqkmaBH8ciL7F4wxEW\ndmY7nDI7adZMFleHXV8ZTY3ywj42I3O4NOU4r7jK+nTv8peitP32UjD+zw/l\nnXw61etYPAZfRtaJZWaxH8nMK6jIHzp2V9tKOInKv+gHO5JrM1oLjfZGmhKP\nrn+I/MyIWhHuSSK8WRQQMys5rkYlrBpzli8zfwRjYycguwZP+3BDuYAoC3al\n7FLFPhpXK0N37XG2wJ4ulkTGUdzs5pXbJGIDcuPIacoeChJfAyh4biTgHYUI\n/FRHArQll097TBEcEeWTYvub4x4Hs4GhdQv+frOQN7Tieriw5SRrgvAN5QPu\nGa1MiXKu9+rf7qfmbLnQRzwrsMkgP1idYPOokB4fidgvLGqCe6AvYxje0eHJ\nmrQzkEHTclBqUKIkA5WrMQcyFEXdQDFzpf0MrUZQDLd8I7ubJrZgB7LVEIFy\nXtaeJTReaQBw9bhe2PJhsOZtF1m9kt6/ilJsK7IXaSJBUXCm6XAJfCJtvdaF\nIwutZoZMURxYV6CraW+gHploUfvzLzc7N2h9+Jqkgg5NydtyDpBViyeRVOTZ\n7+0Ipo4gmvw6mdzmT9xVfK5FfiPbbb17lbvGsHrlDWYoBUviXEtxCbsYKlqw\nikjm\r\n=dh2j\r\n-----END PGP SIGNATURE-----\r\n","size":2661,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-1.1.0.tgz"},"gitHead":"d9d0a02bb140445bae53b5a395cda2e551200b90","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.14.5","description":"Parse a JSON string that has git merge conflicts, resolving if possible","directories":{},"_nodeVersion":"14.2.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.1.0_1594687030640_0.5935731346955817","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":1594687030800,"_cnpm_publish_time":1594687030800,"dist-tags":{"latest":"6.0.0"}}