diff --git a/src/index.ts b/src/index.ts index 620c4c2..e3a9678 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,9 @@ export class SourceText { readonly lineStarts: CodePointIndex[]; constructor(rawSource: string) { - const source = rawSource.normalize('NFC'); + // TODO: This shouldn't really be a concern of the library. + // const source = rawSource.normalize('NFC'); + const source = rawSource; this.source = source; this.chars = []; @@ -57,6 +59,10 @@ export class SourceText { } } + codePointAt(index: CodePointIndex): CodePoint { + return this.chars[index].char; + } + get length(): number { return this.chars.length; } @@ -196,6 +202,10 @@ export class SourceRegion { public readonly span: Span ) {} + codePointAt(index: CodePointIndex): CodePoint { + return this.source.codePointAt(index); + } + get length(): number { return this.span.end.index - this.span.start.index; }