UNPKG

1.22 kBJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var equals =
6/*#__PURE__*/
7require("./equals");
8
9var map =
10/*#__PURE__*/
11require("./map");
12
13var where =
14/*#__PURE__*/
15require("./where");
16/**
17 * Takes a spec object and a test object; returns true if the test satisfies
18 * the spec, false otherwise. An object satisfies the spec if, for each of the
19 * spec's own properties, accessing that property of the object gives the same
20 * value (in [`R.equals`](#equals) terms) as accessing that property of the
21 * spec.
22 *
23 * `whereEq` is a specialization of [`where`](#where).
24 *
25 * @func
26 * @memberOf R
27 * @since v0.14.0
28 * @category Object
29 * @sig {String: *} -> {String: *} -> Boolean
30 * @param {Object} spec
31 * @param {Object} testObj
32 * @return {Boolean}
33 * @see R.propEq, R.where
34 * @example
35 *
36 * // pred :: Object -> Boolean
37 * const pred = R.whereEq({a: 1, b: 2});
38 *
39 * pred({a: 1}); //=> false
40 * pred({a: 1, b: 2}); //=> true
41 * pred({a: 1, b: 2, c: 3}); //=> true
42 * pred({a: 1, b: 1}); //=> false
43 */
44
45
46var whereEq =
47/*#__PURE__*/
48_curry2(function whereEq(spec, testObj) {
49 return where(map(equals, spec), testObj);
50});
51
52module.exports = whereEq;
\No newline at end of file