Skip to main content
Module

x/domain_functions/src/index.ts>map

Types and functions to make composition easy and safe
Latest
function map
import { map } from "https://deno.land/x/domain_functions@v3.0.0/src/index.ts";

It takes a domain function and a predicate to apply a transformation over the result.data of that function. It only runs if the function was successfull. When the given domain function fails, its error is returned wihout changes.

Examples

import { mdf, map } from 'domain-functions'

const a = mdf(z.object({ n: z.number() }))(({ n }) => n + 1) const df = map(a, (n) => String(n)) // ^? DomainFunction

Parameters

mapper: (element: O) => R | Promise<R>