UNPKG

854 BJavaScriptView Raw
1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1");
4
5var assoc =
6/*#__PURE__*/
7require("./assoc");
8
9var lens =
10/*#__PURE__*/
11require("./lens");
12
13var prop =
14/*#__PURE__*/
15require("./prop");
16/**
17 * Returns a lens whose focus is the specified property.
18 *
19 * @func
20 * @memberOf R
21 * @since v0.14.0
22 * @category Object
23 * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
24 * @sig String -> Lens s a
25 * @param {String} k
26 * @return {Lens}
27 * @see R.view, R.set, R.over
28 * @example
29 *
30 * const xLens = R.lensProp('x');
31 *
32 * R.view(xLens, {x: 1, y: 2}); //=> 1
33 * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
34 * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
35 */
36
37
38var lensProp =
39/*#__PURE__*/
40_curry1(function lensProp(k) {
41 return lens(prop(k), assoc(k));
42});
43
44module.exports = lensProp;
\No newline at end of file