{"id":19757156,"url":"https://github.com/lyst/updated-obj-diff","last_synced_at":"2025-02-28T02:20:54.236Z","repository":{"id":45306960,"uuid":"321989440","full_name":"lyst/updated-obj-diff","owner":"lyst","description":null,"archived":false,"fork":false,"pushed_at":"2021-12-22T16:38:58.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-10T22:43:22.059Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/lyst.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}},"created_at":"2020-12-16T13:22:56.000Z","updated_at":"2021-12-22T15:30:14.000Z","dependencies_parsed_at":"2022-09-26T16:22:26.048Z","dependency_job_id":null,"html_url":"https://github.com/lyst/updated-obj-diff","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyst%2Fupdated-obj-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyst%2Fupdated-obj-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyst%2Fupdated-obj-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyst%2Fupdated-obj-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lyst","download_url":"https://codeload.github.com/lyst/updated-obj-diff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241089116,"owners_count":19907690,"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":[],"created_at":"2024-11-12T03:18:16.218Z","updated_at":"2025-02-28T02:20:54.216Z","avatar_url":"https://github.com/lyst.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# updated-obj-diff\n\nA small JavaScript library that returns the updated difference between two JavaScript objects, including nested objects.\n\nFeatures:\n\n- Handles values of data types including arrays, strings and integers\n- Handles situations where keys are not present in both objects\n- Omits keys with null values in both objects\n- Returns whole array values of keys in updated objects\n\n## Installation\n\n```\nnpm install updated-obj-diff\n```\n\n## Usage\n\nReturns top-level and nested updated values\n\n```javascript\nconst updatedDiff = require(\"updated-obj-diff\");\n\nconst pokemon1 = {\n  species: \"pikachu\",\n  type: \"electric\",\n  measurements: {\n    height: {\n      measurement: 0.4,\n      unit: \"m\",\n    },\n    weight: {\n      measurement: 6,\n      unit: \"kg\",\n    },\n  },\n};\nconst pokemon2 = {\n  species: \"raichu\",\n  type: \"electric\",\n  measurements: {\n    height: {\n      measurement: 31,\n      unit: \"in\",\n    },\n    weight: {\n      measurement: 30,\n      unit: \"kg\",\n    },\n  },\n};\n\nconsole.log(updatedDiff(pokemon1, pokemon2));\n/*\n{\n  species: \"raichu\",\n  measurements: {\n    height: {\n      measurement: 31,\n      unit: \"in\",\n    },\n    weight: {\n      measurement: 30,\n    },\n  },\n};\n*/\n```\n\nReturns whole updated arrays\n\n```javascript\nconst updatedDiff = require(\"updated-obj-diff\");\n\nconst pokemon1 = {\n  species: \"pikachu\",\n  moves: {\n    level_up: [\"quick attack\", \"slam\", \"spark\"],\n    machine: [\"frustration\"],\n  },\n};\nconst pokemon2 = {\n  species: \"raichu\",\n  moves: {\n    level_up: [\"quick attack\"],\n    machine: [\"frustration\", \"giga impact\", \"hyper beam\"],\n  },\n};\n\nconsole.log(updatedDiff(pokemon1, pokemon2));\n/*\n{\n    species: \"raichu\",\n    moves: {\n        level_up: [\"quick attack\"],\n        machine: [\"frustration\", \"giga impact\", \"hyper beam\"],\n    },\n};\n*/\n```\n\nReturns new keys and values\n\n```javascript\nconst updatedDiff = require(\"updated-obj-diff\");\n\nconst pokemon1 = {\n  species: \"pikachu\",\n};\nconst pokemon2 = {\n  species: \"raichu\",\n  thunder_stone: true,\n};\n\nconsole.log(updatedDiff(pokemon1, pokemon2));\n/*\n  {\n    species: \"raichu\",\n    thunder_stone: true,\n  };\n*/\n```\n\nReturns null values for missing keys\n\n```javascript\nconst updatedDiff = require(\"updated-obj-diff\");\n\nconst pokemon1 = {\n  species: \"pikachu\",\n  mascot: true,\n};\nconst pokemon2 = {\n  species: \"raichu\",\n};\n\nconsole.log(updatedDiff(pokemon1, pokemon2));\n/*\n  {\n    species: \"raichu\",\n    mascot: null,\n  };\n*/\n```\n\nReturns null for updated null values that were not previously null\n\n```javascript\nconst updatedDiff = require(\"updated-obj-diff\");\n\nconst pokemon1 = {\n  species: \"pikachu\",\n  dynamax: {\n    gigantamax: true,\n  },\n};\nconst pokemon2 = {\n  species: \"raichu\",\n  dynamax: null,\n};\n\nconsole.log(updatedDiff(pokemon1, pokemon2));\n/*\n  {\n    species: \"raichu\",\n    dynamax: null,\n  };\n*/\n```\n\nOmits keys that have the value of null in one object, and do not exist in the other object\n\n```javascript\nconst updatedDiff = require(\"updated-obj-diff\");\n\nconst pokemon1 = {\n  species: \"pikachu\",\n  old_key: null,\n};\nconst pokemon2 = {\n  species: \"raichu\",\n  new_key: null,\n};\n\nconsole.log(updatedDiff(pokemon1, pokemon2));\n/*\n  {\n    species: \"raichu\",\n  };\n*/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyst%2Fupdated-obj-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flyst%2Fupdated-obj-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyst%2Fupdated-obj-diff/lists"}