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