-
Notifications
You must be signed in to change notification settings - Fork 0
2. Pipe
Carlos De Dios edited this page Oct 20, 2015
·
1 revision
Takes care of passing a value through multiple functions in a left-associative manner.
/* Regular Approach */
let addTwo = (v) => v + 2;
let timesTen = (v) => v * 10;
let minusThree = (v) => v - 3;
let r1 = addTwo(5);
let r2 = timesTen(r1);
let r3 = MinusThree(r2);
return r3;
/* Pipe Approach */
import { pipe } from "functional-programming-utilities";
let addTwo = (v) => v + 2;
let timesTen = (v) => v * 10;
let minusThree = (v) => v - 3;
return pipe(5, addTwo, timesTen, minusThree);