{"id":13484276,"url":"https://github.com/mattphillips/deep-object-diff","last_synced_at":"2025-05-14T07:08:23.262Z","repository":{"id":40139108,"uuid":"74713360","full_name":"mattphillips/deep-object-diff","owner":"mattphillips","description":"Deep diffs two objects, including nested structures of arrays and objects, and returns the difference. ❄️","archived":false,"fork":false,"pushed_at":"2024-03-04T12:06:22.000Z","size":182,"stargazers_count":1104,"open_issues_count":35,"forks_count":96,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-12T05:42:11.968Z","etag":null,"topics":["array","deep","diff","nested-structures","object"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/deep-object-diff","language":"JavaScript","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/mattphillips.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["mattphillips"]}},"created_at":"2016-11-25T00:34:54.000Z","updated_at":"2025-04-29T13:56:43.000Z","dependencies_parsed_at":"2023-02-19T19:45:43.922Z","dependency_job_id":"a927b853-5145-47c9-8ac3-5eb24f517894","html_url":"https://github.com/mattphillips/deep-object-diff","commit_stats":{"total_commits":114,"total_committers":10,"mean_commits":11.4,"dds":0.5789473684210527,"last_synced_commit":"a24d61fea6d6d644fc3e32a853f685953d6d5b41"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattphillips%2Fdeep-object-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattphillips%2Fdeep-object-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattphillips%2Fdeep-object-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattphillips%2Fdeep-object-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattphillips","download_url":"https://codeload.github.com/mattphillips/deep-object-diff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092662,"owners_count":22013290,"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":["array","deep","diff","nested-structures","object"],"created_at":"2024-07-31T17:01:21.714Z","updated_at":"2025-05-14T07:08:23.241Z","avatar_url":"https://github.com/mattphillips.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003edeep-object-diff\u003c/h1\u003e\n\n  ❄️\n\n  Deep diff two JavaScript Objects\n\u003c/div\u003e\n\n\u003chr /\u003e\n\n[![Build Status](https://github.com/mattphillips/deep-object-diff/actions/workflows/ci.yaml/badge.svg)](https://github.com/mattphillips/deep-object-diff/actions/workflows/ci.yaml)\n[![Code coverage](https://codecov.io/gh/mattphillips/deep-object-diff/branch/main/graph/badge.svg?token=EwnXzDGW3x)](https://codecov.io/gh/mattphillips/deep-object-diff)\n[![version](https://img.shields.io/npm/v/deep-object-diff.svg?style=flat-square)](https://www.npmjs.com/package/deep-object-diff)\n[![downloads](https://img.shields.io/npm/dm/deep-object-diff.svg?style=flat-square)](http://npm-stat.com/charts.html?package=deep-object-diff\u0026from=2016-11-23)\n[![MIT License](https://img.shields.io/npm/l/deep-object-diff.svg?style=flat-square)](https://github.com/mattphillips/deep-object-diff/blob/master/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\nA small library that can deep diff two JavaScript Objects, including nested structures of arrays and objects.\n\n## Installation\n`yarn add deep-object-diff`\n\n`npm i --save deep-object-diff`\n\n## Functions available:\n - [`diff(originalObj, updatedObj)`](#diff)\n returns the difference of the original and updated objects\n\n - [`addedDiff(original, updatedObj)`](#addeddiff)\n returns only the values added to the updated object\n\n - [`deletedDiff(original, updatedObj)`](#deleteddiff)\n returns only the values deleted in the updated object\n\n - [`updatedDiff(original, updatedObj)`](#updateddiff)\n returns only the values that have been changed in the updated object\n\n - [`detailedDiff(original, updatedObj)`](#detaileddiff)\n returns an object with the added, deleted and updated differences\n\n## Importing\n\n``` js\nimport { diff, addedDiff, deletedDiff, updatedDiff, detailedDiff } from 'deep-object-diff';\n```\n\n## Usage:\n\n### `diff`:\n```js\nconst lhs = {\n  foo: {\n    bar: {\n      a: ['a', 'b'],\n      b: 2,\n      c: ['x', 'y'],\n      e: 100 // deleted\n    }\n  },\n  buzz: 'world'\n};\n\nconst rhs = {\n  foo: {\n    bar: {\n      a: ['a'], // index 1 ('b')  deleted\n      b: 2, // unchanged\n      c: ['x', 'y', 'z'], // 'z' added\n      d: 'Hello, world!' // added\n    }\n  },\n  buzz: 'fizz' // updated\n};\n\nconsole.log(diff(lhs, rhs)); // =\u003e\n/*\n{\n  foo: {\n    bar: {\n      a: {\n        '1': undefined\n      },\n      c: {\n        '2': 'z'\n      },\n      d: 'Hello, world!',\n      e: undefined\n    }\n  },\n  buzz: 'fizz'\n}\n*/\n```\n\n### `addedDiff`:\n```js\nconst lhs = {\n  foo: {\n    bar: {\n      a: ['a', 'b'],\n      b: 2,\n      c: ['x', 'y'],\n      e: 100 // deleted\n    }\n  },\n  buzz: 'world'\n};\n\nconst rhs = {\n  foo: {\n    bar: {\n      a: ['a'], // index 1 ('b')  deleted\n      b: 2, // unchanged\n      c: ['x', 'y', 'z'], // 'z' added\n      d: 'Hello, world!' // added\n    }\n  },\n  buzz: 'fizz' // updated\n};\n\nconsole.log(addedDiff(lhs, rhs));\n\n/*\n{\n  foo: {\n    bar: {\n      c: {\n        '2': 'z'\n      },\n      d: 'Hello, world!'\n    }\n  }\n}\n*/\n```\n\n### `deletedDiff`:\n```js\nconst lhs = {\n  foo: {\n    bar: {\n      a: ['a', 'b'],\n      b: 2,\n      c: ['x', 'y'],\n      e: 100 // deleted\n    }\n  },\n  buzz: 'world'\n};\n\nconst rhs = {\n  foo: {\n    bar: {\n      a: ['a'], // index 1 ('b')  deleted\n      b: 2, // unchanged\n      c: ['x', 'y', 'z'], // 'z' added\n      d: 'Hello, world!' // added\n    }\n  },\n  buzz: 'fizz' // updated\n};\n\nconsole.log(deletedDiff(lhs, rhs));\n\n/*\n{\n  foo: {\n    bar: {\n      a: {\n        '1': undefined\n      },\n      e: undefined\n    }\n  }\n}\n*/\n```\n\n### `updatedDiff`:\n```js\nconst lhs = {\n  foo: {\n    bar: {\n      a: ['a', 'b'],\n      b: 2,\n      c: ['x', 'y'],\n      e: 100 // deleted\n    }\n  },\n  buzz: 'world'\n};\n\nconst rhs = {\n  foo: {\n    bar: {\n      a: ['a'], // index 1 ('b')  deleted\n      b: 2, // unchanged\n      c: ['x', 'y', 'z'], // 'z' added\n      d: 'Hello, world!' // added\n    }\n  },\n  buzz: 'fizz' // updated\n};\n\nconsole.log(updatedDiff(lhs, rhs));\n\n/*\n{\n  buzz: 'fizz'\n}\n*/\n```\n\n### `detailedDiff`:\n```js\nconst lhs = {\n  foo: {\n    bar: {\n      a: ['a', 'b'],\n      b: 2,\n      c: ['x', 'y'],\n      e: 100 // deleted\n    }\n  },\n  buzz: 'world'\n};\n\nconst rhs = {\n  foo: {\n    bar: {\n      a: ['a'], // index 1 ('b')  deleted\n      b: 2, // unchanged\n      c: ['x', 'y', 'z'], // 'z' added\n      d: 'Hello, world!' // added\n    }\n  },\n  buzz: 'fizz' // updated\n};\n\nconsole.log(detailedDiff(lhs, rhs));\n\n/*\n{\n  added: {\n    foo: {\n      bar: {\n        c: {\n          '2': 'z'\n        },\n        d: 'Hello, world!'\n      }\n    }\n  },\n  deleted: {\n    foo: {\n      bar: {\n        a: {\n          '1': undefined\n        },\n        e: undefined\n      }\n    }\n  },\n  updated: {\n    buzz: 'fizz'\n  }\n}\n*/\n```\n\n\n## License\n\nMIT\n","funding_links":["https://github.com/sponsors/mattphillips"],"categories":["JavaScript","目录","Modules","模块"],"sub_categories":["Object","对象"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattphillips%2Fdeep-object-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattphillips%2Fdeep-object-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattphillips%2Fdeep-object-diff/lists"}