source: node_modules/ramda-adjunct/lib/lensEq.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _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 */
27var lensEq = (0, _ramda.curryN)(3, function (lens, val, data) {
28 return (0, _ramda.pipe)((0, _ramda.view)(lens), (0, _ramda.equals)(val))(data);
29});
30var _default = lensEq;
31exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.