Skip to content

Instantly share code, notes, and snippets.

@nanggo
Last active February 19, 2021 06:47
Show Gist options
  • Save nanggo/3568ec7fe12d76bfbf9a3c037dcb0723 to your computer and use it in GitHub Desktop.
Save nanggo/3568ec7fe12d76bfbf9a3c037dcb0723 to your computer and use it in GitHub Desktop.
compose 구현
function compose() {
const funcArray = Array.prototype.slice.call(arguments);
return funcArray.reduce(
(prevFunc, nextFunc) =>
() => {
const args = Array.prototype.slice.call(arguments);
return nextFunc(prevFunc.apply(null, args));
}
)
}
function comp() {
const funcArr = Array.prototype.slice.call(arguments);
return funcArr.reduce(
function(prevFunc, nextFunc) {
return function() {
const args = Array.prototype.slice.call(arguments);
return nextFunc(prevFunc.apply(null, args));
}
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment