[d24f17c] | 1 | var _curry2 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry2.js");
|
---|
| 4 |
|
---|
| 5 | var paths =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./paths.js");
|
---|
| 8 | /**
|
---|
| 9 | * Retrieves the value at a given path. The nodes of the path can be arbitrary strings or non-negative integers.
|
---|
| 10 | * For anything else, the value is unspecified. Integer paths are meant to index arrays, strings are meant for objects.
|
---|
| 11 | *
|
---|
| 12 | * @func
|
---|
| 13 | * @memberOf R
|
---|
| 14 | * @since v0.2.0
|
---|
| 15 | * @category Object
|
---|
| 16 | * @typedefn Idx = String | Int | Symbol
|
---|
| 17 | * @sig [Idx] -> {a} -> a | Undefined
|
---|
| 18 | * @sig Idx = String | NonNegativeInt
|
---|
| 19 | * @param {Array} path The path to use.
|
---|
| 20 | * @param {Object} obj The object or array to retrieve the nested property from.
|
---|
| 21 | * @return {*} The data at `path`.
|
---|
| 22 | * @see R.prop, R.nth, R.assocPath, R.dissocPath
|
---|
| 23 | * @example
|
---|
| 24 | *
|
---|
| 25 | * R.path(['a', 'b'], {a: {b: 2}}); //=> 2
|
---|
| 26 | * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined
|
---|
| 27 | * R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1
|
---|
| 28 | * R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2
|
---|
| 29 | * R.path([2], {'2': 2}); //=> 2
|
---|
| 30 | * R.path([-2], {'-2': 'a'}); //=> undefined
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | var path =
|
---|
| 35 | /*#__PURE__*/
|
---|
| 36 | _curry2(function path(pathAr, obj) {
|
---|
| 37 | return paths([pathAr], obj)[0];
|
---|
| 38 | });
|
---|
| 39 |
|
---|
| 40 | module.exports = path; |
---|