mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 07:02:28 +03:00
32 lines
849 B
TypeScript
32 lines
849 B
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/path.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
import paths from './paths.js';
|
|
|
|
/**
|
|
* Retrieve the value at a given path.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.2.0
|
|
* @category Object
|
|
* @typedefn Idx = String | Int | Symbol
|
|
* @sig [Idx] -> {a} -> a | Undefined
|
|
* @param {Array} path The path to use.
|
|
* @param {Object} obj The object to retrieve the nested property from.
|
|
* @return {*} The data at `path`.
|
|
* @see R.prop, R.nth
|
|
* @example
|
|
*
|
|
* R.path(['a', 'b'], {a: {b: 2}}); //=> 2
|
|
* R.path(['a', 'b'], {c: {b: 2}}); //=> undefined
|
|
* R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1
|
|
* R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2
|
|
*/
|
|
|
|
var path = _curry2(function path(pathAr, obj) {
|
|
return paths([pathAr], obj)[0];
|
|
});
|
|
export default path;
|