logootsropes-crdt
Version:
Provides several data structures to represent a text in a ropes-like structure and manipulating it
28 lines (24 loc) • 598 B
JavaScript
var Utils = require('utils-crdt');
var LogootSDel = function (lid) {
this.lid = [];
for(var i=0; i<lid.length; i++) {
var id = new IdentifierInterval(lid[i].base, lid[i].begin, lid[i].end);
this.lid.push(id);
}
};
LogootSDel.prototype.copy = function () {
var o = new LogootSDel();
o.lid = [];
for(var i=0; i<this.lid.length; i++) {
o.lid.push(lid[i].copy());
}
return o;
};
LogootSDel.prototype.execute = function (doc) {
var l = [];
for(var i=0; i<this.lid.length; i++) {
Utils.pushAll(l, doc.delBlock(this.lid[i]));
}
return l;
};
module.exports = LogootSDel;