Last active
December 9, 2016 03:52
-
-
Save cesardeazevedo/e3e9cd348b29a6b94b33a4849abbaa43 to your computer and use it in GitHub Desktop.
Ramda WhereEq only on predicate properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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