Skip to content

Instantly share code, notes, and snippets.

@alersenkevich
Last active October 26, 2017 09:50
Show Gist options
  • Save alersenkevich/37c6081ed32617d2cfe5adf8b11fe62d to your computer and use it in GitHub Desktop.
Save alersenkevich/37c6081ed32617d2cfe5adf8b11fe62d to your computer and use it in GitHub Desktop.
applyMiddleware function
const dummy = ws => ws
export const applyMiddlewareForWebSocket = (ws, ...fnList) => {
let tmp = ws
fnList.forEach((fn, index) => {
tmp = fn(tmp, fnList[index + 1] || dummy)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment