test-action-debian-package/node_modules/ramda/es/propOr.js
Dawid Dziurla 9308795b8b
update
2020-03-26 15:37:35 +01:00

36 lines
1,018 B
JavaScript

import _curry3 from "./internal/_curry3.js";
import pathOr from "./pathOr.js";
/**
* If the given, non-null object has an own property with the specified name,
* returns the value of that property. Otherwise returns the provided default
* value.
*
* @func
* @memberOf R
* @since v0.6.0
* @category Object
* @sig a -> String -> Object -> a
* @param {*} val The default value.
* @param {String} p The name of the property to return.
* @param {Object} obj The object to query.
* @return {*} The value of given property of the supplied object or the default value.
* @example
*
* const alice = {
* name: 'ALICE',
* age: 101
* };
* const favorite = R.prop('favoriteLibrary');
* const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
*
* favorite(alice); //=> undefined
* favoriteWithDefault(alice); //=> 'Ramda'
*/
var propOr =
/*#__PURE__*/
_curry3(function propOr(val, p, obj) {
return pathOr(val, [p], obj);
});
export default propOr;