(...funcs: Function[])
| 44 | export default function compose<R>(...funcs: Function[]): (...args: any[]) => R |
| 45 | |
| 46 | export default function compose(...funcs: Function[]) { |
| 47 | if (funcs.length === 0) { |
| 48 | class="cm">// infer the argument type so it is usable in inference down the line |
| 49 | return <T>(arg: T) => arg |
| 50 | } |
| 51 | |
| 52 | if (funcs.length === 1) { |
| 53 | return funcs[0] |
| 54 | } |
| 55 | |
| 56 | return funcs.reduce( |
| 57 | (a, b) => |
| 58 | (...args: any) => |
| 59 | a(b(...args)) |
| 60 | ) |
| 61 | } |
no test coverage detected