tryRun
Signature
ts
interface Runnable<T> {
with(input: string): Success<T>
}
function tryRun<T>(parser: Parser<T>): Runnable<T>Description
tryRun is is used to run parser with provided input, throwing ParserError on failure.
Usage
ts
tryRun(string('hello world')).with('hello world')Success
ts
{
isOk: true,
span: [ 0, 11 ],
pos: 11,
value: 'hello world'
}Failure
ts
<ParserError>