{"name":"parse-conflict-json","version":"3.0.0","author":{"name":"GitHub Inc."},"license":"ISC","_id":"parse-conflict-json@3.0.0","maintainers":[{"name":"fritzy","email":"fritzy@github.com"},{"name":"darcyclarke","email":"darcy@darcyclarke.me"},{"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":{"nyc-arg":["--exclude","tap-snapshots/**"],"check-coverage":true},"dist":{"shasum":"eb266cbeeb66e73c3e92806da4d4ace3b798acff","tarball":"http://registry-npm.ywwl.com/parse-conflict-json/download/parse-conflict-json-3.0.0.tgz","fileCount":4,"integrity":"sha512-ipcKLCmZbAj7n+h9qQREvdvsBUMPetGk9mM4ljCvs5inZznAlkHPk5XPc7ROtknUKw7kO6Jnz10Y3Eec7tky/A==","signatures":[{"sig":"MEUCIEBCqNiW07Vj3KKheu20lO57qWuT3aryRl032Dt4oIZFAiEA1Yue0ZB2BN5q9yj3YJ26jqEwUNNDb+YzxkTSQkFLGFA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6328,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjSPIsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo/LA/9HmCX16zqpeJkvq5t9zsLA3mE4PmnvbVbzueyaw6NZhpdb40Q\r\nysAdnxhE8mOZTytt70oTP/5jNccjojwPmqdLmVnX63refSBmagMgW7Riwser\r\n42UoFiqTfHBzcOPb6oexEd/U4nK5qqR/8S3ssHi3iS68KVjqK9fDmK4rrwij\r\nvneEcgZNGjFMn4Mkkbqe4WlhiTU7lfsXQfl3iL2vGhChWOF7oph4bWGenS/X\r\nyr3yvkeNzIhQetWdE7pQ3JapLwiBKn5LfnXyU2vCMx8fXXDcFhoG62y3YKSk\r\njY9lBjj0xtE1Sir0RXdxnyC2FLRuxPj5QiLoJVZP4T1yUDdp7FTI8d72BKho\r\ndrkoTlYkDc0aXYB9dMsPBqbIuZykNhS3vMJI5w4rle6f69NIkC0fE1NuZgDA\r\nP/MQJz6onvRAfwrqO9mvS6xJiy/snpGKb3g6y76QHkuSkMFSZU53osF5vufq\r\nAywHcut8Tih/+H8fDk+jewXF7sIDwG9wYJ1/K2SN5AWBX5NeLhfdIRtOlKHU\r\nPByr1CxsglZf/Ek8h4o49ymEMArZKZQHC54SX+zHk6b9m3UO6CdqSu6bKN1L\r\n7aYx5/97CcERRb8tRkeAwKwJpc5hyV8ih1fMbSNs8TIMfdqFsGeXiqm0rB2I\r\nups2XmV83qdH1kdLENfea8n2/d2jDBpMe1M=\r\n=oNel\r\n-----END PGP SIGNATURE-----\r\n","size":2926,"noattachment":false,"key":"/parse-conflict-json/-/parse-conflict-json-3.0.0.tgz"},"main":"lib","engines":{"node":"^14.17.0 || ^16.13.0 || >=18.0.0"},"gitHead":"708bbe1e24371c2dfa55aff950707bbb8afdc9f9","scripts":{"lint":"eslint \"**/*.js\"","snap":"tap","test":"tap","lintfix":"npm run lint -- --fix","postlint":"template-oss-check","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"_npmUser":{"name":"lukekarrys","email":"luke@lukekarrys.com"},"repository":{"url":"git+https://github.com/npm/parse-conflict-json.git","type":"git"},"_npmVersion":"8.19.2","description":"Parse a JSON string that has git merge conflicts, resolving if possible","directories":{},"templateOSS":{"version":"4.5.1","//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten."},"_nodeVersion":"18.10.0","dependencies":{"just-diff":"^5.0.1","just-diff-apply":"^5.2.0","json-parse-even-better-errors":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.0.1","@npmcli/template-oss":"4.5.1","@npmcli/eslint-config":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/parse-conflict-json_3.0.0_1665724972145_0.41215624601516176","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":1665724972351,"_cnpm_publish_time":1665724972351,"dist-tags":{"latest":"6.0.0"}}