Skip to content

Instantly share code, notes, and snippets.

@hw0k
Created June 28, 2020 10:59
Show Gist options
  • Save hw0k/021ee7a8a77ed7ae54e5b74ef8df2da6 to your computer and use it in GitHub Desktop.
Save hw0k/021ee7a8a77ed7ae54e5b74ef8df2da6 to your computer and use it in GitHub Desktop.
FND 9
function pipe(...functions) {
return input => functions.reduce((value, func) => func(value), input);
}
function multiplyTwice(x) {
return x * 2;
}
function addFive(x) {
return x + 5;
}
const number = 3;
// pipe()가 없을 때
addFive(multiplyTwice(number));
// pipe()를 사용했을 때
const multiplyAndAdd = pipe(multiplyTwice, addFive);
multiplyAndAdd(number);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment