Check user-agent with semver syntax.
npm install ua-semver
var ua = require('ua-semver');
var capabilities = [
{
family: 'chrome',
version: '>=33'
},
{
family: 'firefox',
version: '>=23'
}
];
ua.satisfies(navigator.userAgent, capabilities); // true or false
Check if the user agent satisfy some capability. You can pass a capability or an array of capabilities. A capability is an object containing two attributes: "family" and "version", "version" must use the semver syntax.
ua.satisfies(navigator.userAgent, {
family: 'chrome',
version: '>=33'
});
You can specify an Os with the same two attributes family and version.
ua.satisfies(navigator.userAgent, {
family: 'mobile safari',
version: '>=6',
os: {
family: 'ios',
version: '>=6'
}
});
In the same way, you can specify a device.
ua.satisfies(navigator.userAgent, {
family: 'mobile safari',
version: '>=6',
device: {
family: 'ipad'
}
});
MIT