Last active
December 28, 2016 23:06
-
-
Save janneh/78133844813a2c86a3bb922a2061bffb to your computer and use it in GitHub Desktop.
dispatch logic
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
function output(a, b, format = 'text') { | |
const dispatchTable = { | |
"text": textOutput, | |
"html": htmlOutput | |
} | |
if (dispatchTable[format] === undefined) { | |
throw new Error(`unknown format ${format}`) | |
} | |
return dispatchTable[format].call(this, a, b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment