add codePointAt and don't normalize
This commit is contained in:
parent
7757394fab
commit
345f69fd1c
1 changed files with 11 additions and 1 deletions
12
src/index.ts
12
src/index.ts
|
|
@ -23,7 +23,9 @@ export class SourceText {
|
||||||
readonly lineStarts: CodePointIndex[];
|
readonly lineStarts: CodePointIndex[];
|
||||||
|
|
||||||
constructor(rawSource: string) {
|
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.source = source;
|
||||||
this.chars = [];
|
this.chars = [];
|
||||||
|
|
@ -57,6 +59,10 @@ export class SourceText {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
codePointAt(index: CodePointIndex): CodePoint {
|
||||||
|
return this.chars[index].char;
|
||||||
|
}
|
||||||
|
|
||||||
get length(): number {
|
get length(): number {
|
||||||
return this.chars.length;
|
return this.chars.length;
|
||||||
}
|
}
|
||||||
|
|
@ -196,6 +202,10 @@ export class SourceRegion {
|
||||||
public readonly span: Span
|
public readonly span: Span
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
codePointAt(index: CodePointIndex): CodePoint {
|
||||||
|
return this.source.codePointAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
get length(): number {
|
get length(): number {
|
||||||
return this.span.end.index - this.span.start.index;
|
return this.span.end.index - this.span.start.index;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue