source: node_modules/ramda/es/pathEq.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import _curry3 from "./internal/_curry3.js";
2import equals from "./equals.js";
3import path from "./path.js";
4/**
5 * Determines whether a nested path on an object has a specific value, in
6 * [`R.equals`](#equals) terms. Most likely used to filter a list.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.7.0
11 * @category Relation
12 * @typedefn Idx = String | Int | Symbol
13 * @sig a -> [Idx] -> {a} -> Boolean
14 * @param {*} val The value to compare the nested property with
15 * @param {Array} path The path of the nested property to use
16 * @param {Object} obj The object to check the nested property in
17 * @return {Boolean} `true` if the value equals the nested object property,
18 * `false` otherwise.
19 * @see R.whereEq, R.propEq, R.pathSatisfies, R.equals
20 * @example
21 *
22 * const user1 = { address: { zipCode: 90210 } };
23 * const user2 = { address: { zipCode: 55555 } };
24 * const user3 = { name: 'Bob' };
25 * const users = [ user1, user2, user3 ];
26 * const isFamous = R.pathEq(90210, ['address', 'zipCode']);
27 * R.filter(isFamous, users); //=> [ user1 ]
28 */
29
30var pathEq =
31/*#__PURE__*/
32_curry3(function pathEq(val, _path, obj) {
33 return equals(path(_path, obj), val);
34});
35
36export default pathEq;
Note: See TracBrowser for help on using the repository browser.