[d24f17c] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | exports.__esModule = true;
|
---|
| 4 | exports["default"] = void 0;
|
---|
| 5 | var _ramda = require("ramda");
|
---|
| 6 | var _isTrue = _interopRequireDefault(require("./isTrue"));
|
---|
| 7 | function _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 | */
|
---|
| 32 | var lensSatisfies = (0, _ramda.curryN)(3, function (predicate, lens, data) {
|
---|
| 33 | return (0, _ramda.pipe)((0, _ramda.view)(lens), predicate, _isTrue["default"])(data);
|
---|
| 34 | });
|
---|
| 35 | var _default = lensSatisfies;
|
---|
| 36 | exports["default"] = _default; |
---|