source: node_modules/ramda/src/path.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: 1.2 KB
RevLine 
[d24f17c]1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2.js");
4
5var paths =
6/*#__PURE__*/
7require("./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
34var path =
35/*#__PURE__*/
36_curry2(function path(pathAr, obj) {
37 return paths([pathAr], obj)[0];
38});
39
40module.exports = path;
Note: See TracBrowser for help on using the repository browser.