Last active
May 12, 2016 17:42
-
-
Save tkers/8f5f009dc0a402a53a50f0151996865a to your computer and use it in GitHub Desktop.
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
// const composed = composeMiddleware(fn1, fn2, fn3); | |
const composeMiddleware = (head, ...tail) => (req, res, next) => | |
head instanceof Function ? | |
head(req, res, () => composeMiddleware(...tail)(req, res, next)) : | |
next(); | |
// var composed5 = composeMiddlewareES5([fn1, fn2, fn3]); | |
var composeMiddlewareES5 = funcs => (req, res, next) => | |
funcs[0] instanceof Function ? | |
funcs[0](req, res, () => composeMiddlewareES5(funcs.slice(1))(req, res, next)) : | |
next(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment