* 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)
| 221 | * See also `s.prependLeft(...)`. |
| 222 | */ |
| 223 | appendLeft(index: number, content: string): this { |
| 224 | index = index + this.offset |
| 225 | |
| 226 | if (typeof content !== 'string') { |
| 227 | throw new MagicStringError(`content must be a string, got ${typeof content}`) |
| 228 | } |
| 229 | |
| 230 | if (DEBUG) |
| 231 | this.stats.time('appendLeft') |
| 232 | |
| 233 | this._split(index) |
| 234 | |
| 235 | const chunk = this.byEnd.get(index) |
| 236 | |
| 237 | if (chunk) { |
| 238 | chunk.appendLeft(content) |
| 239 | } |
| 240 | else { |
| 241 | this.intro += content |
| 242 | } |
| 243 | |
| 244 | if (DEBUG) |
| 245 | this.stats.timeEnd('appendLeft') |
| 246 | return this |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Appends the specified content at the index in the original string. |
no test coverage detected