{"name":"json-patch","author":{"name":"Byron Ruth","email":"b@devel.io"},"version":"0.7.0","description":"A JavaScript implementation of the JSON Object Notation (JSON) Patch http://tools.ietf.org/html/rfc6902 and JSON Pointer http://tools.ietf.org/html/rfc6901 specifications.","license":"BSD","keywords":["diff","patch","json","jsonpatch","jsonpointer"],"main":"jsonpatch.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bruth/jsonpatch-js.git"},"devDependencies":{"coffee-script":"^1.12.3"},"gitHead":"3dc98349454f821ab97ab88b5742043686c7b256","bugs":{"url":"https://github.com/bruth/jsonpatch-js/issues"},"homepage":"https://github.com/bruth/jsonpatch-js#readme","_id":"json-patch@0.7.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"bruth","email":"b@devel.io"},"dist":{"integrity":"sha512-9zaGTzsV6Hal5HVMC8kb4niXYQOOcq3tUp0P/GTw6HHZFPVwtCU2+mXE9q59MelL9uknALWnoKrUxnDpUX728g==","shasum":"2598958ea67fa3660dae8ee684d35407b37f4b98","tarball":"http://registry-npm.ywwl.com/json-patch/download/json-patch-0.7.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID2MwPs3GoowZ6YKc36jArNdMUi05sf5PbwVqW8yi7lFAiEAxavnWNyGaLsOQN4hR2oGgs4d2aqjHA+9sGjkIstAOR0="}],"size":8190,"noattachment":false,"key":"/json-patch/-/json-patch-0.7.0.tgz"},"maintainers":[{"name":"bruth","email":"b@devel.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-patch-0.7.0.tgz_1503337846195_0.18203770648688078"},"readme":"# jsonpatch-js\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/bruth/jsonpatch-js/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\nLibrary to apply JSON Patches in JavaScript\n\n- JSON Patch - http://tools.ietf.org/html/rfc6902\n- JSON Pointer - http://tools.ietf.org/html/rfc6901\n\njsonpatch-js works as in the browser as a script, as a Node module and as an\nAMD module.\n\n## Install\n\n**Bower**\n\n```\nbower install json-patch\n```\n\n**NPM**\n\n```\nnpm install json-patch\n```\n\n**Note: at this time, all operations are applied in-place.**\n\n## Methods\n\n**`jsonpatch.apply(document, patch)`**\n\nApplies a patch to the document\n\n**`jsonpatch.compile(patch)`**\n\nCompiles a patch and returns a function that takes a document to apply the patch to.\n\n## Patch Operations\n\n### Add\n\nPatch syntax: `{op: 'add', path: <path>, value: <value>}`\n\n```javascript\n// Add property, result: {foo: 'bar'}\njsonpatch.apply({}, [{op: 'add', path: '/foo', value: 'bar'}]);\n\n// Add array element, result: {foo: [1, 2, 3]}\njsonpatch.apply({foo: [1, 3]}, [{op: 'add', path: '/foo/1', value: 2}]);\n\n// Complex, result: {foo: [{bar: 'baz'}]}\njsonpatch.apply({foo: [{}]}, [{op: 'add', path: '/foo/0/bar', value: 'baz'}]);\n```\n\n### Remove\n\nPatch syntax: `{op: 'remove', path: <path>}`\n\n```javascript\n// Remove property, result: {}\njsonpatch.apply({foo: 'bar'}, [{op: 'remove', path: '/foo'}]);\n\n// Remove array element, result: {foo: [1, 3]}\njsonpatch.apply({foo: [1, 2, 3]}, [{op: 'remove', path: '/foo/1'}]);\n\n// Complex, result: {foo: [{}]}\njsonpatch.apply({foo: [{bar: 'baz'}]}, [{op: 'remove', path: '/foo/0/bar'}]);\n```\n\n### Replace\n\nPatch syntax: `{op: 'replace', path: <path>, value: <value>}`\n\n```javascript\n// Replace property, result: {foo: 1}\njsonpatch.apply({foo: 'bar'}, [{op: 'replace', path: '/foo', value: 1}]);\n\n// Replace array element, result: {foo: [1, 4, 3]}\njsonpatch.apply({foo: [1, 2, 3]}, [{op: 'replace', path: '/foo/1', value: 4}]);\n\n// Complex, result: {foo: [{bar: 1}]}\njsonpatch.apply({foo: [{bar: 'baz'}]}, [{op: 'replace', path: '/foo/0/bar', value: 1}]);\n```\n\n### Move\n\nPatch syntax: `{op: 'move', from: <path>, path: <path>}`\n\n```javascript\n// Move property, result {bar: [1, 2, 3]}\njsonpatch.apply({foo: [1, 2, 3]}, [{op: 'move', from: '/foo', path: '/bar'}]);\n```\n\n### Copy\n\nPatch syntax: `{op: 'copy', from: <path>, path: <path>}`\n\n```javascript\n// Copy property, result {foo: [1, 2, 3], bar: 2}\njsonpatch.apply({foo: [1, 2, 3]}, [{op: 'copy', from: '/foo/1', path: '/bar'}]);\n```\n\n### Test\n\nPatch syntax: `{op: 'test', path: <path>, value: <value>}`\n\n```javascript\n// Test equality of property to value, result: true\njsonpatch.apply({foo: 'bar'}, [{op: 'test', path: '/foo', value: 'bar'}]\n```\n\n*Changed in 0.5.0*\n\nThe return value is no longer a boolean, but now the the document itself which adheres correctly to the specification. It the test fails, a `PatchTestFailed` error will be thrown.\n\n## Error Types\n\n**`JSONPatchError`**\n\nBase error type which all patch errors extend from.\n\n**`InvalidPointerError`**\n\nThrown when the pointer is invalid.\n\n**`InvalidPatchError`**\n\nThrown when the patch itself has an invalid syntax.\n\n**`PatchConflictError`**\n\nThrown when there is a conflic with applying the patch to the document.\n\n**`PatchTestFailed`**\n\nThrown when a test operation is applied and fails.\n","publish_time":1503337847140,"_cnpm_publish_time":1503337847140,"dist-tags":{"latest":"0.7.0"}}