UNPKG

1.35 kBTypeScriptView Raw
1import { IntersectOf } from '../Union/IntersectOf';
2import { PipeListAsync } from './Pipe/List/Async';
3import { PipeListSync } from './Pipe/List/Sync';
4import { PipeMultiAsync } from './Pipe/Multi/Async';
5import { PipeMultiSync } from './Pipe/Multi/Sync';
6import { Input, Mode } from './_Internal';
7/**
8 * Pipe [[Function]]s together
9 * @param mode (?=`'sync'`) sync/async (this depends on your implementation)
10 * @param input (?=`'multi'`) whether you want to take a list or multiple parameters
11 * @returns [[Function]]
12 * @example
13 * ```ts
14 * import {F} from 'ts-toolbelt'
15 *
16 * /// If you are looking for creating types for `pipe`:
17 * declare const pipe: F.Pipe
18 *
19 * const a = (a1: number) => `${a1}`
20 * const b = (b1: string) => [b1]
21 * const c = (c1: string[]) => [c1]
22 *
23 * pipe(a, b, c)(42)
24 *
25 * /// And if you are looking for an async `pipe` type:
26 * declare const pipe: F.Pipe<'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 pipe(a, b, c)(42)
33 * ```
34 */
35export declare type Pipe<mode extends Mode = 'sync', input extends Input = 'multi'> = IntersectOf<{
36 'sync': {
37 'multi': PipeMultiSync;
38 'list': PipeListSync;
39 };
40 'async': {
41 'multi': PipeMultiAsync;
42 'list': PipeListAsync;
43 };
44}[mode][input]>;