ramda-adjunct
Version:
Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
33 lines (30 loc) • 1.12 kB
JavaScript
exports.__esModule = true;
exports["default"] = void 0;
var _ramda = require("ramda");
/**
* Returns `true` if data structure focused by the given lens equals provided value.
*
* @func lensEq
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
* @category Relation
* @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
* @sig Lens s a -> b -> s -> Boolean
* @see {@link RA.lensNotEq|lensNotEq}
* @param {function} lens Van Laarhoven lens
* @param {*} value The value to compare the focused data structure with
* @param {*} data The data structure
* @return {boolean} `true` if the focused data structure equals value, `false` otherwise
*
* @example
*
* RA.lensEq(R.lensIndex(0), 1, [0, 1, 2]); // => false
* RA.lensEq(R.lensIndex(1), 1, [0, 1, 2]); // => true
* RA.lensEq(R.lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }) // => true
*/
var lensEq = (0, _ramda.curryN)(3, function (lens, val, data) {
return (0, _ramda.pipe)((0, _ramda.view)(lens), (0, _ramda.equals)(val))(data);
});
var _default = lensEq;
exports["default"] = _default;
;