New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tap does not execute the provided function if it receives no arguments #3006
Comments
Because most ramda's functions are auto curried, in ramda's curry mechanism:
For example, this is what ramda's inner function export default function _curry1(fn) {
return function f1(a) {
if (arguments.length === 0 || _isPlaceholder(a)) {
return f1;
} else {
return fn.apply(this, arguments);
}
};
} as you can see, _curry1(console.log)() // just do nothing but returned console.log
_curry1(console.log)(undefined) // output 'undefined' So, in your example, |
The only use I've ever had for
And in such circumstances, of course, the pipeline must be supplying data, so one would never notice that Of course @adispring's analysis of why this is so is spot-on. @buzzdecafe has long argued that |
Unless of course the data comes into your pipeline as a part of a more complex process and you're logging your input as the very first step of the Ramda pipeline, which was the case where I noticed this happening. As addressing this would probably need unfortunate tradeoffs in other areas (change currying) and as this is pretty much an edge case, it's probably not worth acting upon in any way. It's just good to know that not seeing an expected log message might be caused by this. |
@adispring: Could you get in touch with me at some point? I'd like to ask you something in a quieter forum. I'm scott@sauyet.com and @scott_sauyet on Twitter. |
The function created by calling
R.tap
does not execute if arguments are not provided.See the provided example.
The text was updated successfully, but these errors were encountered: