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:
900 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | var _curry1 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry1.js");
|
---|
| 4 |
|
---|
| 5 | var lens =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./lens.js");
|
---|
| 8 |
|
---|
| 9 | var nth =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./nth.js");
|
---|
| 12 |
|
---|
| 13 | var update =
|
---|
| 14 | /*#__PURE__*/
|
---|
| 15 | require("./update.js");
|
---|
| 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; |
---|
Note:
See
TracBrowser
for help on using the repository browser.