import { fromSuccess } from "https://deno.land/x/domain_functions@v2.6.0/src/index.ts";
It can be used to call a domain function from another domain function. It will return the output of the given domain function if it was successfull, otherwise it will throw a ResultError
that will bubble up to the parent function.
Also good to use it in successfull test cases.
Examples
import { mdf, fromSuccess } from 'domain-functions'
import { mdf, fromSuccess } from 'domain-functions'
const add1 = mdf(z.number())((n) => n + 1) const result = await add1(1) // ^? Result const data = await fromSuccess(add1)(n) // ^? number expect(data).toBe(n + 1)
Type Parameters
T extends DomainFunction
Parameters
df: T
Returns
(...args: Parameters<DomainFunction>) => Promise<UnpackData<T>>