source: node_modules/ramda-adjunct/lib/lensSatisfies.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.5 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _isTrue = _interopRequireDefault(require("./isTrue"));
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8/**
9 * Returns `true` if data structure focused by the given lens satisfies the predicate.
10 * Note that the predicate is expected to return boolean value and will be evaluated
11 * as `false` unless the predicate returns `true`.
12 *
13 * @func lensSatisfies
14 * @memberOf RA
15 * @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
16 * @category Relation
17 * @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
18 * @sig Boolean b => (a -> b) -> Lens s a -> s -> b
19 * @see {@link RA.lensNotSatisfy|lensNotSatisfy}
20 * @param {Function} predicate The predicate function
21 * @param {Function} lens Van Laarhoven lens
22 * @param {*} data The data structure
23 * @return {boolean} `true` if the focused data structure satisfies the predicate, `false` otherwise
24 *
25 * @example
26 *
27 * RA.lensSatisfies(RA.isTrue, R.lensIndex(0), [false, true, 1]); // => false
28 * RA.lensSatisfies(RA.isTrue, R.lensIndex(1), [false, true, 1]); // => true
29 * RA.lensSatisfies(RA.isTrue, R.lensIndex(2), [false, true, 1]); // => false
30 * RA.lensSatisfies(R.identity, R.lensProp('x'), { x: 1 }); // => false
31 */
32var lensSatisfies = (0, _ramda.curryN)(3, function (predicate, lens, data) {
33 return (0, _ramda.pipe)((0, _ramda.view)(lens), predicate, _isTrue["default"])(data);
34});
35var _default = lensSatisfies;
36exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.