Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor re-org on documentation #144

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -8,13 +8,20 @@ Automerge Utilities extends Automerge's `Document` type to make it easier to par

## Topics

### Walking and Parsing Automerge documents
### Inspecting Automerge documents

- ``Automerge/Document/isEmpty()``
- ``Automerge/Document/parseToSchema(_:from:)``
- ``Automerge/Document/schema()``
- ``AutomergeUtilities/AutomergeValue``

### Parsing the contents of an Automerge document

- ``Automerge/Document/parseToSchema(_:from:)``

### Comparing the contents of Automerge documents

- ``Automerge/Document/equivalentContents(_:)``

### Debugging Methods

- ``Automerge/Document/walk()``
14 changes: 14 additions & 0 deletions Sources/AutomergeUtilities/Document+equivalentContents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Automerge

public extension Document {
/// Returns a Boolean value that indicates whether the latest contents another document are equivalent.
func equivalentContents(_ anotherDoc: Document) -> Bool {
do {
let doc1Contents = try self.parseToSchema(self, from: .ROOT)
let doc2Contents = try anotherDoc.parseToSchema(anotherDoc, from: .ROOT)
return doc1Contents == doc2Contents
} catch {
return false
}
}
}