* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
(index: number, content: string)
| 883 | * Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index |
| 884 | */ |
| 885 | prependLeft(index: number, content: string): this { |
| 886 | index = index + this.offset |
| 887 | |
| 888 | if (typeof content !== 'string') { |
| 889 | throw new MagicStringError(`content must be a string, got ${typeof content}`) |
| 890 | } |
| 891 | |
| 892 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 893 | if (DEBUG) |
| 894 | this.stats.time('insertRight') |
| 895 | |
| 896 | this._split(index) |
| 897 | |
| 898 | const chunk = this.byEnd.get(index) |
| 899 | |
| 900 | if (chunk) { |
| 901 | chunk.prependLeft(content) |
| 902 | } |
| 903 | else { |
| 904 | this.intro = content + this.intro |
| 905 | } |
| 906 | |
| 907 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 908 | if (DEBUG) |
| 909 | this.stats.timeEnd('insertRight') |
| 910 | return this |
| 911 | } |
| 912 | |
| 913 | /** |
| 914 | * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index` |