This commit is contained in:
2026-03-31 16:38:22 -07:00
commit 38940436a7
2112 changed files with 376929 additions and 0 deletions

View File

@ -0,0 +1,91 @@
/** @private */
export declare class StringScanner {
charIndex: number;
readonly string: string;
private readonly charCount;
private readonly charsToBytes;
private readonly length;
private readonly multiByteMode;
constructor(string: string);
/**
* Whether the current character index is at the end of the input string.
*/
get isEnd(): boolean;
/**
* Returns the number of characters in the given string, which may differ from
* the byte length if the string contains multibyte characters.
*/
protected charLength(string: string, multiByteSafe?: boolean): number;
/**
* Advances the scanner by the given number of characters, stopping if the end
* of the string is reached.
*/
advance(count?: number): void;
/**
* Returns the byte index of the given character index in the string. The two
* may differ in strings that contain multibyte characters.
*/
charIndexToByteIndex(charIndex?: number): number;
/**
* Consumes and returns the given number of characters if possible, advancing
* the scanner and stopping if the end of the string is reached.
*
* If no characters could be consumed, an empty string will be returned.
*/
consume(charCount?: number): string;
/**
* Consumes and returns the given number of bytes if possible, advancing the
* scanner and stopping if the end of the string is reached.
*
* It's up to the caller to ensure that the given byte count doesn't split a
* multibyte character.
*
* If no bytes could be consumed, an empty string will be returned.
*/
consumeBytes(byteCount: number): string;
/**
* Consumes and returns all characters for which the given function returns
* `true`, stopping when `false` is returned or the end of the input is
* reached.
*/
consumeMatchFn(fn: (char: string) => boolean): string;
/**
* Consumes the given string if it exists at the current character index, and
* advances the scanner.
*
* If the given string doesn't exist at the current character index, an empty
* string will be returned and the scanner will not be advanced.
*/
consumeString(stringToConsume: string): string;
/**
* Consumes characters until the given global regex is matched, advancing the
* scanner up to (but not beyond) the beginning of the match. If the regex
* doesn't match, nothing will be consumed.
*
* Returns the consumed string, or an empty string if nothing was consumed.
*/
consumeUntilMatch(regex: RegExp): string;
/**
* Consumes characters until the given string is found, advancing the scanner
* up to (but not beyond) that point. If the string is never found, nothing
* will be consumed.
*
* Returns the consumed string, or an empty string if nothing was consumed.
*/
consumeUntilString(searchString: string): string;
/**
* Returns the given number of characters starting at the current character
* index, without advancing the scanner and without exceeding the end of the
* input string.
*/
peek(count?: number): string;
/**
* Resets the scanner position to the given character _index_, or to the start
* of the input string if no index is given.
*
* If _index_ is negative, the scanner position will be moved backward by that
* many characters, stopping if the beginning of the string is reached.
*/
reset(index?: number): void;
}
//# sourceMappingURL=StringScanner.d.ts.map