-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
pathEq.js
34 lines (32 loc) · 1.19 KB
/
pathEq.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import _curry3 from './internal/_curry3.js';
import _path from './internal/_path.js';
import equals from './equals.js';
/**
* Determines whether a nested path on an object has a specific value, in
* [`R.equals`](#equals) terms. Most likely used to filter a list.
*
* @func
* @memberOf R
* @since v0.7.0
* @category Relation
* @typedefn Idx = String | Int | Symbol
* @sig a -> [Idx] -> {a} -> Boolean
* @param {*} val The value to compare the nested property with
* @param {Array} path The path of the nested property to use
* @param {Object} obj The object to check the nested property in
* @return {Boolean} `true` if the value equals the nested object property,
* `false` otherwise.
* @see R.whereEq, R.propEq, R.pathSatisfies, R.equals
* @example
*
* const user1 = { address: { zipCode: 90210 } };
* const user2 = { address: { zipCode: 55555 } };
* const user3 = { name: 'Bob' };
* const users = [ user1, user2, user3 ];
* const isFamous = R.pathEq(90210, ['address', 'zipCode']);
* R.filter(isFamous, users); //=> [ user1 ]
*/
var pathEq = _curry3(function pathEq(val, pathAr, obj) {
return equals(_path(pathAr, obj), val);
});
export default pathEq;