Skip to main content
Module

x/pazza/mod.ts>or

Parser combinators library designed for Deno, but also works on browsers and Node.js.
Go to Latest
function or
import { or } from "https://deno.land/x/pazza@v0.3.0/mod.ts";

Attempt to run "left" parser at first. If it succeeds, return its result. If it fails, run "right" parser.

or(digit(), alpha())("4").output === "4";
or(digit(), alpha())("a").output === "a";
or(digit(), alpha())("").ok === false;

Type Parameters

L
R
E
I extends Input
CtxIn
CtxOut

Parameters

left: IParser<L, unknown, I, CtxIn, CtxOut>

left parser

right: IParser<R, E, I, CtxIn, CtxOut>

right parser