How to use the ua-parser-js/dist/ua-parser.min function in ua-parser-js

To help you get started, we’ve selected a few ua-parser-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duskload / react-device-detect / src / init.js View on Github external
function init() {
  if (typeof window !== 'undefined') {
    if (window && window.navigator) {
      UA = new UAParser();

      browser = UA.getBrowser();
      cpu = UA.getCPU();
      device = UA.getDevice();
      engine = UA.getEngine();
      os = UA.getOS();
      ua = UA.getUA();
    }
  }
}
github duskload / react-device-detect / src / components / helpers / get-ua-data.js View on Github external
const UAParser = require("ua-parser-js/dist/ua-parser.min");

export const UA = new UAParser();

export const browser = UA.getBrowser();
export const cpu = UA.getCPU();
export const device = UA.getDevice();
export const engine = UA.getEngine();
export const os = UA.getOS();
export const ua = UA.getUA();
export const setUA = uaStr => UA.setUA(uaStr);

export const mockUserAgent = userAgent => {
  window.navigator.__defineGetter__("userAgent", () => userAgent);
};

export const setDefaults = (p, d = "none") => (p ? p : d);

export const isIOS13Check = type => {
github duskload / react-device-detect / main.js View on Github external
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var React = require('react');
var React__default = _interopDefault(React);

var UAParser = require('ua-parser-js/dist/ua-parser.min');

var UA = new UAParser();
var browser = UA.getBrowser();
var cpu = UA.getCPU();
var device = UA.getDevice();
var engine = UA.getEngine();
var os = UA.getOS();
var ua = UA.getUA();

var setDefaults = function setDefaults(p) {
  var d = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'none';
  return p ? p : d;
};
var getNavigatorInstance = function getNavigatorInstance() {
  if (typeof window !== 'undefined') {
    if (window.navigator || navigator) {
      return window.navigator || navigator;
    }

ua-parser-js

Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment

AGPL-3.0
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis