Utility function that provides a bit cleaner interface
for running a parser over a string.
Returns undefined in case parser did not match.
Input string is broken down to characters as [...str]
unless you provide a pre-split array.
Note: this doesn't capture errors thrown during parsing.
Nonmatch is considered a part or normal flow.
Errors mean unrecoverable state and it's up to client code to decide
where to throw errors and how to get back to safe state.
Utility function that provides a bit cleaner interface for running a parser over a string. Returns
undefined
in case parser did not match.Input string is broken down to characters as
[...str]
unless you provide a pre-split array.Note: this doesn't capture errors thrown during parsing. Nonmatch is considered a part or normal flow. Errors mean unrecoverable state and it's up to client code to decide where to throw errors and how to get back to safe state.
Returns
A matched value or
undefined
in case of nonmatch.