main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import { IntersectOf } from '../Union/IntersectOf';
|
---|
| 2 | import { PipeListAsync } from './Pipe/List/Async';
|
---|
| 3 | import { PipeListSync } from './Pipe/List/Sync';
|
---|
| 4 | import { PipeMultiAsync } from './Pipe/Multi/Async';
|
---|
| 5 | import { PipeMultiSync } from './Pipe/Multi/Sync';
|
---|
| 6 | import { 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 | */
|
---|
| 35 | export 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]>;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.