Skip to content

Instantly share code, notes, and snippets.

@janneh
Last active December 28, 2016 23:06
Show Gist options
  • Save janneh/78133844813a2c86a3bb922a2061bffb to your computer and use it in GitHub Desktop.
Save janneh/78133844813a2c86a3bb922a2061bffb to your computer and use it in GitHub Desktop.
dispatch logic
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