1 | import _curry3 from "./internal/_curry3.js";
|
---|
2 | import prop from "./prop.js";
|
---|
3 | import equals from "./equals.js";
|
---|
4 | /**
|
---|
5 | * Returns `true` if the specified object property is equal, in
|
---|
6 | * [`R.equals`](#equals) terms, to the given value; `false` otherwise.
|
---|
7 | * You can test multiple properties with [`R.whereEq`](#whereEq),
|
---|
8 | * and test nested path property with [`R.pathEq`](#pathEq).
|
---|
9 | *
|
---|
10 | * @func
|
---|
11 | * @memberOf R
|
---|
12 | * @since v0.1.0
|
---|
13 | * @category Relation
|
---|
14 | * @sig a -> String -> Object -> Boolean
|
---|
15 | * @param {*} val The value to compare the property with
|
---|
16 | * @param {String} name the specified object property's key
|
---|
17 | * @param {*} obj The object to check the property in
|
---|
18 | * @return {Boolean} `true` if the value equals the specified object property,
|
---|
19 | * `false` otherwise.
|
---|
20 | * @see R.whereEq, R.pathEq, R.propSatisfies, R.equals
|
---|
21 | * @example
|
---|
22 | *
|
---|
23 | * const abby = {name: 'Abby', age: 7, hair: 'blond'};
|
---|
24 | * const fred = {name: 'Fred', age: 12, hair: 'brown'};
|
---|
25 | * const rusty = {name: 'Rusty', age: 10, hair: 'brown'};
|
---|
26 | * const alois = {name: 'Alois', age: 15, disposition: 'surly'};
|
---|
27 | * const kids = [abby, fred, rusty, alois];
|
---|
28 | * const hasBrownHair = R.propEq('brown', 'hair');
|
---|
29 | * R.filter(hasBrownHair, kids); //=> [fred, rusty]
|
---|
30 | */
|
---|
31 |
|
---|
32 | var propEq =
|
---|
33 | /*#__PURE__*/
|
---|
34 | _curry3(function propEq(val, name, obj) {
|
---|
35 | return equals(val, prop(name, obj));
|
---|
36 | });
|
---|
37 |
|
---|
38 | export default propEq; |
---|