source: node_modules/ramda/src/lensPath.js

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: 1.0 KB
RevLine 
[d24f17c]1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1.js");
4
5var assocPath =
6/*#__PURE__*/
7require("./assocPath.js");
8
9var lens =
10/*#__PURE__*/
11require("./lens.js");
12
13var path =
14/*#__PURE__*/
15require("./path.js");
16/**
17 * Returns a lens whose focus is the specified path.
18 *
19 * @func
20 * @memberOf R
21 * @since v0.19.0
22 * @category Object
23 * @typedefn Idx = String | Int | Symbol
24 * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
25 * @sig [Idx] -> Lens s a
26 * @param {Array} path The path to use.
27 * @return {Lens}
28 * @see R.view, R.set, R.over
29 * @example
30 *
31 * const xHeadYLens = R.lensPath(['x', 0, 'y']);
32 *
33 * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
34 * //=> 2
35 * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
36 * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]}
37 * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
38 * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]}
39 */
40
41
42var lensPath =
43/*#__PURE__*/
44_curry1(function lensPath(p) {
45 return lens(path(p), assocPath(p));
46});
47
48module.exports = lensPath;
Note: See TracBrowser for help on using the repository browser.