Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/modules / ___dist / chain-able / src / deps / fp / hasInMatching.js
Size: Mime:
"use strict";

const curry = require("../fp/curry");

const hasIn = require("../is/in");
/**
 * @desc isIn + hasIn ...and also allows a predicate/matcher/specification
 * @memberOf is
 * @memberOf fp
 * @since 5.0.0-beta.4
 *
 * @param {Object} predicate predicate match the property against this
 * @param {Object} obj object to check
 * @param {any} prop property to check in object
 * @return {boolean} obj[prop] hasIn & satisfies
 *
 * @TODO surely would be better with focusing on a prop, then applying predicate, lense? :s
 * @TODO is it better in fp/ or is/ ? needs some definitions
 *
 * @see https://github.com/ramda/ramda/blob/master/src/propOr.js
 * @extends hasIn
 * @extends isNull
 * @extends isIn
 *
 * @example
 *
 *  hasIn({}, 'eh') //=> false
 *  hasIn(null, 'eh') //=> false
 *  hasIn({eh: true}, 'eh') //=> true
 *
 */


function hasInMatching(predicate, obj, prop) {
  return hasIn(obj, prop) && predicate(obj[prop]);
}

module.exports = curry(3, hasInMatching);