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:
792 bytes
|
Line | |
---|
1 | import _curry1 from "./internal/_curry1.js";
|
---|
2 | import assoc from "./assoc.js";
|
---|
3 | import lens from "./lens.js";
|
---|
4 | import prop from "./prop.js";
|
---|
5 | /**
|
---|
6 | * Returns a lens whose focus is the specified property.
|
---|
7 | *
|
---|
8 | * @func
|
---|
9 | * @memberOf R
|
---|
10 | * @since v0.14.0
|
---|
11 | * @category Object
|
---|
12 | * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
|
---|
13 | * @sig String -> Lens s a
|
---|
14 | * @param {String} k
|
---|
15 | * @return {Lens}
|
---|
16 | * @see R.view, R.set, R.over
|
---|
17 | * @example
|
---|
18 | *
|
---|
19 | * const xLens = R.lensProp('x');
|
---|
20 | *
|
---|
21 | * R.view(xLens, {x: 1, y: 2}); //=> 1
|
---|
22 | * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
|
---|
23 | * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
|
---|
24 | */
|
---|
25 |
|
---|
26 | var lensProp =
|
---|
27 | /*#__PURE__*/
|
---|
28 | _curry1(function lensProp(k) {
|
---|
29 | return lens(prop(k), assoc(k));
|
---|
30 | });
|
---|
31 |
|
---|
32 | export default lensProp; |
---|
Note:
See
TracBrowser
for help on using the repository browser.