Skip to content

Instantly share code, notes, and snippets.

@cesardeazevedo
Last active December 9, 2016 03:52
Show Gist options
  • Save cesardeazevedo/e3e9cd348b29a6b94b33a4849abbaa43 to your computer and use it in GitHub Desktop.
Save cesardeazevedo/e3e9cd348b29a6b94b33a4849abbaa43 to your computer and use it in GitHub Desktop.
Ramda WhereEq only on predicate properties
var props = {
a: true,
b: true,
}
R.whereEq(props, {
a: true,
b: true,
}) // => true
var props = {
a: true,
b: true,
c: false
}
R.whereEq(props, {
a: true,
b: true,
}) // => false
const wherePropEq = R.curry((props, predicate) => R.whereEq(
R.compose(R.pick(R.__, props), R.intersection(R.keys(props)), R.keys)(predicate),
predicate,
))
wherePropEq(props, {
a: true,
b: true
}) // => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment