condition< TToken , TOptions , TValueA , TValueB > ( cond: ( ( data: Data < TToken , TOptions > , i: number ) => boolean ) , pTrue: Matcher < TToken , TOptions , TValueA > , pFalse: Matcher < TToken , TOptions , TValueB > ) : Matcher < TToken , TOptions , TValueA | TValueB >
Type Parameters
TToken
TOptions
TValueA
TValueB
Parameters
cond: ( ( data: Data < TToken , TOptions > , i: number ) => boolean )
( data: Data < TToken , TOptions > , i: number ) : boolean
Parameters
data: Data < TToken , TOptions >
i: number
Returns boolean
pTrue: Matcher < TToken , TOptions , TValueA >
pFalse: Matcher < TToken , TOptions , TValueB >
Returns Matcher < TToken , TOptions , TValueA | TValueB >
condition< TToken , TOptions , TValueA , TValueB > ( cond: ( ( data: Data < TToken , TOptions > , i: number ) => boolean ) , pTrue: Parser < TToken , TOptions , TValueA > , pFalse: Parser < TToken , TOptions , TValueB > ) : Parser < TToken , TOptions , TValueA | TValueB >
Type Parameters
TToken
TOptions
TValueA
TValueB
Parameters
cond: ( ( data: Data < TToken , TOptions > , i: number ) => boolean )
( data: Data < TToken , TOptions > , i: number ) : boolean
Parameters
data: Data < TToken , TOptions >
i: number
Returns boolean
pTrue: Parser < TToken , TOptions , TValueA >
pFalse: Parser < TToken , TOptions , TValueB >
Returns Parser < TToken , TOptions , TValueA | TValueB >
This overload makes a Matcher that chooses between two given matchers based on a condition. This makes possible to allow/disallow a grammar based on context/options.
decide and chain allow for more complex dynamic rules.