forked from remeda/remeda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createPipe.ts
63 lines (55 loc) · 1.56 KB
/
createPipe.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { pipe } from './pipe';
/**
* Creates a data-last pipe function. First function must be always annotated. Other functions are automatically inferred.
* @signature
* R.createPipe(op1, op2, op3)(data);
* @example
* R.createPipe(
* (x: number) => x * 2,
* x => x * 3
* )(1) // => 6
* @category Function
*/
export function createPipe<A, B>(op1: (input: A) => B): (value: A) => B;
export function createPipe<A, B, C>(
op1: (input: A) => B,
op2: (input: B) => C
): (value: A) => C;
export function createPipe<A, B, C, D>(
op1: (input: A) => B,
op2: (input: B) => C,
op3: (input: C) => D
): (value: A) => D;
export function createPipe<A, B, C, D, E>(
op1: (input: A) => B,
op2: (input: B) => C,
op3: (input: C) => D,
op4: (input: D) => E
): (value: A) => E;
export function createPipe<A, B, C, D, E, F>(
op1: (input: A) => B,
op2: (input: B) => C,
op3: (input: C) => D,
op4: (input: D) => E,
op5: (input: E) => F
): (value: A) => F;
export function createPipe<A, B, C, D, E, F, G>(
op1: (input: A) => B,
op2: (input: B) => C,
op3: (input: C) => D,
op4: (input: D) => E,
op5: (input: E) => F,
op6: (input: F) => G
): (value: A) => G;
export function createPipe<A, B, C, D, E, F, G, H>(
op1: (input: A) => B,
op2: (input: B) => C,
op3: (input: C) => D,
op4: (input: D) => E,
op5: (input: E) => F,
op6: (input: F) => G,
op7: (input: G) => H
): (value: A) => H;
export function createPipe(...operations: ReadonlyArray<(input: any) => any>) {
return (value: any) => (pipe as any)(value, ...operations);
}