(text: string, from: number, to: number)
| 44 | |
| 45 | /** Delete the half-open range [from,to) (order-independent). Returns text + cursor at range start. */ |
| 46 | export function deleteRange(text: string, from: number, to: number): { text: string; cursor: number } { |
| 47 | const a = Math.max(0, Math.min(from, to)); |
| 48 | const b = Math.min(text.length, Math.max(from, to)); |
| 49 | return { text: text.slice(0, a) + text.slice(b), cursor: a }; |
| 50 | } |
| 51 | |
| 52 | /** Replace the range [from,to) with `s`. Returns text + cursor after the inserted text. */ |
| 53 | export function replaceRange(text: string, from: number, to: number, s: string): { text: string; cursor: number } { |
no outgoing calls
no test coverage detected