main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | var _curry3 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry3.js");
|
---|
| 4 |
|
---|
| 5 | var defaultTo =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./defaultTo.js");
|
---|
| 8 |
|
---|
| 9 | var prop =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./prop.js");
|
---|
| 12 | /**
|
---|
| 13 | * Return the specified property of the given non-null object if the property
|
---|
| 14 | * is present and it's value is not `null`, `undefined` or `NaN`.
|
---|
| 15 | *
|
---|
| 16 | * Otherwise the first argument is returned.
|
---|
| 17 | *
|
---|
| 18 | * @func
|
---|
| 19 | * @memberOf R
|
---|
| 20 | * @since v0.6.0
|
---|
| 21 | * @category Object
|
---|
| 22 | * @sig a -> String -> Object -> a
|
---|
| 23 | * @param {*} val The default value.
|
---|
| 24 | * @param {String} p The name of the property to return.
|
---|
| 25 | * @param {Object} obj The object to query.
|
---|
| 26 | * @return {*} The value of given property of the supplied object or the default value.
|
---|
| 27 | * @example
|
---|
| 28 | *
|
---|
| 29 | * const alice = {
|
---|
| 30 | * name: 'ALICE',
|
---|
| 31 | * age: 101
|
---|
| 32 | * };
|
---|
| 33 | * const favorite = R.prop('favoriteLibrary');
|
---|
| 34 | * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
|
---|
| 35 | *
|
---|
| 36 | * favorite(alice); //=> undefined
|
---|
| 37 | * favoriteWithDefault(alice); //=> 'Ramda'
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | var propOr =
|
---|
| 42 | /*#__PURE__*/
|
---|
| 43 | _curry3(function propOr(val, p, obj) {
|
---|
| 44 | return defaultTo(val, prop(p, obj));
|
---|
| 45 | });
|
---|
| 46 |
|
---|
| 47 | module.exports = propOr; |
---|
Note:
See
TracBrowser
for help on using the repository browser.