-
Notifications
You must be signed in to change notification settings - Fork 0
3. Compose
Carlos De Dios edited this page Oct 20, 2015
·
1 revision
Joins n functions to be called one after another in a left-associative manner when invoked.
/* Regular Approach */
let addTwo = (v) => v + 2;
let timesTen = (v) => v * 10;
let minusThree = (v) => v - 3;
return minusThree(timesTen(addTwo(5)));
/* Compose Approach */
import { compose } from "functional-programming-utilities";
let addTwo = (v) => v + 2;
let timesTen = (v) => v * 10;
let minusThree = (v) => v - 3;
return compose(addTwo, timesTen, minusThree)(5);