Skip to main content
Module

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

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

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)

Returns

(...args: Parameters<DomainFunction>) => Promise<UnpackData<T>>