main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
946 bytes
|
Line | |
---|
1 | var _curry3 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry3.js");
|
---|
4 |
|
---|
5 | var defaultTo =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./defaultTo.js");
|
---|
8 |
|
---|
9 | var path =
|
---|
10 | /*#__PURE__*/
|
---|
11 | require("./path.js");
|
---|
12 | /**
|
---|
13 | * If the given, non-null object has a value at the given path, returns the
|
---|
14 | * value at that path. Otherwise returns the provided default value.
|
---|
15 | *
|
---|
16 | * @func
|
---|
17 | * @memberOf R
|
---|
18 | * @since v0.18.0
|
---|
19 | * @category Object
|
---|
20 | * @typedefn Idx = String | Int | Symbol
|
---|
21 | * @sig a -> [Idx] -> {a} -> a
|
---|
22 | * @param {*} d The default value.
|
---|
23 | * @param {Array} p The path to use.
|
---|
24 | * @param {Object} obj The object to retrieve the nested property from.
|
---|
25 | * @return {*} The data at `path` of the supplied object or the default value.
|
---|
26 | * @example
|
---|
27 | *
|
---|
28 | * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2
|
---|
29 | * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"
|
---|
30 | */
|
---|
31 |
|
---|
32 |
|
---|
33 | var pathOr =
|
---|
34 | /*#__PURE__*/
|
---|
35 | _curry3(function pathOr(d, p, obj) {
|
---|
36 | return defaultTo(d, path(p, obj));
|
---|
37 | });
|
---|
38 |
|
---|
39 | module.exports = pathOr; |
---|
Note:
See
TracBrowser
for help on using the repository browser.