Last active
September 26, 2015 20:53
-
-
Save luijar/12b607b3a557c42f8f36 to your computer and use it in GitHub Desktop.
Ramda and Lenses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ana = new Person('Ana', 'Gonzalez'); | |
var firstnameLens = R.lensProp('firstname'); | |
// read firtstname | |
R.view(firstnameLens, ana); //-> 'Ana' | |
// transform firstname to upper case | |
R.over(firstnameLens, R.toUpper, ana); //-> 'ANA' | |
// set firstname (creates a branch new object) | |
var olivia = R.set(firstnameLens, 'Olivia', ana)); //-> new Person('Olivia', 'Gonzalez') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment