1 | import { IntersectOf } from '../Union/IntersectOf';
|
2 | import { ComposeListAsync } from './Compose/List/Async';
|
3 | import { ComposeListSync } from './Compose/List/Sync';
|
4 | import { ComposeMultiAsync } from './Compose/Multi/Async';
|
5 | import { ComposeMultiSync } from './Compose/Multi/Sync';
|
6 | import { Input, Mode } from './_Internal';
|
7 | /**
|
8 | * Compose [[Function]]s together
|
9 | * @param mode (?=`'sync'`) sync/async (this depends on your implementation)
|
10 | * @param input (?=`'multi'`) whether you want it to take a list or parameters
|
11 | * @example
|
12 | * ```ts
|
13 | * import {F} from 'ts-toolbelt'
|
14 | *
|
15 | * /// If you are looking for creating types for `compose`
|
16 | * /// `Composer` will check for input & `Compose` the output
|
17 | * declare const compose: F.Compose
|
18 | *
|
19 | * const a = (a1: number) => `${a1}`
|
20 | * const c = (c1: string[]) => [c1]
|
21 | * const b = (b1: string) => [b1]
|
22 | *
|
23 | * compose(c, b, a)(42)
|
24 | *
|
25 | * /// And if you are looking for an async `compose` type
|
26 | * declare const compose: F.Compose<'async'>
|
27 | *
|
28 | * const a = async (a1: number) => `${a1}`
|
29 | * const b = async (b1: string) => [b1]
|
30 | * const c = async (c1: string[]) => [c1]
|
31 | *
|
32 | * await compose(c, b, a)(42)
|
33 | */
|
34 | export declare type Compose<mode extends Mode = 'sync', input extends Input = 'multi'> = IntersectOf<{
|
35 | 'sync': {
|
36 | 'multi': ComposeMultiSync;
|
37 | 'list': ComposeListSync;
|
38 | };
|
39 | 'async': {
|
40 | 'multi': ComposeMultiAsync;
|
41 | 'list': ComposeListAsync;
|
42 | };
|
43 | }[mode][input]>;
|