Created
November 20, 2017 19:06
-
-
Save rgeraldporter/bb280636639d7f4759ddba2b6bd13308 to your computer and use it in GitHub Desktop.
RamdaJS trick, handle uncurried side-effect functions (e.g. console) in a chain while still currying the value back
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
//RamdaJS trick, handle uncurried side-effect functions (e.g. console) in a chain while still currying the value back | |
const sideFx = R.pipe(R.juxt([console.log, console.error, R.identity]), R.last); | |
// > R.pipe(R.add(1), sideFx, R.add(4))(1); | |
// >> console.log(2); | |
// >> console.error(2); | |
// >> 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment