If I want to compose a series of functions I can use compose, which will allow me to define a series of functions, with one or more arguments passed into the first, then the return of value of the first passed on to the second and the return value of the second passed on to the third and so on ...
compose(f3, f2, f1)(value);
Which is the equivalent of:
f3(f2(f1(value)))
However, what if I want all three functions to be called with value?
My use-case is that I have a series of functions which validate a piece of data. In each case the function either throws an error of does nothing if the value is valid. I need to compose these validation functions in a way that passing in a value will result in each function called with the value in sequence. Effectively:
f1(value);
f2(value);
f3(value);
// Do something now we are sure the value is valid.
The only way I can see of doing this using the functions provided by ramda is to use the logic operators to prevent short-circuiting if a value returns false:
const f1 = (v) => console.log(`f1 called with '${v}'`);
const f2 = (v) => console.log(`f2 called with '${v}'`);
const f3 = (v) => console.log(`f3 called with '${v}'`);
const callAll = compose(complement, anyPass);
callAll([f1, f2, f3])('x');
However this feels like a misuse of anyPass. Is this the most appropriate way of achieving what I want?