source: node_modules/ramda/es/pathOr.js

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: 890 bytes
Line 
1import _curry3 from "./internal/_curry3.js";
2import defaultTo from "./defaultTo.js";
3import path from "./path.js";
4/**
5 * If the given, non-null object has a value at the given path, returns the
6 * value at that path. Otherwise returns the provided default value.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.18.0
11 * @category Object
12 * @typedefn Idx = String | Int | Symbol
13 * @sig a -> [Idx] -> {a} -> a
14 * @param {*} d The default value.
15 * @param {Array} p The path to use.
16 * @param {Object} obj The object to retrieve the nested property from.
17 * @return {*} The data at `path` of the supplied object or the default value.
18 * @example
19 *
20 * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2
21 * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"
22 */
23
24var pathOr =
25/*#__PURE__*/
26_curry3(function pathOr(d, p, obj) {
27 return defaultTo(d, path(p, obj));
28});
29
30export default pathOr;
Note: See TracBrowser for help on using the repository browser.