import { change } from "https://deno.land/x/automerge@2.2.2/index.ts";
Update the contents of an automerge document
Examples
A simple change
A simple change
let doc1 = automerge.init()
doc1 = automerge.change(doc1, d => {
d.key = "value"
})
assert.equal(doc1.key, "value")
A change with a message
A change with a message
doc1 = automerge.change(doc1, "add another value", d => {
d.key2 = "value2"
})
A change with a message and a timestamp
A change with a message and a timestamp
doc1 = automerge.change(doc1, {message: "add another value", time: 1640995200}, d => {
d.key2 = "value2"
})
responding to a patch callback
responding to a patch callback
let patchedPath
let patchCallback = patch => {
patchedPath = patch.path
}
doc1 = automerge.change(doc1, {message: "add another value", time: 1640995200, patchCallback}, d => {
d.key2 = "value2"
})
assert.equal(patchedPath, ["key2"])
Parameters
options: string | ChangeOptions<T> | ChangeFn<T>
- Either a message, an ChangeOptions, or a ChangeFn