|
| 1 | +/* eslint-disable @typescript-eslint/max-params */ |
| 2 | +import { type AnyFunction } from "./types/anyFunction"; |
| 3 | +import { type AnyValue } from "./types/anyValue"; |
| 4 | + |
| 5 | +export function pipe< |
| 6 | + GenericInput extends AnyValue, |
| 7 | + GenericOutputPipe1 extends AnyValue, |
| 8 | +>( |
| 9 | + input: GenericInput, |
| 10 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 11 | +): GenericOutputPipe1; |
| 12 | +export function pipe< |
| 13 | + GenericInput extends AnyValue, |
| 14 | + GenericOutputPipe1 extends AnyValue, |
| 15 | + GenericOutputPipe2 extends AnyValue, |
| 16 | +>( |
| 17 | + input: GenericInput, |
| 18 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 19 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 20 | +): GenericOutputPipe2; |
| 21 | +export function pipe< |
| 22 | + GenericInput extends AnyValue, |
| 23 | + GenericOutputPipe1 extends AnyValue, |
| 24 | + GenericOutputPipe2 extends AnyValue, |
| 25 | + GenericOutputPipe3 extends AnyValue, |
| 26 | +>( |
| 27 | + input: GenericInput, |
| 28 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 29 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 30 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 31 | +): GenericOutputPipe3; |
| 32 | +export function pipe< |
| 33 | + GenericInput extends AnyValue, |
| 34 | + GenericOutputPipe1 extends AnyValue, |
| 35 | + GenericOutputPipe2 extends AnyValue, |
| 36 | + GenericOutputPipe3 extends AnyValue, |
| 37 | + GenericOutputPipe4 extends AnyValue, |
| 38 | +>( |
| 39 | + input: GenericInput, |
| 40 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 41 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 42 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 43 | + pipe4: (input: GenericOutputPipe3) => GenericOutputPipe4, |
| 44 | +): GenericOutputPipe4; |
| 45 | +export function pipe< |
| 46 | + GenericInput extends AnyValue, |
| 47 | + GenericOutputPipe1 extends AnyValue, |
| 48 | + GenericOutputPipe2 extends AnyValue, |
| 49 | + GenericOutputPipe3 extends AnyValue, |
| 50 | + GenericOutputPipe4 extends AnyValue, |
| 51 | + GenericOutputPipe5 extends AnyValue, |
| 52 | +>( |
| 53 | + input: GenericInput, |
| 54 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 55 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 56 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 57 | + pipe4: (input: GenericOutputPipe3) => GenericOutputPipe4, |
| 58 | + pipe5: (input: GenericOutputPipe4) => GenericOutputPipe5, |
| 59 | +): GenericOutputPipe5; |
| 60 | +export function pipe< |
| 61 | + GenericInput extends AnyValue, |
| 62 | + GenericOutputPipe1 extends AnyValue, |
| 63 | + GenericOutputPipe2 extends AnyValue, |
| 64 | + GenericOutputPipe3 extends AnyValue, |
| 65 | + GenericOutputPipe4 extends AnyValue, |
| 66 | + GenericOutputPipe5 extends AnyValue, |
| 67 | + GenericOutputPipe6 extends AnyValue, |
| 68 | +>( |
| 69 | + input: GenericInput, |
| 70 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 71 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 72 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 73 | + pipe4: (input: GenericOutputPipe3) => GenericOutputPipe4, |
| 74 | + pipe5: (input: GenericOutputPipe4) => GenericOutputPipe5, |
| 75 | + pipe6: (input: GenericOutputPipe5) => GenericOutputPipe6, |
| 76 | +): GenericOutputPipe6; |
| 77 | +export function pipe< |
| 78 | + GenericInput extends AnyValue, |
| 79 | + GenericOutputPipe1 extends AnyValue, |
| 80 | + GenericOutputPipe2 extends AnyValue, |
| 81 | + GenericOutputPipe3 extends AnyValue, |
| 82 | + GenericOutputPipe4 extends AnyValue, |
| 83 | + GenericOutputPipe5 extends AnyValue, |
| 84 | + GenericOutputPipe6 extends AnyValue, |
| 85 | + GenericOutputPipe7 extends AnyValue, |
| 86 | +>( |
| 87 | + input: GenericInput, |
| 88 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 89 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 90 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 91 | + pipe4: (input: GenericOutputPipe3) => GenericOutputPipe4, |
| 92 | + pipe5: (input: GenericOutputPipe4) => GenericOutputPipe5, |
| 93 | + pipe6: (input: GenericOutputPipe5) => GenericOutputPipe6, |
| 94 | + pipe7: (input: GenericOutputPipe6) => GenericOutputPipe7, |
| 95 | +): GenericOutputPipe7; |
| 96 | +export function pipe< |
| 97 | + GenericInput extends AnyValue, |
| 98 | + GenericOutputPipe1 extends AnyValue, |
| 99 | + GenericOutputPipe2 extends AnyValue, |
| 100 | + GenericOutputPipe3 extends AnyValue, |
| 101 | + GenericOutputPipe4 extends AnyValue, |
| 102 | + GenericOutputPipe5 extends AnyValue, |
| 103 | + GenericOutputPipe6 extends AnyValue, |
| 104 | + GenericOutputPipe7 extends AnyValue, |
| 105 | + GenericOutputPipe8 extends AnyValue, |
| 106 | +>( |
| 107 | + input: GenericInput, |
| 108 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 109 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 110 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 111 | + pipe4: (input: GenericOutputPipe3) => GenericOutputPipe4, |
| 112 | + pipe5: (input: GenericOutputPipe4) => GenericOutputPipe5, |
| 113 | + pipe6: (input: GenericOutputPipe5) => GenericOutputPipe6, |
| 114 | + pipe7: (input: GenericOutputPipe6) => GenericOutputPipe7, |
| 115 | + pipe8: (input: GenericOutputPipe7) => GenericOutputPipe8, |
| 116 | +): GenericOutputPipe8; |
| 117 | +export function pipe< |
| 118 | + GenericInput extends AnyValue, |
| 119 | + GenericOutputPipe1 extends AnyValue, |
| 120 | + GenericOutputPipe2 extends AnyValue, |
| 121 | + GenericOutputPipe3 extends AnyValue, |
| 122 | + GenericOutputPipe4 extends AnyValue, |
| 123 | + GenericOutputPipe5 extends AnyValue, |
| 124 | + GenericOutputPipe6 extends AnyValue, |
| 125 | + GenericOutputPipe7 extends AnyValue, |
| 126 | + GenericOutputPipe8 extends AnyValue, |
| 127 | + GenericOutputPipe9 extends AnyValue, |
| 128 | +>( |
| 129 | + input: GenericInput, |
| 130 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 131 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 132 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 133 | + pipe4: (input: GenericOutputPipe3) => GenericOutputPipe4, |
| 134 | + pipe5: (input: GenericOutputPipe4) => GenericOutputPipe5, |
| 135 | + pipe6: (input: GenericOutputPipe5) => GenericOutputPipe6, |
| 136 | + pipe7: (input: GenericOutputPipe6) => GenericOutputPipe7, |
| 137 | + pipe8: (input: GenericOutputPipe7) => GenericOutputPipe8, |
| 138 | + pipe9: (input: GenericOutputPipe8) => GenericOutputPipe9, |
| 139 | +): GenericOutputPipe9; |
| 140 | +export function pipe< |
| 141 | + GenericInput extends AnyValue, |
| 142 | + GenericOutputPipe1 extends AnyValue, |
| 143 | + GenericOutputPipe2 extends AnyValue, |
| 144 | + GenericOutputPipe3 extends AnyValue, |
| 145 | + GenericOutputPipe4 extends AnyValue, |
| 146 | + GenericOutputPipe5 extends AnyValue, |
| 147 | + GenericOutputPipe6 extends AnyValue, |
| 148 | + GenericOutputPipe7 extends AnyValue, |
| 149 | + GenericOutputPipe8 extends AnyValue, |
| 150 | + GenericOutputPipe9 extends AnyValue, |
| 151 | + GenericOutputPipe10 extends AnyValue, |
| 152 | +>( |
| 153 | + input: GenericInput, |
| 154 | + pipe1: (input: GenericInput) => GenericOutputPipe1, |
| 155 | + pipe2: (input: GenericOutputPipe1) => GenericOutputPipe2, |
| 156 | + pipe3: (input: GenericOutputPipe2) => GenericOutputPipe3, |
| 157 | + pipe4: (input: GenericOutputPipe3) => GenericOutputPipe4, |
| 158 | + pipe5: (input: GenericOutputPipe4) => GenericOutputPipe5, |
| 159 | + pipe6: (input: GenericOutputPipe5) => GenericOutputPipe6, |
| 160 | + pipe7: (input: GenericOutputPipe6) => GenericOutputPipe7, |
| 161 | + pipe8: (input: GenericOutputPipe7) => GenericOutputPipe8, |
| 162 | + pipe9: (input: GenericOutputPipe8) => GenericOutputPipe9, |
| 163 | + pipe10: (input: GenericOutputPipe9) => GenericOutputPipe10, |
| 164 | +): GenericOutputPipe10; |
| 165 | +export function pipe(input: AnyValue, ...pipes: AnyFunction[]) { |
| 166 | + let acc = input; |
| 167 | + |
| 168 | + for (const pipe of pipes) { |
| 169 | + acc = pipe(acc); |
| 170 | + } |
| 171 | + |
| 172 | + return acc; |
| 173 | +} |
0 commit comments