ua-semver

1.1.0 • Public • Published

ua-semver

Build Status Dependency Status devDependency Status

Check user-agent with semver syntax.

Install

npm install ua-semver

Usage

var ua = require('ua-semver');
 
var capabilities = [
  {
    family: 'chrome',
    version: '>=33'
  },
  {
    family: 'firefox',
    version: '>=23'
  }
];
 
ua.satisfies(navigator.userAgent, capabilities); // true or false

ua.satisfies(userAgent, capabilities)

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'
  }
});

License

MIT

Package Sidebar

Install

npm i ua-semver

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

13.1 kB

Total Files

8

Last publish

Collaborators

  • neoziro