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