Loading homepage
Slice text while clipping, shifting, and preserving overlapping style ranges without mutating the original.
Input: sliceStyledText({ text: "Hello world", ranges: [{ start: 0, end: 5, style: "bold" }] }, 2, 8); Output: { text: "llo wo", ranges: [{ start: 0, end: 3, style: "bold" }] }
Input: sliceStyledText({ text: "abcdef", ranges: [{ start: 2, end: 6, style: "italic" }] }, -3); Output: { text: "def", ranges: [{ start: 0, end: 3, style: "italic" }] }
Implement the exported styled-text utility in index.js or index.ts. Tests cover the documented scope and edge cases.