{"name":"json-patch","author":{"name":"Byron Ruth","email":"b@devel.io"},"version":"0.4.1","description":"A JavaScript implementation of the JSON Media Type for partial modifications: http://tools.ietf.org/html/rfc6902","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"},"bugs":{"url":"https://github.com/bruth/jsonpatch-js/issues"},"homepage":"https://github.com/bruth/jsonpatch-js","_id":"json-patch@0.4.1","dist":{"shasum":"3c7570048dc14f6f24821ac4ee278c1474e4d74e","tarball":"http://registry-npm.ywwl.com/json-patch/download/json-patch-0.4.1.tgz","integrity":"sha512-n8jNGhZeF1P98Yv9DtaeMALOVS2FKYE9Db4IeOaIuXU5Ag4cWakJdwr+WDYVi4K2i6PtekHdj5cn2noiD2qv1A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFFyfwef0QoARy2Ug45HOtWT+jF0RPQ2/5luqT98CfNwIhAOi/2IxZAonHWtBaY8XwB+xembh8BV3mADLjj2beTw+h"}],"size":7692,"noattachment":false,"key":"/json-patch/-/json-patch-0.4.1.tgz"},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"bruth","email":"b@devel.io"},"maintainers":[{"name":"bruth","email":"b@devel.io"}],"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":1391428426881,"_cnpm_publish_time":1391428426881,"dist-tags":{"latest":"0.7.0"}}