[d24f17c] | 1 | var _curry1 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry1.js");
|
---|
| 4 |
|
---|
| 5 | var assocPath =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./assocPath.js");
|
---|
| 8 |
|
---|
| 9 | var lens =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./lens.js");
|
---|
| 12 |
|
---|
| 13 | var path =
|
---|
| 14 | /*#__PURE__*/
|
---|
| 15 | require("./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 |
|
---|
| 42 | var lensPath =
|
---|
| 43 | /*#__PURE__*/
|
---|
| 44 | _curry1(function lensPath(p) {
|
---|
| 45 | return lens(path(p), assocPath(p));
|
---|
| 46 | });
|
---|
| 47 |
|
---|
| 48 | module.exports = lensPath; |
---|