2.0.0 • Published 2 months ago

ua-query v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
2 months ago

NPM version Build Status

ua-query

Lazy user agent string checker for connect compatible requests

Install

$ npm install --save ua-query

Usage

var ua = require('ua-query');

function middleware(req, res, next) {
  if (ua.isChrome(req, 45) || ua.isFirefox(req, 40)) {
    res.locals.polyfills = false;
  }
}

API

ua-query functions take request as the first parameter and optionally version number as the second.

browsers:

  • isChrome(req[, version])
  • isFirefox(req[, version])
  • isSafari(req[, version])
  • isIE(req[, version])
  • isEdge(req[, version])
  • isBot(req[, version]) - a few strange bots
  • isOld(browser, version) - true if browser type matches but the version is older than specified version

OS:

  • isWindowsXP(req)

In-browser usage

When used in the browser ua-query will check self.navigator.userAgent. Browser-side API is similar to server-side API but it skips req parameter.

var ua = require('ua-query');

function isModern(req, res, next) {
  return ua.isChrome(45) || ua.isFirefox(40);
}

License

MIT © Damian Krzeminski

2.0.0

2 months ago

1.3.2

2 years ago

1.3.1

4 years ago

1.3.0

6 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.0

7 years ago