- map1<TToken, TOptions, TValue1, TValue2>(p: Parser<TToken, TOptions, TValue1>, mapper: ((m: Match<TValue1>, data: Data<TToken, TOptions>, i: number) => Result<TValue2>)): Parser<TToken, TOptions, TValue2>
-
Type Parameters
-
TToken
-
TOptions
-
TValue1
-
TValue2
Parameters
-
p: Parser<TToken, TOptions, TValue1>
-
mapper: ((m: Match<TValue1>, data: Data<TToken, TOptions>, i: number) => Result<TValue2>)
-
- (m: Match<TValue1>, data: Data<TToken, TOptions>, i: number): Result<TValue2>
-
Parameters
-
m: Match<TValue1>
-
data: Data<TToken, TOptions>
-
i: number
Returns Result<TValue2>
Returns Parser<TToken, TOptions, TValue2>
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.