action-debian-package/node_modules/ramda/src/pathEq.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-03-26 14:37:35 +00:00
var _curry3 =
/*#__PURE__*/
require("./internal/_curry3");
var equals =
/*#__PURE__*/
require("./equals");
var path =
/*#__PURE__*/
require("./path");
/**
* Determines whether a nested path on an object has a specific value, in
* [`R.equals`](#equals) terms. Most likely used to filter a list.
*
* @func
* @memberOf R
* @since v0.7.0
* @category Relation
* @typedefn Idx = String | Int
* @sig [Idx] -> a -> {a} -> Boolean
* @param {Array} path The path of the nested property to use
* @param {*} val The value to compare the nested property with
* @param {Object} obj The object to check the nested property in
* @return {Boolean} `true` if the value equals the nested object property,
* `false` otherwise.
* @example
*
* const user1 = { address: { zipCode: 90210 } };
* const user2 = { address: { zipCode: 55555 } };
* const user3 = { name: 'Bob' };
* const users = [ user1, user2, user3 ];
* const isFamous = R.pathEq(['address', 'zipCode'], 90210);
* R.filter(isFamous, users); //=> [ user1 ]
*/
var pathEq =
/*#__PURE__*/
_curry3(function pathEq(_path, val, obj) {
return equals(path(_path, obj), val);
});
module.exports = pathEq;