Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "Function/Compose"

Index

Type aliases

Compose

Compose<Fns, mode>: { 'sync': (...args: Parameters<Fns[Tail<Fns>["length"]]>) => Return<Head<Fns>>; 'async': (...args: Parameters<Fns[Tail<Fns>["length"]]>) => Promise<PromiseOf<Return<Head<Fns>>>>; }[mode]

Compose Functions together

Type parameters

returns

Function

example

import {F} from 'ts-toolbelt'

/// If you are looking for creating types for `compose`
/// `Composer` will check for input & `Compose` the output
declare function compose<Fns extends F.Function[]>(...args: F.Composer<Fns>): F.Compose<Fns>

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 `pipe` type
declare function compose<Fns extends F.Function[]>(...args: F.Composer<Fns, 'async'>): F.Composer<Fns, '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)

ComposeFnAsync

ComposeFnAsync<Fns, K>: ComposeFnAsync<Fns, K>

Type parameters

ComposeFnSync

ComposeFnSync<Fns, K>: ComposeFnSync<Fns, K>

Type parameters

Composer

Composer<Fns, mode>: { 'sync': { [K in keyof Fns]: ComposeFnSync<Fns, K>; }; 'async': { [K in keyof Fns]: ComposeFnAsync<Fns, K>; }; }[mode]

Compute what the input of Compose should be

Type parameters

  • Fns: Function[]

    to compose

  • mode: Mode

    sync/async (?='sync')

example

Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.