* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
(index: number, content: string)
| 819 | * Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index |
| 820 | */ |
| 821 | prependLeft(index: number, content: string): this { |
| 822 | index = index + this.offset |
| 823 | |
| 824 | if (typeof content !== 'string') { |
| 825 | throw new MagicStringError(`content must be a string, got ${typeof content}`) |
| 826 | } |
| 827 | |
| 828 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 829 | if (DEBUG) |
| 830 | this.stats.time('insertRight') |
| 831 | |
| 832 | this._split(index) |
| 833 | |
| 834 | const chunk = this.byEnd.get(index) |
| 835 | |
| 836 | if (chunk) { |
| 837 | chunk.prependLeft(content) |
| 838 | } |
| 839 | else { |
| 840 | this.intro = content + this.intro |
| 841 | } |
| 842 | |
| 843 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 844 | if (DEBUG) |
| 845 | this.stats.timeEnd('insertRight') |
| 846 | return this |
| 847 | } |
| 848 | |
| 849 | /** |
| 850 | * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index` |