Enums Submodule
Import these enums from 'ua-parser-js/enums'
Code Example
- Match for a specific
os.name
:
js
import { UAParser } from 'ua-parser-js';
import { OSName } from 'ua-parser-js/enums';
const { os } = UAParser();
if (os.is(OSName.RIM_TABLET_OS)) {
console.log('Are you for real?');
}
- Match for a specific
browser.type
:
js
import { UAParser } from 'ua-parser-js';
import { Crawlers } from 'ua-parser-js/extensions';
import { BrowserType } from 'ua-parser-js/enums';
const uaParser = new UAParser(Crawlers);
const typeofBrowser = uaParser
.setUA(req.headers['user-agent'])
.getBrowser()
.type;
if (typeofBrowser == BrowserType.CRAWLER) {
console.log('Hi, hello there Spidey!');
}