where

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
3
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
835 B
Takes a spec object and a test object; returns true if the test satisfies the spec.
1 contributor
Install where as a package?
Copied
npm i @bit/justin-capalbo.ramda.where
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
where (
spec:Object,
testObj:Object
) : Boolean

Takes a spec object and a test object; returns true if the test satisfies the spec. Each of the spec’s own properties must be a predicate function. Each predicate is applied to the value of the corresponding property of the test object. where returns true if all the predicates return true, false otherwise.

where is well suited to declaratively expressing constraints for other functions such as filter and find.

Example
// pred :: Object -> Boolean
     const pred = R.where({
       a: R.equals('foo'),
       b: R.complement(R.equals('bar')),
       x: R.gt(R.__, 10),
       y: R.lt(R.__, 20)
     });

     pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
     pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
     pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
     pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
     pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false
Arguments
spec: Object
testObj: Object
Returns
Boolean

Help and resources