{"name":"json-patch","author":{"name":"Byron Ruth","email":"b@devel.io"},"version":"0.4.2","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.7.1"},"bugs":{"url":"https://github.com/bruth/jsonpatch-js/issues"},"homepage":"https://github.com/bruth/jsonpatch-js","_id":"json-patch@0.4.2","_shasum":"1eadcbda7d1275c624077b915ae28cd71913c52b","_from":".","_npmVersion":"1.4.10","_npmUser":{"name":"bruth","email":"b@devel.io"},"maintainers":[{"name":"bruth","email":"b@devel.io"}],"dist":{"shasum":"1eadcbda7d1275c624077b915ae28cd71913c52b","tarball":"http://registry-npm.ywwl.com/json-patch/download/json-patch-0.4.2.tgz","integrity":"sha512-vS6M1YHCD6E0TlSofIQOC/8UFyqx9GkdyvyysxV4UL9fyzWWosXFkmyUV0Ho/UdW/O2zB5Bs6LexbGZiiQQ/RA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCM0UZdX1PBXorgXWhn/z/+/WY5w6itylpN2YbGxRJxpwIgauX7Y4YPldRoGvd55PO/SHplw9SbF8kGGK6E3UA65QU="}],"size":7792,"noattachment":false,"key":"/json-patch/-/json-patch-0.4.2.tgz"},"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":1403430552833,"_cnpm_publish_time":1403430552833,"dist-tags":{"latest":"0.7.0"}}