Skip to content

Instantly share code, notes, and snippets.

@newyankeecodeshop
Created November 15, 2016 16:57
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save newyankeecodeshop/94f0bb8b6a34d60c95f264ea3deed0c4 to your computer and use it in GitHub Desktop.
Browser detection for ES6 support
/**
* 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