| 11 | } |
| 12 | } |
| 13 | class Chunk { |
| 14 | constructor(start, end, content) { |
| 15 | this.start = start; |
| 16 | this.end = end; |
| 17 | this.original = content; |
| 18 | this.intro = ''; |
| 19 | this.outro = ''; |
| 20 | this.content = content; |
| 21 | this.storeName = false; |
| 22 | this.edited = false; |
| 23 | Object.defineProperties(this, { |
| 24 | previous: { writable: true, value: null }, |
| 25 | next: { writable: true, value: null }, |
| 26 | }); |
| 27 | } |
| 28 | appendLeft(content) { |
| 29 | this.outro += content; |
| 30 | } |
| 31 | appendRight(content) { |
| 32 | this.intro = this.intro + content; |
| 33 | } |
| 34 | clone() { |
| 35 | const chunk = new Chunk(this.start, this.end, this.original); |
| 36 | chunk.intro = this.intro; |
| 37 | chunk.outro = this.outro; |
| 38 | chunk.content = this.content; |
| 39 | chunk.storeName = this.storeName; |
| 40 | chunk.edited = this.edited; |
| 41 | return chunk; |
| 42 | } |
| 43 | contains(index) { |
| 44 | return this.start < index && index < this.end; |
| 45 | } |
| 46 | eachNext(fn) { |
| 47 | let chunk = this; |
| 48 | while (chunk) { |
| 49 | fn(chunk); |
| 50 | chunk = chunk.next; |
| 51 | } |
| 52 | } |
| 53 | eachPrevious(fn) { |
| 54 | let chunk = this; |
| 55 | while (chunk) { |
| 56 | fn(chunk); |
| 57 | chunk = chunk.previous; |
| 58 | } |
| 59 | } |
| 60 | edit(content, storeName, contentOnly) { |
| 61 | this.content = content; |
| 62 | if (!contentOnly) { |
| 63 | this.intro = ''; |
| 64 | this.outro = ''; |
| 65 | } |
| 66 | this.storeName = storeName; |
| 67 | this.edited = true; |
| 68 | return this; |
| 69 | } |
| 70 | prependLeft(content) { |
nothing calls this directly
no outgoing calls
no test coverage detected