/
createPipe.ts
76 lines (67 loc) · 1.94 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
64
65
66
67
68
69
70
71
72
73
74
75
76
/* eslint-disable jsdoc/require-param -- ignore for deprecated files */
import { pipe } from "./pipe";
/**
* Creates a data-last pipe function. First function must be always annotated. Other functions are automatically inferred.
*
* ! **DEPRECATED**: Use `R.piped(op1, op2, op3)`. Will be removed in V2!
*
* @signature
* R.createPipe(op1, op2, op3)(data);
* @example
* R.createPipe(
* (x: number) => x * 2,
* x => x * 3
* )(1) // => 6
* @category Deprecated
* @deprecated Use `R.piped(op1, op2, op3)`. Will be removed in V2!
*/
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: unknown) => unknown>
) {
return (value: unknown): unknown =>
pipe(
value,
// @ts-expect-error [ts2556] - We can't avoid this error because pipe is typed for users and this is an internal function
...operations,
);
}