Created
December 1, 2017 11:58
-
-
Save erukiti/a16a87ee2cbfb3b030edf066d63f5b2b to your computer and use it in GitHub Desktop.
telettype-crdtの実験
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Document, serializeOperation, deserializeOperation } = require('@atom/teletype-crdt') | |
const doc1 = new Document({siteId: 1}) | |
const doc2 = new Document({siteId: 2}) | |
const ZP = {...{row: 0, column: 0}} | |
doc1.setTextInRange(ZP, ZP, 'a') | |
doc2.setTextInRange(ZP, ZP, 'b') | |
doc1.integrateOperations(doc2.getOperations()) | |
doc2.integrateOperations(doc1.getOperations()) | |
console.log(1, doc1.getText()) | |
console.log(2, doc2.getText()) | |
const ops1 = doc1.setTextInRange(ZP, ZP, 'hoge') | |
console.log(1, doc1.getText()) | |
console.log(2, doc2.getText()) | |
doc2.integrateOperations(ops1) | |
console.log(2, doc2.getText()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment