Last active
August 29, 2015 14:07
-
-
Save bigmeech/abb53b238eaaf3fa1971 to your computer and use it in GitHub Desktop.
switch alternative
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 fomatCSV(req, res){ | |
//format csv | |
} | |
function formatExcel(req, res){ | |
//formatExcel | |
} | |
//------- switch alternative-- | |
var formats = { | |
csv:formatCSV, | |
excel:formatExcel | |
}; | |
if(formats[req.query.format]){ | |
formats[req.query.format](req, res); | |
} else next(); | |
//-------the switch ends here ---- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment