otjs
v1.2.1
Published
The line-based implementation of operational transform
Downloads
20
Readme
ot
A line-based operational transform algorithm
Install
npm install otjs
Usage
var transform = require('otjs');
var res = transform.transformBatch([
// Operation "S"
{ type: 'del', line: 0 },
{ type: 'del', line: 0 },
{ type: 'del', line: 0 }
], [
// Operation "C"
{ type: 'add', line: 0, text: '0' },
{ type: 'add', line: 2, text: '2' },
{ type: 'add', line: 4, text: '4' }
]);
expect(res).to.eql([
[
// Operation "S'"
{ type: 'del', line: 1 },
{ type: 'del', line: 2 },
{ type: 'del', line: 3 }
], [
// Operation "C'"
{ type: 'add', line: 0, text: '0' },
{ type: 'add', line: 1, text: '2' },
{ type: 'add', line: 2, text: '4' }
]
]);
// S + C' === C + S'