Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (var key in item) {
change[key] = item[key];
}
});
const changes = Automerge.getChanges(doc, newDoc);
const latestActor = changes.length
? changes[changes.length - 1].actor
: actor;
delta.push([id, changes, rev]);
return {
...item,
[actorField]: latestActor,
id,
// rem,
rev,
[mergeField]: Automerge.save(newDoc)
};
});
/* if (!history.length) {
return {
...snapshot,
actor: undefined,
id,
merge: Automerge.save(docNew)
};
}*/
const history = Automerge.getHistory(docNew);
const { change, snapshot } = history[history.length - 1];
return {
...snapshot,
actor: change.actor,
id,
merge: Automerge.save(docNew)
};
})
.filter(x => x);
private onConnect = socket => {
const { id, conn } = socket
const { name } = socket.nsp
const doc = this.docSet.getDoc(name)
const data = Automerge.save(doc)
this.connections[id] = new Automerge.Connection(this.docSet, data => {
socket.emit('operation', { id: conn.id, ...data })
})
socket.join(id, () => {
this.connections[id].open()
socket.emit('document', data)
})
socket.on('operation', this.onOperation(id, name))
socket.on('disconnect', this.onDisconnect(id, socket))
this.garbageCursors(name)
save() {
return Automerge.save(this.getState())
}
doc[key] = item[key];
}
});
}
if (cb) {
cb(doc);
}
});
const history = Automerge.getHistory(doc);
item = JSON.parse(JSON.stringify(history[history.length - 1].snapshot));
item.changes = originalChanges + 1;
item.id = id;
if (wasDel) {
item.isRemoved = wasDel;
}
item.automerge = Automerge.save(doc);
item = await client.insert(table, item);
return item;
} catch (err) {
return Promise.reject(err);
}
}
return edit;
public async serialize() {
return AutoMerge.save(this.outline)
}
public serialize() {
return AutoMerge.save(this.crdt)
}