Skip to content

anzerr/agent.util

Repository files navigation

Intro

GitHub Actions status | linter GitHub Actions status | publish GitHub Actions status | test

Parse and fetch info found inside user-agent

Install

npm install --save git+https://git@github.com/anzerr/agent.util.git
npm install --save @anzerr/agent.util

Example

const {UserAgent} = require('@anzerr/agent.util');

const u = new UserAgent();

const agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36';
console.log(u.get(agent), agent);
/*
{
  os: null,
  phone: null,
  tablet: null,
  valid: { tablet: false, phone: false },
  uas: [],
  props: [
    { key: 'Safari', version: '537.36' },
    { key: 'Webkit', version: '537.36' },
    { key: 'Chrome', version: '84.0.4147.105' },
    { key: 'Windows NT', version: '10.0' }
  ],
  utils: [ { key: 'WebKit', version: '537.36' } ]
} Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
*/