{"id":20137158,"url":"https://github.com/amirfarzamnia/deep-compare-objects","last_synced_at":"2026-01-27T08:03:28.603Z","repository":{"id":245453451,"uuid":"818555322","full_name":"amirfarzamnia/deep-compare-objects","owner":"amirfarzamnia","description":"Deeply compare objects and identify their differences.","archived":false,"fork":false,"pushed_at":"2025-12-16T09:22:29.000Z","size":217,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-17T00:33:36.482Z","etag":null,"topics":["arrays","compare","datatype","deep","differences","json","objects"],"latest_commit_sha":null,"homepage":"https://amirfarzamnia.github.io/deep-compare-objects/","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/amirfarzamnia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-22T06:51:03.000Z","updated_at":"2025-12-15T13:46:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"c2fb3852-8a6b-43eb-aeec-6194a23c4163","html_url":"https://github.com/amirfarzamnia/deep-compare-objects","commit_stats":null,"previous_names":["amirfarzamnia/deep-object-compare"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amirfarzamnia/deep-compare-objects","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirfarzamnia%2Fdeep-compare-objects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirfarzamnia%2Fdeep-compare-objects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirfarzamnia%2Fdeep-compare-objects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirfarzamnia%2Fdeep-compare-objects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amirfarzamnia","download_url":"https://codeload.github.com/amirfarzamnia/deep-compare-objects/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirfarzamnia%2Fdeep-compare-objects/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28809337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["arrays","compare","datatype","deep","differences","json","objects"],"created_at":"2024-11-13T21:25:38.816Z","updated_at":"2026-01-27T08:03:28.595Z","avatar_url":"https://github.com/amirfarzamnia.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deep Compare Objects\r\n\r\nA TypeScript utility for deeply comparing objects and arrays, identifying their differences with precision.\r\n\r\n[![npm version](https://badge.fury.io/js/deep-compare-objects.svg)](https://badge.fury.io/js/deep-compare-objects)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![TypeScript](https://img.shields.io/badge/TypeScript-007ACC.svg?logo=typescript\u0026logoColor=white)](https://www.typescriptlang.org/)\r\n\r\n## Features\r\n\r\n- Deep comparison of objects and arrays\r\n- Handles nested structures\r\n- TypeScript support\r\n- Safe JSON stringification\r\n- Returns only the differences between objects\r\n\r\n## Installation\r\n\r\n```bash\r\n# Using npm\r\nnpm install deep-compare-objects\r\n\r\n# Using yarn\r\nyarn add deep-compare-objects\r\n\r\n# Using pnpm\r\npnpm add deep-compare-objects\r\n```\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport deepCompareObjects from \"deep-compare-objects\";\r\n\r\n// Basic object comparison\r\nconst obj1 = { name: \"John\", age: 30 };\r\nconst obj2 = { name: \"John\", age: 31 };\r\nconst differences = deepCompareObjects(obj1, obj2);\r\n// Result: { age: 31 }\r\n\r\n// Nested object comparison\r\nconst nested1 = { user: { name: \"John\", address: { city: \"New York\" } } };\r\nconst nested2 = { user: { name: \"John\", address: { city: \"Los Angeles\" } } };\r\nconst nestedDifferences = deepCompareObjects(nested1, nested2);\r\n// Result: { user: { address: { city: 'Los Angeles' } } }\r\n\r\n// Array comparison\r\nconst arr1 = [1, 2, { name: \"John\" }];\r\nconst arr2 = [1, 2, { name: \"Jane\" }];\r\nconst arrayDifferences = deepCompareObjects(arr1, arr2);\r\n// Result: { 2: { name: 'Jane' } }\r\n```\r\n\r\n## API\r\n\r\n### `deepCompareObjects(a: Record\u003cstring, any\u003e, b: Record\u003cstring, any\u003e): Record\u003cstring, any\u003e | undefined`\r\n\r\nCompares two objects and returns their differences.\r\n\r\n#### Parameters\r\n\r\n- `a` (optional): The first object to compare. Defaults to an empty object.\r\n- `b` (optional): The second object to compare. Defaults to an empty object.\r\n\r\n#### Returns\r\n\r\n- An object containing only the differences between `a` and `b`\r\n- `undefined` if `b` is null or undefined\r\n\r\n#### Behavior\r\n\r\n- For primitive values, returns the new value if different\r\n- For objects, recursively compares and returns only the changed properties\r\n- For arrays, compares each element and returns only the changed elements\r\n- Handles circular references safely using `json-stringify-safe`\r\n\r\n## Examples\r\n\r\n### Comparing Simple Objects\r\n\r\n```typescript\r\nconst obj1 = { name: \"John\", age: 30 };\r\nconst obj2 = { name: \"John\", age: 31, city: \"New York\" };\r\nconst result = deepCompareObjects(obj1, obj2);\r\n// Result: { age: 31, city: 'New York' }\r\n```\r\n\r\n### Comparing Nested Objects\r\n\r\n```typescript\r\nconst obj1 = {\r\n  user: {\r\n    name: \"John\",\r\n    preferences: {\r\n      theme: \"dark\",\r\n      notifications: true,\r\n    },\r\n  },\r\n};\r\n\r\nconst obj2 = {\r\n  user: {\r\n    name: \"John\",\r\n    preferences: {\r\n      theme: \"light\",\r\n      notifications: true,\r\n    },\r\n  },\r\n};\r\n\r\nconst result = deepCompareObjects(obj1, obj2);\r\n// Result: { user: { preferences: { theme: 'light' } } }\r\n```\r\n\r\n### Comparing Arrays\r\n\r\n```typescript\r\nconst arr1 = [1, 2, { name: \"John\" }];\r\nconst arr2 = [1, 3, { name: \"Jane\" }];\r\nconst result = deepCompareObjects(arr1, arr2);\r\n// Result: { 1: 3, 2: { name: 'Jane' } }\r\n```\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Author\r\n\r\nAmir Farzamnia - [GitHub](https://github.com/amirfarzamnia)\r\n\r\n## Support\r\n\r\nIf you find this package useful, please consider giving it a ⭐️ on GitHub!\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirfarzamnia%2Fdeep-compare-objects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famirfarzamnia%2Fdeep-compare-objects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirfarzamnia%2Fdeep-compare-objects/lists"}