source-region/README.md
2026-04-06 15:33:41 +02:00

12 lines
930 B
Markdown

TypeScript library for handling source code strings.
It has its own String type that deals with unicode in a saner than JS's UTF16 strings.
This take in JS string, and makes it into a fat string `SourceText` that handles all the insanity of UTF16 in JS (like JS leaking UTF16 internals so that there are code-points spanning multiple indices in the string array).
- it handles NFC Normalization
- makes the original string easy to traverse in error-free way by introducing a character abstraction - type `CodePoint` and its position within the SourceText called `CodePointIndex`
- It also tracks where line start (handling various platform specific weirdness like `\r\n`)
It also allows for Spatial Tracking or verious sub-regions within the source. It introduces
- point-like `SourceLocation` abstraction (basically where a cursor could be)
- and interval-like `Span` abstraction (basically what a mouse selection could span)