[d24f17c] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | exports.__esModule = true;
|
---|
| 4 | exports["default"] = void 0;
|
---|
| 5 | var _ramda = require("ramda");
|
---|
| 6 | /**
|
---|
| 7 | * Returns `true` if data structure focused by the given lens equals provided value.
|
---|
| 8 | *
|
---|
| 9 | * @func lensEq
|
---|
| 10 | * @memberOf RA
|
---|
| 11 | * @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
|
---|
| 12 | * @category Relation
|
---|
| 13 | * @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
|
---|
| 14 | * @sig Lens s a -> b -> s -> Boolean
|
---|
| 15 | * @see {@link RA.lensNotEq|lensNotEq}
|
---|
| 16 | * @param {function} lens Van Laarhoven lens
|
---|
| 17 | * @param {*} value The value to compare the focused data structure with
|
---|
| 18 | * @param {*} data The data structure
|
---|
| 19 | * @return {boolean} `true` if the focused data structure equals value, `false` otherwise
|
---|
| 20 | *
|
---|
| 21 | * @example
|
---|
| 22 | *
|
---|
| 23 | * RA.lensEq(R.lensIndex(0), 1, [0, 1, 2]); // => false
|
---|
| 24 | * RA.lensEq(R.lensIndex(1), 1, [0, 1, 2]); // => true
|
---|
| 25 | * RA.lensEq(R.lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }) // => true
|
---|
| 26 | */
|
---|
| 27 | var lensEq = (0, _ramda.curryN)(3, function (lens, val, data) {
|
---|
| 28 | return (0, _ramda.pipe)((0, _ramda.view)(lens), (0, _ramda.equals)(val))(data);
|
---|
| 29 | });
|
---|
| 30 | var _default = lensEq;
|
---|
| 31 | exports["default"] = _default; |
---|