|Project Name||Stars||Downloads||Repos Using This||Packages Using This||Most Recent Commit||Total Releases||Latest Release||Open Issues||License||Language|
|Difftastic||15,447||4 days ago||57||July 27, 2023||143||mit||Rust|
|a structural diff that understands syntax 🟥🟩|
|Differencekit||3,328||19||4 months ago||21||May 07, 2021||27||apache-2.0||Swift|
|💻 A fast and flexible O(n) difference algorithm framework for Swift collection.|
|Textdistance||3,172||14||42||a year ago||25||September 20, 2022||9||mit||Python|
|📐 Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.|
|Dwifft||1,767||26||3 years ago||12||October 22, 2018||18||mit||Swift|
|Diff.swift||935||20||5 years ago||7||September 30, 2017||8||mit||Swift|
|The fastest Diff and patch library in Swift. Includes UICollectionView/UITableView utils.|
|🚅 - Hyper fast diffing algorithm for real DOM nodes|
|Diffabledatasources||619||2 years ago||4||June 08, 2021||13||apache-2.0||Swift|
|💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.|
|Editscript||423||6 months ago||22||August 25, 2022||11||epl-1.0||Clojure|
|A library to diff and patch Clojure/ClojureScript data structures|
|Vim Diff Enhanced||332||3 years ago||Vim script|
|Better Diff options for Vim|
|Diff Lcs||263||214,363||323||a year ago||16||December 23, 2021||5||other||Ruby|
|Generate difference sets between Ruby sequences.|
Dwifft is a small Swift library that tells you what the "diff" is between two collections, namely, the series of "edit operations" required to turn one into the other. It also comes with UIKit bindings, to automatically, animatedly keep a UITableView/UICollectionView in sync with a piece of data by making the necessary row/section insertion/deletion calls for you as the data changes.
Dwifft is a Swift library that does two things. The first thing sounds interesting but perhaps only abstractly useful, and the other thing is a very concretely useful thing based off the first thing.
The first thing (found in
Dwifft.swift) is an algorithm that calculates the diff between two collections using the Longest Common Subsequence method. If this kind of thing is interesting to you, there's a pretty great paper on diffing algorithms: http://www.xmailserver.org/diff2.pdf
The second thing (found in
Dwifft+UIKit.swift) is a series of diff calculators for
UICollectionViews. Let's say you have a
UITableView that's backed by a simple array of values (like a list of names, e.g.
["Alice", "Bob", "Carol"]. If that array changes (maybe Bob leaves, and is replaced by Dave, so our list is now
["Alice, "Carol", "Dave"]), we'll want to update the table. The easiest way to do this is by calling
reloadData on it. This has a couple of downsides: the transition isn't animated, and it'll cause your user to lose their scroll position if they've scrolled the table. The nicer way is to use the
deleteRowsAtIndexPaths:withRowAnimation methods on
UITableView, but this requires you to figure out which index paths have changed in your array (in our example, you'd have to figure out that the row at index 1 should be removed, and a new row should be inserted at index 2 should then be added). If only we had a way to diff the previous value of our array with it's new value. Wait a minute.
When you wire up a
TableViewDiffCalculator to your
UITableView (or a
CollectionViewDiffCalculator to your
UICollectionView, it'll automatically calculate diffs and trigger the necessary animations on it whenever you change its
sectionedValues property. Neat, right? Notably, as of Dwifft 0.6, Dwifft will also figure out section insertions and deletions, as well as how to efficiently insert and delete rows across different sections, which is just so massively useful if you have a multi-section table. If you're currently using a <0.6 version of Dwifft and want to do this, read the 0.6 release notes.
Learn more about the history of Dwifft, and how it works, in this exciting video of a talk recorded at the Brooklyn Swift meetup in March 2017.
Contributions are welcome, with some caveats - please read the contributing guidelines before opening a PR to avoid wasting both our time.
Ok, that's it, there's nothing more here.