{"id":17291177,"url":"https://github.com/ali-master/json-diff-patch","last_synced_at":"2026-01-02T06:49:34.721Z","repository":{"id":249371815,"uuid":"831339975","full_name":"ali-master/json-diff-patch","owner":"ali-master","description":"JsonDiffPatch is a library that allows for the diffing and patching of JSON objects","archived":false,"fork":false,"pushed_at":"2024-07-20T10:03:21.000Z","size":181,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T08:40:12.043Z","etag":null,"topics":["diff","diff-algorithm","json","json-diff-patch"],"latest_commit_sha":null,"homepage":"https://ali-master.github.io/json-diff-patch/","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/ali-master.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","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":"2024-07-20T09:12:30.000Z","updated_at":"2024-07-24T18:46:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"62a3cd2d-4ad6-433b-9f21-6a63bda54b07","html_url":"https://github.com/ali-master/json-diff-patch","commit_stats":null,"previous_names":["ali-master/json-diff-patch"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fjson-diff-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fjson-diff-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fjson-diff-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fjson-diff-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ali-master","download_url":"https://codeload.github.com/ali-master/json-diff-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732293,"owners_count":20338839,"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":["diff","diff-algorithm","json","json-diff-patch"],"created_at":"2024-10-15T10:40:14.694Z","updated_at":"2026-01-02T06:49:34.696Z","avatar_url":"https://github.com/ali-master.png","language":"TypeScript","readme":"# JsonDiffPatch\nJsonDiffPatch is a library that allows for the diffing and patching of JSON objects.\n\n```bash\nnpm install json-diff-patch-v2\n```\n\n1. Import JsonDiffPatch in your project:\n\n```javascript\nimport { DiffPatcher } from 'json-diff-patch-v2';\n```\n\n2. Create a `DiffPatcher` instance:\n\n```javascript\nconst diffPatcher = new DiffPatcher();\n```\n\n3. Use the `diff`, `patch`, and `reverse` methods to work with your JSON objects:\n\n- **Diff**: To find the difference between two objects.\n- **Patch**: To apply a patch to an object.\n- **Reverse**: To reverse a patch.\n\n## Examples\n\n### Diffing Two Objects\n\n```javascript\nconst left = { name: 'John', age: 25 };\nconst right = { name: 'John', age: 26 };\n\nconst delta = diffPatcher.diff(left, right);\nconsole.log(delta);\n// Output: { age: [25, 26] }\n```\n\n### Patching an Object\n\n```javascript\nconst original = { name: 'John', age: 25 };\nconst delta = { age: [25, 26] };\n\nconst patched = diffPatcher.patch(original, delta);\nconsole.log(patched);\n// Output: { name: 'John', age: 26 }\n```\n\n### Using Property Filter\n\nIn scenarios where you want to ignore certain properties during diffing, you can use the `propertyFilter` option.\n\n```javascript\nconst options = {\n  propertyFilter: function(name) {\n    return name.slice(0, 1) !== '$';\n  },\n};\nconst diffPatcherWithFilter = new DiffPatcher(options);\n\nconst left = { data: { $volatile: 123, stable: 456 } };\nconst right = { data: { $volatile: 124, stable: 456 } };\n\nconst delta = diffPatcherWithFilter.diff(left, right);\nconsole.log(delta);\n// Output: undefined (since the change is in a filtered property)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fali-master%2Fjson-diff-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fali-master%2Fjson-diff-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fali-master%2Fjson-diff-patch/lists"}