UNPKG

821 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var path =
6/*#__PURE__*/
7require("./path");
8/**
9 * Returns a function that when supplied an object returns the indicated
10 * property of that object, if it exists.
11 *
12 * @func
13 * @memberOf R
14 * @since v0.1.0
15 * @category Object
16 * @typedefn Idx = String | Int
17 * @sig Idx -> {s: a} -> a | Undefined
18 * @param {String|Number} p The property name or array index
19 * @param {Object} obj The object to query
20 * @return {*} The value at `obj.p`.
21 * @see R.path, R.nth
22 * @example
23 *
24 * R.prop('x', {x: 100}); //=> 100
25 * R.prop('x', {}); //=> undefined
26 * R.prop(0, [100]); //=> 100
27 * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4
28 */
29
30
31var prop =
32/*#__PURE__*/
33_curry2(function prop(p, obj) {
34 return path([p], obj);
35});
36
37module.exports = prop;
\No newline at end of file