Last active
January 25, 2018 03:16
-
-
Save roberto/09303c35dc32c3e2230a446b21aa293a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const setJackson = R.pipe( | |
R.prop("users"), | |
R.map( | |
(user) => | |
R.startsWith('J', user.name) | |
? {...user, name: R.concat(user.name, ' Jackson')} | |
: user | |
) | |
) |
This file contains hidden or 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
const setLastName = (name) => | |
R.startsWith('J', name) | |
? R.concat(name, ' Jackson') | |
: name | |
const setJackson = R.pipe( | |
R.prop("users"), | |
R.map(R.evolve({name: setLastName})) | |
) |
This file contains hidden or 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
const setLastName = R.cond([ | |
[R.startsWith('J'), R.concat(R.__, ' Jackson')], | |
[R.T, R.identity] | |
]) | |
const setJackson = R.pipe( | |
R.prop("users"), | |
R.map(evolve({name: setLastName})) | |
) |
This file contains hidden or 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
const setLastName = R.when( | |
R.startsWith('J'), | |
R.concat(R.__, ' Jackson') | |
) | |
const setJackson = R.pipe( | |
R.prop("users"), | |
R.map(evolve({name: setLastName})) | |
) |
This file contains hidden or 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
const lensName = R.lensProp('name') | |
const setJackson = R.pipe( | |
R.prop("users"), | |
R.map( | |
R.when( | |
R.propSatisfies(R.startsWith('J'), 'name'), | |
R.over(lensName, R.concat(R.__, ' Jackson')) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment