source: node_modules/ramda/es/lensIndex.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 826 bytes
Line 
1import _curry1 from "./internal/_curry1.js";
2import lens from "./lens.js";
3import nth from "./nth.js";
4import update from "./update.js";
5/**
6 * Returns a lens whose focus is the specified index.
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 Number -> Lens s a
14 * @param {Number} n
15 * @return {Lens}
16 * @see R.view, R.set, R.over, R.nth
17 * @example
18 *
19 * const headLens = R.lensIndex(0);
20 *
21 * R.view(headLens, ['a', 'b', 'c']); //=> 'a'
22 * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c']
23 * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c']
24 */
25
26var lensIndex =
27/*#__PURE__*/
28_curry1(function lensIndex(n) {
29 return lens(nth(n), update(n));
30});
31
32export default lensIndex;
Note: See TracBrowser for help on using the repository browser.