ua-cases
v1.3.2
Published
Returns cases object based on user agent.
Downloads
10
Maintainers
Readme
#ua-cases
Returns cases object based on user agent.
var obj = cases(useragent, cases, transform)
Returns a cases object bases on the user agent including data such as browser, device and platform
- useragent (string|object) - user agent string or vigour-ua object
- cases (object) - (optional) object to be merged to the output result
- transform (function) - (optional) function to modify the cases object before it's returned
- returns (object) obj - cases object
####example
const useragent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.3'
const cases = require('ua-cases')
const obj = cases(useragent)
/*
→ {
$chrome: true,
$edge: false,
$windows: false,
$ie10: false,
$android: false,
$chromecast: false,
$desktop: true,
$ios: false,
$native: false,
$phone: false,
$tablet: false,
$touch: false,
$tv: false,
$ie: false,
'$ie10': false,
$firefox: false
}
/*