Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm

Related tags

Utility Differific
Overview

Differific

CI Status Version Carthage Compatible codecov License Platform Swift

Description

Differific Icon

Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm. Creating a changeset is seamless for all your diffing needs. The library also includes some convenience extensions to make life easier when updating data sources.

The library is based and highly influenced by Matias Cudich's (@mcudich) HeckelDiff library that aims to solve the same issue. Versions prior to 0.3.0 was based on DeepDiff. For more information about how the algorithm works and the performance of the algorithm, head over to DeepDiff. For the time being, both frameworks are very similar; this is subject to change when the frameworks evolve.

Features

  • 🍩 Built-in extensions for updating table & collection views.
  • 🎩 Customizable diffing.
  • 🏎 High performance.
  • 📱 iOS support.
  • 💻 macOS support.
  • 📺 tvOS support.

Usage

Diffing two collections

let old = ["Foo", "Bar"]
let new = ["Foo", "Bar", "Baz"]
let manager = DiffManager()
let changes = manager.diff(old, new)

Updating a table or collection view

// uiElement is either your table view or collection view.
let old = dataSource.models
let new = newCollection
let changes = DiffManager().diff(old, new)
uiElement.reload(with: changes, before: { dataSource.models = new })

Installation

Differific is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Differific'

Differific is also available through Carthage. To install just write into your Cartfile:

github "zenangst/Differific"

Differific can also be installed manually. Just download and drop Sources folders in your project.

Author

Contributing

We would love you to contribute to Differific, check the CONTRIBUTING file for more info.

License

Differific is available under the MIT license. See the LICENSE file for more info.

Comments
  • Demo

    Demo

    In response

    https://github.com/zenangst/Differific/issues/6#issuecomment-446855458

    I thought I would go all out on this one.

    TOOK AGES guys 😓

    It's really hot shit 😎

    opened by ghost 3
  • Make Algorithm static and optimize diff method

    Make Algorithm static and optimize diff method

    The diff method has been made static and the implementation has been optimized. Now the for-loop retain their own index, it also iterates over ArraySlices.

    opened by zenangst 2
  • Add safe-guard for reloading without a superview

    Add safe-guard for reloading without a superview

    Fixes crash where the view has yet to get a superview. Instead of running the performBatchUpdates, the implementation will now invoke reloadData followed by completion?() and return early.

    opened by zenangst 1
  • Improve diff performance

    Improve diff performance

    This PR improves diff performance by using reserving capacity of the arrays before diffing. It also simplifies the implementation by removing enum and uses concrete value types instead, this should not affect performance but in my own personal opinion, it is easier to reason about as opposed to looking "fancy".

    The use of defer has also been removed to make the code more linear.

    opened by zenangst 1
  • Fix crash with only one new match

    Fix crash with only one new match

    Fix crash when trying to diff two collection where the new one only contains one item. When this happens the algorithm went out of bounds as it moves the offset around.

    opened by zenangst 1
  • Fix crash when new array only contains one item

    Fix crash when new array only contains one item

    Fix crash when trying to diff two collection where the new one only contains one item. When this happens the algorithm went out of bounds as it moves the offset around.

    opened by zenangst 1
  • Improve user interface extensions

    Improve user interface extensions

    The user interface extensions have been refactored to run the update closure inside of performBatchUpdates. The closure has also been renamed from before to updateDataSource.

    opened by zenangst 1
  • Refactor implementation to handle updates properly

    Refactor implementation to handle updates properly

    The implementation of the algorithm has been refactored and partially rewritten to handle updates properly.

    Thanks to @mcudich for his library HeckelDiff (https://github.com/mcudich/HeckelDiff).

    opened by zenangst 1
  • Improve public API on extensions.

    Improve public API on extensions.

    There is really no need to pass the UI element into the before closure as it is available at the call-site. So instead of always writing _ in, the element is no longer passed into the closure.

    • Remove UI element from before closure.
    • Call setNeedsLayout() and layoutIfNeeded() in extension methods.
    opened by zenangst 0
Releases(0.8.4)
Owner
Christoffer Winterkvist
random hero at @finkoslo by day, cocoa vigilante by night, dad at dawn. my life is awesome. Previously @hyperoslo
Christoffer Winterkvist
Paul Hudson redesigned and remastered the original MoonshotApp. And so I followed the tutorial

Moonshot App for iOS. parsing some json files, using generics, and creating multi page app. Application provides simple informations from the Apollo m

Pavel Surový 0 Dec 7, 2021
🦀Amazingly incredible extraordinary lightning fast diffing in Swift

DeepDiff ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut man

Khoa 2k Dec 29, 2022
Diff - Simple diffing library in pure Swift

Diff Simple diffing library in pure Swift. Installing You can use Carthage or Swift Package Manager to install Diff. Usage Start by importing the pack

Sam Soffes 120 Sep 9, 2022
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.

A fast and flexible O(n) difference algorithm framework for Swift collection. The algorithm is optimized based on the Paul Heckel's algorithm. Made wi

Ryo Aoyama 3.3k Jan 4, 2023
SuggestionsBox helps you build better a product trough your user suggestions. Written in Swift. 🗳

SuggestionsBox An iOS library to aggregate users feedback about suggestions, features or comments in order to help you build a better product. Swift V

Manuel Escrig 100 Feb 6, 2022
Highlighter will magically find UI objects such as UILabel, UITextView, UITexTfield, UIButton

Highlighter Updates See CHANGELOG for details Intoduction ?? Highlight whatever you want! Highlighter will magically find UI objects such as UILabel,

Kyle Yi 932 Dec 12, 2022
Type-Safe Associated Objects in Swift

Type-Safe Associated Objects in Swift TSAO is an implementation of type-safe associated objects in Swift. Objective-C associated objects are useful, b

Lily Ballard 135 Dec 21, 2022
Observe objects in SwiftUI Views which may be nil

ObservedOptionalObject Rationale SwiftUIs @ObservedObject requires that the observed object actually exists. In some cases it's convenient to observe

Matthias Bartelmeß 7 Jul 20, 2022
Getting square objects down round holes

Enough with the bazillion lines of array parsing logic. YOLO. @import YOLOKit; campaigns.reject(^(PPCampaign *campaign){ return campaign.locked;

Max Howell 662 Nov 20, 2022
A Swift collection of unique, ordered objects

Introduction OrderedSet is essentially the Swift equivalent of Foundation's NSOrderedSet/NSMutableOrderedSet. It was created so Swift would have a uni

Weebly 248 Sep 14, 2022
A library that helps developers to easily perform file-related operations In iOS

File Operations Preview A library that helps developers to easily perform file-related operations. In iOS, We write our files mainly into three direct

Rinto Andrews 1 Oct 15, 2021
Extensions which helps to convert objc-style target/action to swifty closures

ActionClosurable Usage ActionClosurable extends UIControl, UIButton, UIRefreshControl, UIGestureRecognizer and UIBarButtonItem. It helps writing swift

takasek 121 Aug 11, 2022
The Objective-C block utilities you always wish you had.

BlocksKit Blocks in C and Objective-C are downright magical. They make coding easier and potentially quicker, not to mention faster on the front end w

BlocksKit 6.9k Dec 28, 2022
Pavel Surový 0 Jan 1, 2022
A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript

Dollar Dollar is a Swift library that provides useful functional programming helper methods without extending any built in objects. It is similar to L

Ankur Patel 4.2k Jan 2, 2023
A command-line tool and Swift Package for generating class diagrams powered by PlantUML

SwiftPlantUML Generate UML class diagrams from swift code with this Command Line Interface (CLI) and Swift Package. Use one or more Swift files as inp

null 374 Jan 3, 2023
A SARS-CoV-2 Mutation Pattern Query Tool

vdb A SARS-CoV-2 Mutation Pattern Query Tool 1. Purpose The vdb program is designed to query the SARS-CoV-2 mutational landscape. It runs as a command

null 13 Oct 25, 2022
This package will contain the standard encodings/decodings/hahsing used by the String Conversion Tool app.

This package will contain the standard encodings/decodings/hahsing used by the String Conversion Tool app. It will also, however, contain extra encoding/decoding methods (new encoding/decoding)

Gleb 0 Oct 16, 2021
qr code generator tool

qr code generator tool Small command line tool for generate and reconition qr codes written in Swift Using Usage: ./qrgen [options] -m, --mode:

Igor 3 Jul 15, 2022