{"id":20023394,"url":"https://github.com/niku/struct_diff","last_synced_at":"2025-08-09T16:27:21.443Z","repository":{"id":66601547,"uuid":"220216161","full_name":"niku/struct_diff","owner":"niku","description":"Calculates the difference between two structs","archived":false,"fork":false,"pushed_at":"2019-11-07T11:04:14.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-12T16:41:28.119Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/niku.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":"2019-11-07T11:00:32.000Z","updated_at":"2019-11-07T11:04:16.000Z","dependencies_parsed_at":"2023-02-27T10:31:09.662Z","dependency_job_id":null,"html_url":"https://github.com/niku/struct_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/niku%2Fstruct_diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niku%2Fstruct_diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niku%2Fstruct_diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niku%2Fstruct_diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niku","download_url":"https://codeload.github.com/niku/struct_diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241455454,"owners_count":19965611,"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-13T08:46:17.882Z","updated_at":"2025-03-02T04:17:15.312Z","avatar_url":"https://github.com/niku.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StructDiff\n\nCalculates the difference between two structs.\n\nIf you would like to calculate map difference and/or nested struct difference, you might use [Qqwy/elixir-map_diff](https://github.com/Qqwy/elixir-map_diff).\n\n## Usage\n\n```elixir\ndefmodule A, do: defstruct [:x, :y, :z]\ndefmodule B, do: defstruct [:x, :y, :z]\n\nStructDiff.diff(%A{x: 1, y: 2, z: 3}, %A{x: 1, y: 2, z: 3})\n# =\u003e {:ok, %{}}\n\nStructDiff.diff(%A{x: 100, y: 2, z: 3}, %A{x: 1, y: 2, z: 30})\n# =\u003e {:ok, %{x: {100, 1}, z: {3, 30}}}\n\nStructDiff.diff(%A{x: 1, y: 2, z: 3}, %B{x: 1, y: 2, z: 3})\n# =\u003e {:error, {:different_struct_given, A, B}}\n\nStructDiff.diff(%{}, %A{})\n# =\u003e {:error, {:no_struct_given, :the_first}}\n\n# Limitation, it calculates only top level diffs, doesn't calculate nested structs\nStructDiff.diff(%A{x: 1, y: 2, z: %B{x: 3, y: 4, z: 5}}, %A{x: 1, y: 2, z: %B{x: 30, y: 40, z: 50}})\n# =\u003e {:ok, %{z: {%B{x: 3, y: 4, z: 5}, %B{x: 30, y: 40, z: 50}}}}\n```\n\n## Installation\n\nAdd `niku/struct_diff` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:struct_diff, github: \"niku/struct_diff\"}\n  ]\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniku%2Fstruct_diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniku%2Fstruct_diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniku%2Fstruct_diff/lists"}