* Appends the specified content at the index in the original string. * If a range *ending* with index is subsequently moved, the insert will be moved with it. * See also `s.prependLeft(...)`.
(index: number, content: string)
| 133 | * See also `s.prependLeft(...)`. |
| 134 | */ |
| 135 | appendLeft(index: number, content: string): this { |
| 136 | index = index + this.offset |
| 137 | |
| 138 | if (typeof content !== 'string') { |
| 139 | throw new MagicStringError(`content must be a string, got ${typeof content}`) |
| 140 | } |
| 141 | |
| 142 | if (DEBUG) |
| 143 | this.stats.time('appendLeft') |
| 144 | |
| 145 | this._split(index) |
| 146 | |
| 147 | const chunk = this.byEnd.get(index) |
| 148 | |
| 149 | if (chunk) { |
| 150 | chunk.appendLeft(content) |
| 151 | } |
| 152 | else { |
| 153 | this.intro += content |
| 154 | } |
| 155 | |
| 156 | if (DEBUG) |
| 157 | this.stats.timeEnd('appendLeft') |
| 158 | return this |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Appends the specified content at the index in the original string. |
no test coverage detected