Skip to main content
Module

x/domain_functions/src/domain-functions.ts>first

Decouple your business logic from your framework. With first-class type inference from end to end.
Go to Latest
function first
import { first } from "https://deno.land/x/domain_functions@v2.6.0/src/domain-functions.ts";

Creates a composite domain function that will return the result of the first successful constituent domain function. It is important to notice that all constituent domain functions will be executed in parallel, so be mindful of the side effects.

Examples

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

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