• Make a parser that runs a given parser, passes the matched value into a parser-generating function and then runs the returned parser.

    A nonmatch is returned if any of two parsers did not match.

    Similar to decide in that it allows for complex logic.

    Use condition if there is no dependency on the value of the first parser.

    Combine with chainReduce to get a stack-safe chain of arbitrary length.

    Type Parameters

    • TToken

    • TOptions

    • TValue1

    • TValue2

    Parameters

    • p: Parser<TToken, TOptions, TValue1>

      A parser.

    • f: ((v1: TValue1, data: Data<TToken, TOptions>, i: number, j: number) => Parser<TToken, TOptions, TValue2>)

      A function that returns a parser based on the input value.

        • (v1: TValue1, data: Data<TToken, TOptions>, i: number, j: number): Parser<TToken, TOptions, TValue2>
        • Parameters

          • v1: TValue1

            A value from the first parser.

          • data: Data<TToken, TOptions>

            Data object (tokens and options).

          • i: number

            Parser position in the tokens array (before the first parser matched).

          • j: number

            Parser position in the tokens array (after the first parser matched).

          Returns Parser<TToken, TOptions, TValue2>

    Returns Parser<TToken, TOptions, TValue2>

Generated using TypeDoc