slice method
Returns slice of this delta from start
index (inclusive) to end
(exclusive).
Implementation
Delta slice(int start, [int? end]) {
final delta = Delta();
var index = 0;
final opIterator = DeltaIterator(this);
final actualEnd = end ?? DeltaIterator.maxLength;
while (index < actualEnd && opIterator.hasNext) {
Operation op;
if (index < start) {
op = opIterator.next(start - index);
} else {
op = opIterator.next(actualEnd - index);
delta.push(op);
}
index += op.length!;
}
return delta;
}