{"id":1023,"url":"https://github.com/soffes/diff","last_synced_at":"2025-06-23T19:35:51.768Z","repository":{"id":66689557,"uuid":"56107830","full_name":"soffes/Diff","owner":"soffes","description":"Simple diff library in pure Swift","archived":false,"fork":false,"pushed_at":"2020-06-03T16:21:08.000Z","size":38,"stargazers_count":121,"open_issues_count":0,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T19:53:24.431Z","etag":null,"topics":["carthage","ios","macos","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/soffes.png","metadata":{"files":{"readme":"Readme.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"Support/Diff.h","governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-04-13T00:27:46.000Z","updated_at":"2025-03-16T22:34:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"74d204e1-f9e2-4ddb-a316-c9ad5b9658b0","html_url":"https://github.com/soffes/Diff","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/soffes/Diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FDiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FDiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FDiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FDiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soffes","download_url":"https://codeload.github.com/soffes/Diff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FDiff/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261543893,"owners_count":23174831,"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":["carthage","ios","macos","swift","tvos","watchos"],"created_at":"2024-01-05T20:15:37.270Z","updated_at":"2025-06-23T19:35:51.737Z","avatar_url":"https://github.com/soffes.png","language":"Swift","readme":"# Diff\n\n[![Version](https://img.shields.io/github/release/soffes/Diff.svg)](https://github.com/soffes/Diff/releases)\n[![Build Status](https://github.com/soffes/Color/workflows/Tests/badge.svg)](https://github.com/soffes/Color/actions)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nSimple diffing library in pure Swift.\n\n## Installing\n\nYou can use [Carthage](https://github.com/Carthage/Carthage) or [Swift Package Manager](https://github.com/apple/swift-package-manager) to install Diff.\n\n\n## Usage\n\nStart by importing the package:\n\n```swift\nimport Diff\n```\n\n### Same\n\nIf there is no difference, the diff will be `nil`.\n\n``` swift\ndiff(\"Hello\", \"Hello\") // nil\n```\n\nFor the sake of brevity, we'll `!` the rest of the examples since we know they're different.\n\n\n### Insert\n\n``` swift\nlet (range, string) = diff(\"Hello world\", \"Hello there world\")!\n// range: 6..\u003c6\n// string: \"there \"\n```\n\n\n### Remove\n\n``` swift\nlet (range, string) = diff(\"Hello there world\", \"Hello world\")!\n// range: 6..\u003c12\n// string: \"\"\n```\n\n\n### Other Types\n\nDiff can diff any array. Here's an array of things that conform to `Equatable`:\n\n``` swift\nlet (range, replacement) = diff([1, 2, 3], [1, 2, 3, 4])!\n// range: 3..\u003c3\n// replacement: [4]\n```\n\nYou can even use arrays of anything as long as you can compare them:\n\n```swift\nlet before: [Foo] = [a, b]\nlet after: [Foo] = [b]\nlet (range, replacement) = diff(before, after, compare: Foo.compare)!\n// range: 0..\u003c1\n// replacement: []\n```\n\n## Development\n\nIf you want to contribute to Diff, please write a test.\n\nBuilding and running the tests locally with SPM is easy:\n\n    $ git clone https://github.com/soffes/Diff\n    $ cd Diff\n    $ swift build\n    $ swift test\n\n\n## Thanks\n\nThanks to [Jonathan Clem](https://github.com/jclem) for the original algorithm and [Caleb Davenport](https://github.com/calebd) for inspiration for the generics implementation and help debugging a few edge cases!\n","funding_links":[],"categories":["Data Structures / Algorithms"],"sub_categories":["Getting Started","Other free courses","Linter"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoffes%2Fdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoffes%2Fdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoffes%2Fdiff/lists"}