Created
November 15, 2016 16:57
-
-
Save newyankeecodeshop/94f0bb8b6a34d60c95f264ea3deed0c4 to your computer and use it in GitHub Desktop.
Browser detection for ES6 support
This file contains 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
/** | |
* Detect browser capabilities on the server. | |
*/ | |
var useragent = require('useragent') | |
var MinimumForES6 = { | |
"Chrome": 49, | |
"Edge": 14, | |
"Firefox": 45, | |
"Safari": 10 | |
} | |
function supportsES6(headers) { | |
var agent = useragent.lookup(headers['user-agent']) | |
var requiredVersion = MinimumForES6[agent.family] | |
if (requiredVersion) { | |
return parseInt(agent.major) >= requiredVersion | |
} | |
return false | |
} | |
exports.supportsES6 = supportsES6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment