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

ldk18501 picture ldk18501  路  3Comments

Luxcium picture Luxcium  路  3Comments

FranzSkuffka picture FranzSkuffka  路  3Comments

tylerlong picture tylerlong  路  3Comments

cjohansen picture cjohansen  路  4Comments