Determine parameters in advance
Bind Bind parameter
We know that you can use bind to pre-bind parameters
But that would add a nasty null.
curry
You can remove this null with Curry:
partial
You can also use partial:
What about binding other parameters?
Bind/curry/partial can bind parameters, but only the front parameters. What if I want to bind parameters in the middle or behind?
See the examples:
You can see that each time readFile is followed by ‘utf8’ and output.
So you might rewrite it like this:
It looks good.
Ramda placeholder
Placeholders are used to solve this problem, but only if the function is Curryized:
Then optimize it a little bit:
You can assume that the position of __ is where file1. TXT and file2. TXT appear.
Is that intuitive?
That’s how placeholders are used.
Reference: hackernoon.com/i-ramda-par…