- token<TToken, TOptions, TValue>(onToken: ((token: TToken, data: Data<TToken, TOptions>, i: number) => undefined | TValue), onEnd?: ((data: Data<TToken, TOptions>, i: number) => void)): Parser<TToken, TOptions, TValue>
-
Parameters
-
onToken: ((token: TToken, data: Data<TToken, TOptions>, i: number) => undefined | TValue)
-
- (token: TToken, data: Data<TToken, TOptions>, i: number): undefined | TValue
-
Parameters
-
token: TToken
-
data: Data<TToken, TOptions>
-
i: number
Returns undefined | TValue
-
Optional
onEnd: ((data: Data<TToken, TOptions>, i: number) => void)
-
- (data: Data<TToken, TOptions>, i: number): void
-
Parameters
-
data: Data<TToken, TOptions>
-
i: number
Returns void
Returns Parser<TToken, TOptions, TValue>
Make a parser based on a token-to-value function.
Nonmatch is produced if
undefined
value is returned by a function.Use make if you want to produce a value without consuming a token.
You can use satisfy if you just want to test but not transform the value.