Function takeWhile

  • Make a Matcher that returns all (0 or more) sequential matches of the same given parser while the test function equates to true.

    Use many if there is no stop condition.

    Use takeWhileP if the stop condition is expressed as a parser.

    Type Parameters

    • TToken

    • TOptions

    • TValue

    Parameters

    • p: Parser<TToken, TOptions, TValue>

      A parser.

    • test: ((value: TValue, n: number, data: Data<TToken, TOptions>, i: number, j: number) => boolean)

      Matched results are accumulated while the result of this function is true.

        • (value: TValue, n: number, data: Data<TToken, TOptions>, i: number, j: number): boolean
        • Parameters

          • value: TValue

            Current value matched by the parser.

          • n: number

            Number of matches so far (including the current value).

          • data: Data<TToken, TOptions>

            Data object (tokens and options).

          • i: number

            Parser position in the tokens array (before the current value matched).

          • j: number

            Parser position in the tokens array (after the current value matched).

          Returns boolean

    Returns Matcher<TToken, TOptions, TValue[]>

Generated using TypeDoc