import { decoder } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { dimap } = decoder;
Map over the input and output of a Decoder. This is effectively a combination of map and premap in a single operator.
Examples
Example 1
Example 1
import * as D from "./decoder.ts";
import { pipe } from "./fn.ts";
const fromStr = pipe(
D.tuple(D.string, D.string),
D.dimap(
(s) => [s, s],
([s]) => [s, s.length] as const,
),
);
const result1 = fromStr("hello"); // Right(["hello", 5])
const result2 = fromStr(null); // Left(DecodeError)