1 | var _curry1 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry1");
|
4 |
|
5 | var lens =
|
6 | /*#__PURE__*/
|
7 | require("./lens");
|
8 |
|
9 | var nth =
|
10 | /*#__PURE__*/
|
11 | require("./nth");
|
12 |
|
13 | var update =
|
14 | /*#__PURE__*/
|
15 | require("./update");
|
16 | /**
|
17 | * Returns a lens whose focus is the specified index.
|
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 Number -> Lens s a
|
25 | * @param {Number} n
|
26 | * @return {Lens}
|
27 | * @see R.view, R.set, R.over, R.nth
|
28 | * @example
|
29 | *
|
30 | * const headLens = R.lensIndex(0);
|
31 | *
|
32 | * R.view(headLens, ['a', 'b', 'c']); //=> 'a'
|
33 | * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c']
|
34 | * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c']
|
35 | */
|
36 |
|
37 |
|
38 | var lensIndex =
|
39 | /*#__PURE__*/
|
40 | _curry1(function lensIndex(n) {
|
41 | return lens(nth(n), update(n));
|
42 | });
|
43 |
|
44 | module.exports = lensIndex; |
\ | No newline at end of file |