Skip to main content
Module

x/domain_functions/src/index.ts>map

Decouple your business logic from your framework. With first-class type inference from end to end.
Go to Latest
function map
import { map } from "https://deno.land/x/domain_functions@v2.6.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>