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