UNPKG

1.2 kBJavaScriptView Raw
1var _curry3 =
2/*#__PURE__*/
3require("./internal/_curry3");
4
5var equals =
6/*#__PURE__*/
7require("./equals");
8
9var path =
10/*#__PURE__*/
11require("./path");
12/**
13 * Determines whether a nested path on an object has a specific value, in
14 * [`R.equals`](#equals) terms. Most likely used to filter a list.
15 *
16 * @func
17 * @memberOf R
18 * @since v0.7.0
19 * @category Relation
20 * @typedefn Idx = String | Int
21 * @sig [Idx] -> a -> {a} -> Boolean
22 * @param {Array} path The path of the nested property to use
23 * @param {*} val The value to compare the nested property with
24 * @param {Object} obj The object to check the nested property in
25 * @return {Boolean} `true` if the value equals the nested object property,
26 * `false` otherwise.
27 * @example
28 *
29 * const user1 = { address: { zipCode: 90210 } };
30 * const user2 = { address: { zipCode: 55555 } };
31 * const user3 = { name: 'Bob' };
32 * const users = [ user1, user2, user3 ];
33 * const isFamous = R.pathEq(['address', 'zipCode'], 90210);
34 * R.filter(isFamous, users); //=> [ user1 ]
35 */
36
37
38var pathEq =
39/*#__PURE__*/
40_curry3(function pathEq(_path, val, obj) {
41 return equals(path(_path, obj), val);
42});
43
44module.exports = pathEq;
\No newline at end of file