Skip to main content
Module

x/pazza/mod.ts>mapErr

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

Execute the embedded parser. If it fails, apply provided function on the error.

const parser = map(digit(), error => "Not a digit.");
parser("a").error === "Not a digit.";

Type Parameters

T
E1
E2
I extends Input
CtxIn
CtxOut

Parameters

parser: IParser<T, E1, I, CtxIn, CtxOut>

embededd parser

fn: (error: E1) => E2

function to be applied on error