Amazon Vinyl
    Preparing search index...

    Class StringReader

    A cursor on a string that allows for fast, naive parsing.

    Index
    data: string

    The string to read.

    position: number = 0

    The current cursor. This should always be between the range 0 and data.length

    • get peek(): number

      Returns the character at the current position without advancing the cursor.

      Note: This method has no bounds checking; if position is greater than or equal to str.length then NaN will be returned.

      Returns number

      String.charCodeAt

    • If peek equals the given character code, returns true and advances the index by one.

      Parameters

      • charCode: number

      Returns boolean

    • Reads and returns the character code at the current position. To read the next character without advancing the cursor, use peek

      Note: This method has no bounds checking; if position is greater than or equal to str.length then NaN will be returned and position will still be incremented.

      Returns number

      String.charCodeAt

    • Reads the expected string from the current position. If the read string doesn't match the given string, a StringParseError is thrown.

      Parameters

      • str: string

        The string required to match at the current position.

      • ignoreCase: boolean = false

        If true, the comparison will be case-insensitive.

      Returns string

    • Reads the expected char code from the current position. If the read character doesn't match the given character, a StringParseError is thrown.

      Parameters

      • charCode: number

        The character code required to match at the current position.

      Returns number

    • If the given string matches the substring at the current position, returns true and advances the index by the string's length.

      Parameters

      • string: string
      • ignoreCase: boolean = false

      Returns boolean

    • Reads the substring from the current index with the given length.

      Parameters

      • length: number

      Returns string

    • The same as until except returns the read substring as a result.

      Parameters

      • predicate: (charCode: number) => boolean

      Returns string

    • The same as untilChar except returns the read substring as a result.

      Parameters

      • charCode: number

      Returns string

    • The same as while except returns the read substring as a result.

      Parameters

      • predicate: (charCode: number) => boolean

      Returns string

    • Reads characters until the predicate returns true or the string length has been reached.

      Parameters

      • predicate: (charCode: number) => boolean

      Returns number

      number Returns the start index.

    • Reads characters until the given character has been found or the string length has been reached.

      Parameters

      • charCode: number

      Returns number

      number Returns the start index.

    • Reads characters until the given string has been found or the string length has been reached.

      Parameters

      • string: string

        The string to match

      Returns number

      number Returns the start index.

    • Reads characters until the predicate returns false or the data length has been reached.

      Parameters

      • predicate: (charCode: number) => boolean

        Given the char code at the cursor index, returns true if the character should be included in the substring result.

      Returns number

      number The start position.