Reputation: 3518
Can I write this somehow using ramda?
const getJobs = data => anotherF('/jobs', data)
perhaps something like
const getJobs = anotherF('/jobs', nthArg(0))
Thank you
Upvotes: 0
Views: 61
Reputation: 50787
If anotherF
is already a curried function, then you can just write
const getJobs = anotherF('/jobs')
So, if it's not curried, or if you don't know, you can write
const getJobs = curry(anotherF)('/jobs')
But there is a good reason to wonder why it would be worth it. I'm one of the founders of Ramda and I'm a big fan, but I think of it as a toolkit to use when it makes my code easier to read and write. Any other use seems a misuse.
Upvotes: 5
Reputation: 191946
You can use R.partial to apply /jobs'
to the function, and return a new function that expects the data
:
const anotherF = (path, data) => console.log(path, data)
const getJobs = R.partial(anotherF, ['/jobs'])
getJobs('data')
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.js"></script>
Upvotes: 2