ramda-extension
Version:
Helpful functions built on top of the mighty Ramda
37 lines (32 loc) • 1.05 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _ramda = require("ramda");
var _splitByDot = _interopRequireDefault(require("./splitByDot"));
/**
* Returns `true` if the specified object property at given dot path satisfies the given predicate; false otherwise.
*
* @func
* @category Object
*
* @param {Function} predicate
* @param {String} path The dot path to use.
* @param {Object} obj
*
* @return {Boolean}
*
* @example
*
* R_.dotPathSatisfies((y) => y > 0, 'a.b', { a: { b: 1 } }); // true
* R_.dotPathSatisfies((y) => y > 0, 'a.b', { a: { b: -1 } }); // false
* R_.dotPathSatisfies((y) => y > 0, 'a.b', { a: { c: 1 } }); // false
*
* @sig (a -> Boolean) → String → {a} → Boolean
*
*/
var dotPathSatisfies = (0, _ramda.useWith)(_ramda.pathSatisfies, [_ramda.identity, _splitByDot.default, _ramda.identity]);
var _default = dotPathSatisfies;
exports.default = _default;