(...funcs)
| 13 | * Thank you Dan Abramov for this code! |
| 14 | */ |
| 15 | export function compose(...funcs) { |
| 16 | return (...args) => { |
| 17 | /* istanbul ignore next */ |
| 18 | if (funcs.length === 0) { |
| 19 | return args[0]; |
| 20 | } |
| 21 | |
| 22 | const last = funcs[funcs.length - 1]; |
| 23 | const rest = funcs.slice(0, -1); |
| 24 | |
| 25 | return rest.reduceRight((composed, f) => f(composed), last(...args)); |
| 26 | }; |
| 27 | } |
| 28 | |
| 29 | // :: (a -> boolean) => [a] => [a] |
| 30 | export const filter = f => x => x.filter(f); |