1 |
|
2 | export type UnaryFunction<ValueType, ReturnType> = (
|
3 | value: ValueType
|
4 | ) => ReturnType | PromiseLike<ReturnType>;
|
5 |
|
6 | export type Pipeline<ValueType, ReturnType> = (
|
7 | value?: ValueType
|
8 | ) => Promise<ReturnType>;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | export default function pPipe<ValueType, ReturnType>(
|
30 | f1: UnaryFunction<ValueType, ReturnType>
|
31 | ): Pipeline<ValueType, ReturnType>;
|
32 | export default function pPipe<ValueType, ResultValue1, ReturnType>(
|
33 | f1: UnaryFunction<ValueType, ResultValue1>,
|
34 | f2: UnaryFunction<ResultValue1, ReturnType>
|
35 | ): Pipeline<ValueType, ReturnType>;
|
36 | export default function pPipe<ValueType, ResultValue1, ResultValue2, ReturnType>(
|
37 | f1: UnaryFunction<ValueType, ResultValue1>,
|
38 | f2: UnaryFunction<ResultValue1, ResultValue2>,
|
39 | f3: UnaryFunction<ResultValue2, ReturnType>
|
40 | ): Pipeline<ValueType, ReturnType>;
|
41 | export default function pPipe<
|
42 | ValueType,
|
43 | ResultValue1,
|
44 | ResultValue2,
|
45 | ResultValue3,
|
46 | ReturnType
|
47 | >(
|
48 | f1: UnaryFunction<ValueType, ResultValue1>,
|
49 | f2: UnaryFunction<ResultValue1, ResultValue2>,
|
50 | f3: UnaryFunction<ResultValue2, ResultValue3>,
|
51 | f4: UnaryFunction<ResultValue3, ReturnType>
|
52 | ): Pipeline<ValueType, ReturnType>;
|
53 | export default function pPipe<
|
54 | ValueType,
|
55 | ResultValue1,
|
56 | ResultValue2,
|
57 | ResultValue3,
|
58 | ResultValue4,
|
59 | ReturnType
|
60 | >(
|
61 | f1: UnaryFunction<ValueType, ResultValue1>,
|
62 | f2: UnaryFunction<ResultValue1, ResultValue2>,
|
63 | f3: UnaryFunction<ResultValue2, ResultValue3>,
|
64 | f4: UnaryFunction<ResultValue3, ResultValue4>,
|
65 | f5: UnaryFunction<ResultValue4, ReturnType>
|
66 | ): Pipeline<ValueType, ReturnType>;
|
67 | export default function pPipe<
|
68 | ValueType,
|
69 | ResultValue1,
|
70 | ResultValue2,
|
71 | ResultValue3,
|
72 | ResultValue4,
|
73 | ResultValue5,
|
74 | ReturnType
|
75 | >(
|
76 | f1: UnaryFunction<ValueType, ResultValue1>,
|
77 | f2: UnaryFunction<ResultValue1, ResultValue2>,
|
78 | f3: UnaryFunction<ResultValue2, ResultValue3>,
|
79 | f4: UnaryFunction<ResultValue3, ResultValue4>,
|
80 | f5: UnaryFunction<ResultValue4, ResultValue5>,
|
81 | f6: UnaryFunction<ResultValue5, ReturnType>
|
82 | ): Pipeline<ValueType, ReturnType>;
|
83 | export default function pPipe<
|
84 | ValueType,
|
85 | ResultValue1,
|
86 | ResultValue2,
|
87 | ResultValue3,
|
88 | ResultValue4,
|
89 | ResultValue5,
|
90 | ResultValue6,
|
91 | ReturnType
|
92 | >(
|
93 | f1: UnaryFunction<ValueType, ResultValue1>,
|
94 | f2: UnaryFunction<ResultValue1, ResultValue2>,
|
95 | f3: UnaryFunction<ResultValue2, ResultValue3>,
|
96 | f4: UnaryFunction<ResultValue3, ResultValue4>,
|
97 | f5: UnaryFunction<ResultValue4, ResultValue5>,
|
98 | f6: UnaryFunction<ResultValue5, ResultValue6>,
|
99 | f7: UnaryFunction<ResultValue6, ReturnType>
|
100 | ): Pipeline<ValueType, ReturnType>;
|
101 | export default function pPipe<
|
102 | ValueType,
|
103 | ResultValue1,
|
104 | ResultValue2,
|
105 | ResultValue3,
|
106 | ResultValue4,
|
107 | ResultValue5,
|
108 | ResultValue6,
|
109 | ResultValue7,
|
110 | ReturnType
|
111 | >(
|
112 | f1: UnaryFunction<ValueType, ResultValue1>,
|
113 | f2: UnaryFunction<ResultValue1, ResultValue2>,
|
114 | f3: UnaryFunction<ResultValue2, ResultValue3>,
|
115 | f4: UnaryFunction<ResultValue3, ResultValue4>,
|
116 | f5: UnaryFunction<ResultValue4, ResultValue5>,
|
117 | f6: UnaryFunction<ResultValue5, ResultValue6>,
|
118 | f7: UnaryFunction<ResultValue6, ResultValue7>,
|
119 | f8: UnaryFunction<ResultValue7, ReturnType>
|
120 | ): Pipeline<ValueType, ReturnType>;
|
121 | export default function pPipe<
|
122 | ValueType,
|
123 | ResultValue1,
|
124 | ResultValue2,
|
125 | ResultValue3,
|
126 | ResultValue4,
|
127 | ResultValue5,
|
128 | ResultValue6,
|
129 | ResultValue7,
|
130 | ResultValue8,
|
131 | ReturnType
|
132 | >(
|
133 | f1: UnaryFunction<ValueType, ResultValue1>,
|
134 | f2: UnaryFunction<ResultValue1, ResultValue2>,
|
135 | f3: UnaryFunction<ResultValue2, ResultValue3>,
|
136 | f4: UnaryFunction<ResultValue3, ResultValue4>,
|
137 | f5: UnaryFunction<ResultValue4, ResultValue5>,
|
138 | f6: UnaryFunction<ResultValue5, ResultValue6>,
|
139 | f7: UnaryFunction<ResultValue6, ResultValue7>,
|
140 | f8: UnaryFunction<ResultValue7, ResultValue8>,
|
141 | f9: UnaryFunction<ResultValue8, ReturnType>
|
142 | ): Pipeline<ValueType, ReturnType>;
|
143 |
|
144 |
|
145 | export default function pPipe(
|
146 | ...functions: Array<UnaryFunction<any, unknown>>
|
147 | ): Pipeline<unknown, unknown>;
|