main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import _curry2 from "./internal/_curry2.js";
|
---|
| 2 | import equals from "./equals.js";
|
---|
| 3 | import map from "./map.js";
|
---|
| 4 | import where from "./where.js";
|
---|
| 5 | /**
|
---|
| 6 | * Takes a spec object and a test object; returns true if the test satisfies
|
---|
| 7 | * the spec, false otherwise. An object satisfies the spec if, for each of the
|
---|
| 8 | * spec's own properties, accessing that property of the object gives the same
|
---|
| 9 | * value (in [`R.equals`](#equals) terms) as accessing that property of the
|
---|
| 10 | * spec.
|
---|
| 11 | *
|
---|
| 12 | * `whereEq` is a specialization of [`where`](#where).
|
---|
| 13 | *
|
---|
| 14 | * @func
|
---|
| 15 | * @memberOf R
|
---|
| 16 | * @since v0.14.0
|
---|
| 17 | * @category Object
|
---|
| 18 | * @sig {String: *} -> {String: *} -> Boolean
|
---|
| 19 | * @param {Object} spec
|
---|
| 20 | * @param {Object} testObj
|
---|
| 21 | * @return {Boolean}
|
---|
| 22 | * @see R.propEq, R.where
|
---|
| 23 | * @example
|
---|
| 24 | *
|
---|
| 25 | * // pred :: Object -> Boolean
|
---|
| 26 | * const pred = R.whereEq({a: 1, b: 2});
|
---|
| 27 | *
|
---|
| 28 | * pred({a: 1}); //=> false
|
---|
| 29 | * pred({a: 1, b: 2}); //=> true
|
---|
| 30 | * pred({a: 1, b: 2, c: 3}); //=> true
|
---|
| 31 | * pred({a: 1, b: 1}); //=> false
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | var whereEq =
|
---|
| 35 | /*#__PURE__*/
|
---|
| 36 | _curry2(function whereEq(spec, testObj) {
|
---|
| 37 | return where(map(equals, spec), testObj);
|
---|
| 38 | });
|
---|
| 39 |
|
---|
| 40 | export default whereEq; |
---|
Note:
See
TracBrowser
for help on using the repository browser.