Skip to main content
Module

x/ts_toolbelt_unofficial/mod.ts>Function.Compose

👷 TypeScript's largest type utility library, now on Deno
Latest
type alias Function.Compose
import { type Function } from "https://deno.land/x/ts_toolbelt_unofficial@1.1.0/mod.ts";
const { Compose } = Function;

Compose [[Function]]s together

Examples

Example 1

import {F} from 'ts-toolbelt.ts'

/// If you are looking for creating types for `compose`
/// `Composer` will check for input & `Compose` the output
declare const compose: F.Compose

const a = (a1: number) => `${a1}`
const c = (c1: string[]) => [c1]
const b = (b1: string) => [b1]

compose(c, b, a)(42)

/// And if you are looking for an async `compose` type
declare const compose: F.Compose<'async'>

const a = async (a1: number) => `${a1}`
const b = async (b1: string) => [b1]
const c = async (c1: string[]) => [c1]

await compose(c, b, a)(42)

Type Parameters

optional
mode extends Mode = "sync"
optional
input extends Input = "multi"
definition: IntersectOf<{ sync: { multi: ComposeMultiSync; list: ComposeListSync; }; async: { multi: ComposeMultiAsync; list: ComposeListAsync; }; }[mode][input]>