Ramda: Add the P combinator: R.on ?

Created on 21 Jun 2019  路  3Comments  路  Source: ramda/ramda

I'd love to have the P combinator available in Ramda.

const on = R.curry((f, g, a, b) => f(g(a))(g(b)))

thoughts?

Edit: some examples:

const eqBy = on(R.equals)

const mergeOn = on(R.mergeLeft)
const mergeProp = p => mergeOn(R.propOr({}, p))

const searchInsensitive = on(R.includes, R.toLower)

Most helpful comment

I would love to help, what's the best way to start?

All 3 comments

I like this function enough that I added it into Sanctuary! I can't recall why we did't add it to Ramda, but I think that if you made a PR we would give it a fair shake.

Would you be interested in working on this?

I would love to help, what's the best way to start?

:herb: Welcome Daniel!

I keep missing this function. It would be great to include.

To get started, you can read our Contributing article, and mostly just follow the style of existing functions. You will need to create a new source file, a test file, and an update to index.js. The implementation should be straightforward, since there are no performance concerns.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhaoyao91 picture zhaoyao91  路  3Comments

ashaffer picture ashaffer  路  4Comments

woss picture woss  路  3Comments

tylerlong picture tylerlong  路  3Comments

makarkotlov picture makarkotlov  路  3Comments