• Make a new parser that transforms the match from a given parser.

    This version can discard a Match - return a NonMatch instead.

    Note: pay attention to the return type and indices.

    Use map if mapping exists for all matched values.

    Type Parameters

    • TToken

    • TOptions

    • TValue1

    • TValue2

    Parameters

    • p: Parser<TToken, TOptions, TValue1>

      A base parser.

    • mapper: ((m: Match<TValue1>, data: Data<TToken, TOptions>, i: number) => Result<TValue2>)

      A function that modifies the match.

        • (m: Match<TValue1>, data: Data<TToken, TOptions>, i: number): Result<TValue2>
        • Returns

          A transformed Result object - either Match or NonMatch.

          Parameters

          • m: Match<TValue1>

            A Match object from the base parser (contains the value and the position after the match).

          • data: Data<TToken, TOptions>

            Data object (tokens and options).

          • i: number

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

          Returns Result<TValue2>

    Returns Parser<TToken, TOptions, TValue2>

Generated using TypeDoc