UNPKG

logoots-structs

Version:

Provides several data structures to represent a text using a ropes-like structure and manipulating it

46 lines (39 loc) 927 B
/** * */ var LogootSBlock = function(id, list) { this.id = id || null; this.nbElement = list || 0; this.mine = false; }; /** * */ LogootSBlock.prototype.addBlock = function(pos, length) { this.nbElement += length; this.id.begin = Math.min(this.id.begin, pos); this.id.end = Math.max(this.id.end, pos + length - 1); }; /** * */ LogootSBlock.prototype.delBlock = function(begin, end, nbElement) { this.nbElement -= nbElement; }; /** * */ LogootSBlock.prototype.copy = function() { return new LogootSBlock(this.id.copy(), this.nbElement); }; LogootSBlock.prototype.copyFromJSON = function (block) { var base = Utils.copy(block.id.base); this.id = new IdentifierInterval(base, block.begin, block.end); }; /** * */ LogootSBlock.prototype.toString = function() { return '{' + this.nbElement + ',' + this.id.toString() + ', ' + (this.mine ? 'mine' : 'its') + '}'; }; module.exports = LogootSBlock;