Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 1.15 KB

README.md

File metadata and controls

37 lines (26 loc) · 1.15 KB

SwiftDiff

SwiftDiff is a (partial) port of the Google Diff, Match and Patch Library (google-diff-match-patch) to Swift. The Google Diff, Match and Patch Library was originally written by Neil Fraser.

So far only the diff algorithm has been ported. It allows comparing two blocks of plain text and efficiently returning a list of their differences. It supports detecting in-line text differences.

SwiftDiff was updated to Swift 5 and SPM 5.1 by Cyberfun

License

SwiftDiff is licensed under the Apache License 2.0 – see the LICENSE file for details.

The original Google Diff, Match and Patch Library is also licensed under the same license and Copyright (c) 2006 Google Inc.

Usage

diff(text1: "The quick brown fox jumps over the lazy dog.", 
     text2: "That quick brown fox jumped over a lazy dog.")
[
  .equal("Th"),
  .delete("e"),
  .insert("at"),
  .equal(" quick brown fox jump"),
  .delete("s"),
  .insert("ed"),
  .equal(" over "),
  .delete("the"),
  .insert("a"),
  .equal(" lazy dog.")
]