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