source: node_modules/ramda-adjunct/src/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: 973 bytes
Line 
1import { view, curryN, equals, pipe } from 'ramda';
2
3/**
4 * Returns `true` if data structure focused by the given lens equals provided value.
5 *
6 * @func lensEq
7 * @memberOf RA
8 * @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
9 * @category Relation
10 * @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
11 * @sig Lens s a -> b -> s -> Boolean
12 * @see {@link RA.lensNotEq|lensNotEq}
13 * @param {function} lens Van Laarhoven lens
14 * @param {*} value The value to compare the focused data structure with
15 * @param {*} data The data structure
16 * @return {boolean} `true` if the focused data structure equals value, `false` otherwise
17 *
18 * @example
19 *
20 * RA.lensEq(R.lensIndex(0), 1, [0, 1, 2]); // => false
21 * RA.lensEq(R.lensIndex(1), 1, [0, 1, 2]); // => true
22 * RA.lensEq(R.lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }) // => true
23 */
24const lensEq = curryN(3, (lens, val, data) =>
25 pipe(view(lens), equals(val))(data)
26);
27
28export default lensEq;
Note: See TracBrowser for help on using the repository browser.