in frontend/index.js [224:254]
function change(doc, options, callback) {
if (doc[OBJECT_ID] !== '_root') {
throw new TypeError('The first argument to Automerge.change must be the document root')
}
if (doc[CHANGE]) {
throw new TypeError('Calls to Automerge.change cannot be nested')
}
if (typeof options === 'function' && callback === undefined) {
[options, callback] = [callback, options]
}
if (typeof options === 'string') {
options = {message: options}
}
if (options !== undefined && !isObject(options)) {
throw new TypeError('Unsupported type of options')
}
const actorId = getActorId(doc)
if (!actorId) {
throw new Error('Actor ID must be initialized with setActorId() before making a change')
}
const context = new Context(doc, actorId)
callback(rootObjectProxy(context))
if (Object.keys(context.updated).length === 0) {
// If the callback didn't change anything, return the original document object unchanged
return [doc, null]
} else {
return makeChange(doc, context, options)
}
}