| 1 |
/** Provides details of continuous extracted tail */ |
| 2 |
class ContinuousTailDetails { |
| 3 |
/** Tail value as string */ |
| 4 |
|
| 5 |
/** Tail start position */ |
| 6 |
|
| 7 |
/** Start position */ |
| 8 |
|
| 9 |
constructor(value, from, stop) { |
| 10 |
if (value === void 0) { |
| 11 |
value = ''; |
| 12 |
} |
| 13 |
if (from === void 0) { |
| 14 |
from = 0; |
| 15 |
} |
| 16 |
this.value = value; |
| 17 |
this.from = from; |
| 18 |
this.stop = stop; |
| 19 |
} |
| 20 |
toString() { |
| 21 |
return this.value; |
| 22 |
} |
| 23 |
extend(tail) { |
| 24 |
this.value += String(tail); |
| 25 |
} |
| 26 |
appendTo(masked) { |
| 27 |
return masked.append(this.toString(), { |
| 28 |
tail: true |
| 29 |
}).aggregate(masked._appendPlaceholder()); |
| 30 |
} |
| 31 |
get state() { |
| 32 |
return { |
| 33 |
value: this.value, |
| 34 |
from: this.from, |
| 35 |
stop: this.stop |
| 36 |
}; |
| 37 |
} |
| 38 |
set state(state) { |
| 39 |
Object.assign(this, state); |
| 40 |
} |
| 41 |
unshift(beforePos) { |
| 42 |
if (!this.value.length || beforePos != null && this.from >= beforePos) return ''; |
| 43 |
const shiftChar = this.value[0]; |
| 44 |
this.value = this.value.slice(1); |
| 45 |
return shiftChar; |
| 46 |
} |
| 47 |
shift() { |
| 48 |
if (!this.value.length) return ''; |
| 49 |
const shiftChar = this.value[this.value.length - 1]; |
| 50 |
this.value = this.value.slice(0, -1); |
| 51 |
return shiftChar; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
export { ContinuousTailDetails as default }; |
| 56 |
|