1.2.1 • Published 9 years ago

otjs v1.2.1

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

ot

A line-based operational transform algorithm

Build Status Dependency Status

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'