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