Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

lens

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
35
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
2 KB
Returns a lens for the given getter and setter functions.
1 contributor
Use lens in your project ?
Copied
npm i @bit/ramda.ramda.lens
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
const xLens = lens(
  prop("x"),
  assoc("x"),
  x: 1,
  y: 2,
}); //=> 1
modifieddraft
chevron_left
chevron_right
lens (
getter:Function,
setter:Function
) : Lens

Returns a lens for the given getter and setter functions. The getter “gets” the value of the focus; the setter “sets” the value of the focus. The setter should not mutate the data structure.

Example
const xLens = R.lens(R.prop('x'), R.assoc('x'));

     R.view(xLens, {x: 1, y: 2});            //=> 1
     R.set(xLens, 4, {x: 1, y: 2});          //=> {x: 4, y: 2}
     R.over(xLens, R.negate, {x: 1, y: 2});  //=> {x: -1, y: 2}
Arguments
getter: Function
setter: Function
Returns
Lens