vigour-ua
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/vigour-ua package

4.0.0 • Public • Published

vigour-ua

Build Status npm version Coverage Status

ua parser with a light footprint (~1kb)

parse user agent strings

var ua = require('vigour-ua')
var 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'
console.log(ua(userAgent))

outputs

{
  "browser": "chrome",
  "version": 46,
  "prefix": "webkit",
  "platform": "mac",
  "device": "desktop"
}

merge into objects

var ua = require('vigour-ua')
var someObject = {
  randomField: true
}
console.log(ua(userAgent, someObject))

outputs someObject

{
  "browser": "chrome",
  "version": 46,
  "prefix": "webkit",
  "platform": "mac",
  "device": "desktop",
  "randomField": true
}

This useragent parser does not catch all useragents, if you encounter a device thats wrongly parsed add a test!

Dependencies (0)

    Dev Dependencies (8)

    Package Sidebar

    Install

    npm i vigour-ua

    Weekly Downloads

    192

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    125 kB

    Total Files

    14

    Last publish

    Collaborators

    • jimdebeer
    • vigour-io