{"id":16398664,"url":"https://github.com/ken107/jsonpatch-observe","last_synced_at":"2025-07-06T16:03:53.413Z","repository":{"id":34397232,"uuid":"38324882","full_name":"ken107/jsonpatch-observe","owner":"ken107","description":"Observe objects recursively for changes and generate JSON Patches","archived":false,"fork":false,"pushed_at":"2024-06-19T02:09:50.000Z","size":734,"stargazers_count":8,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-25T02:05:35.878Z","etag":null,"topics":["data-binding","firebase","harmony-proxies","json","json-patch","json-rpc"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ken107.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-30T18:05:34.000Z","updated_at":"2025-01-25T16:57:51.000Z","dependencies_parsed_at":"2024-05-14T05:26:52.091Z","dependency_job_id":"ce1683a2-3cea-42c6-8b3b-f1b1aae4a90e","html_url":"https://github.com/ken107/jsonpatch-observe","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ken107/jsonpatch-observe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fjsonpatch-observe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fjsonpatch-observe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fjsonpatch-observe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fjsonpatch-observe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ken107","download_url":"https://codeload.github.com/ken107/jsonpatch-observe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fjsonpatch-observe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261953199,"owners_count":23235453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-binding","firebase","harmony-proxies","json","json-patch","json-rpc"],"created_at":"2024-10-11T05:13:26.333Z","updated_at":"2025-07-06T16:03:53.386Z","avatar_url":"https://github.com/ken107.png","language":"TypeScript","readme":"Observe an object tree for changes and generate JSON Patches ([RFC 6902](https://tools.ietf.org/html/rfc6902)).  Uses [Harmony Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), available in NodeJS version 6.4 and above.\n\n\n### Usage\n```javascript\nconst {observe} = require(\"jsonpatch-observe\");\n\nlet observable = observe({});\nobservable.$subscribe(patch =\u003e console.log(patch));\nobservable.a = {b:1};\t\t//prints {op:\"add\", path:\"a\", value:{b:1}}\nobservable.a.b = 2;\t\t//prints {op:\"add\", path:\"a/b\", value:2}\ndelete observable.a;\t\t//prints {op:\"remove\", path:\"a\"}\n```\n\nNote that the properties of an Observable are also Observables.  This is how it's able to detect when you do `observable.a.b = 2`.\n\n\n### Unobserved Properties\nYou can exclude certain properties from `observe` as follows:\n```javascript\nrequire(\"jsonpatch-observe\").config.excludeProperty = function(obj, prop) {\n\t//return true to exclude the property\n}\n```\n\n\n### Splice Patch\nThe JSONPatch standard does not specify a \"splice\" operation.  Without splice, Array changes are represented as a series of individual \"add\", \"replace\", and \"remove\" operations, which can be quite inefficient to apply.\n\nThis module supports generating the splice patch.  Enable it as follows:\n```javascript\nrequire(\"jsonpatch-observe\").config.enableSplice = true;\n```\n\nThe splice patch has the following format:\n```javascript\n{\n\top: \"splice\",\n\tpath: \"/myarr/3\",\t\t//path to array index\n\tremove: 2,\t\t\t//number of elements removed\n\tadd: ['a','b','c']\t\t//elements added\n}\n```\n\nI created a [fork](https://github.com/ken107/JSON-Patch) of Starcounter-Jack JSONPatch library capable of consuming this non-standard splice patch.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken107%2Fjsonpatch-observe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fken107%2Fjsonpatch-observe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken107%2Fjsonpatch-observe/lists"}