Skip to main content
Module

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

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

Receives a Record of domain functions, runs them all in sequence like pipe but preserves the shape of that record for the data property in successful results. It will pass the same environment to all given functions, and it will pass the output of a function as the next function's input in the given order.

NOTE : After ECMAScript2015 JS is able to keep the order of keys in an object, we are relying on that. However, number-like keys such as { 1: 'foo' } will be ordered and may break the given order.

Examples

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

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

Type Parameters

Fns extends Record<string, DomainFunction>