How to use the ua-parser-js.UAParser 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 DefinitelyTyped / DefinitelyTyped / types / ua-parser-js / ua-parser-js-tests.ts View on Github external
parser.getEngine().version

    // OS
    result.os.name
    result.os.version
    parser.getOS().name
    parser.getOS().version

    // CPU
    result.cpu.architecture
    parser.getCPU().architecture

    // Extensions
    var uaString = 'ownbrowser/1.3';
    var ownBrowser = [[/(ownbrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]];
    var parser = new UAParser(uaString, { browser: ownBrowser });

}
github DefinitelyTyped / DefinitelyTyped / types / ua-parser-js / ua-parser-js-tests.ts View on Github external
function test_parser() {
    var ua = 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6';
    var parser = new UAParser(ua);
    var result = parser.getResult();

    parser.getUA()
    parser.setUA("foo")

    result.ua

    // browser
    result.browser.name
    result.browser.version
    parser.getBrowser().name
    parser.getBrowser().version

    // device
    result.device.model
    result.device.type
github DefinitelyTyped / DefinitelyTyped / ua-parser-js / ua-parser-js-tests.ts View on Github external
parser.getEngine().version

    // OS
    result.os.name
    result.os.version
    parser.getOS().name
    parser.getOS().version

    // CPU
    result.cpu.architecture
    parser.getCPU().architecture

    // Extensions
    var uaString = 'ownbrowser/1.3';
    var ownBrowser = [[/(ownbrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]];
    var parser = new UAParser(uaString, { browser: ownBrowser });

}
github luan007 / edge-node-wrt / Apps / Launcher / drivers / P0FService.ts View on Github external
/// 
var UAParser = require('ua-parser-js');
var parser = new UAParser.UAParser();

class P0FService implements IInAppDriver {

    match(dev:IDevice, delta:IDriverDetla, cb:Callback) {
        //console.log("------------\n P0f match Called", dev.bus.data);
        cb(undefined, {});
    }

    attach(dev:IDevice, delta:IDriverDetla, matchResult:any, cb:PCallback) {
        console.log("P0f ATTACH Called");
        cb(undefined, {valid: true});
    }

    change(dev:IDevice, delta:IDriverDetla, cb:PCallback) {
        var runtimekey = 'App_' + global.runtime_id + ':P0F';
        var devAssump = dev.assumptions[runtimekey];
github Venryx / DebateMap / Source / Frame / General / UserAgent.ts View on Github external
| "Firefox" // desktop and mobile
	| "Safari" | "Mobile Safari" // desktop and mobile
	// supported, but not promoted (eg, mentioned in browser-not-supported warning)
	| "Chrome WebView" // android-browser
	| "Edge" // desktop and mobile (they're the same);
type BrowserName =
	| "Amaya" | "Android Browser" | "Arora" | "Avant" | "Baidu" | "Blazer" | "Bolt" | "Camino" | "Chimera" | "Chrome"
	| "Chromium" | "Comodo Dragon" | "Conkeror" | "Dillo" | "Dolphin" | "Doris" | "Edge" | "Epiphany" | "Fennec"
	| "Firebird" | "Firefox" | "Flock" | "GoBrowser" | "iCab" | "ICE Browser" | "IceApe" | "IceCat" | "IceDragon"
	| "Iceweasel" | "IE" | "IE Mobile" | "Iron" | "Jasmine" | "K-Meleon" | "Konqueror" | "Kindle" | "Links"
	| "Lunascape" | "Lynx" | "Maemo" | "Maxthon" | "Midori" | "Minimo" | "MIUI Browser" | "Safari" | "Mobile Safari"
	| "Mosaic" | "Mozilla" | "Netfront" | "Netscape" | "NetSurf" | "Nokia" | "OmniWeb" | "Opera" | "Opera Mini" | "Opera Mobi" | "Opera Tablet"
	| "PhantomJS" | "Phoenix" | "Polaris" | "QQBrowser" | "RockMelt" | "Silk" | "Skyfire" | "SeaMonkey" | "SlimBrowser"
	| "Swiftfox" | "Tizen" | "UCBrowser" | "Vivaldi" | "w3m" | "WeChat" | "Yandex";

let parser = new UAParser();
export function GetBrowser(): {name: BrowserName, version: string} {
	return parser.getBrowser();
}
/*export function GetBrowserName(): BrowserName {
	return parser.getBrowser().name;
}
export function GetBrowserVersion(): string {
	return parser.getBrowser().version;
}*/
github Polymer / tools / packages / browser-capabilities / src / browser-capabilities.ts View on Github external
export function browserCapabilities(userAgent: string): Set {
  const ua = new UAParser(userAgent);
  const capabilities = new Set();
  let browserName = ua.getBrowser().name || '';
  if (browserName === 'Chrome' && ua.getOS().name === 'iOS') {
    // Chrome on iOS is really Safari.
    browserName = 'Mobile Safari';
  }
  const predicates = browserPredicates[browserName] || {};
  for (const capability of Object.keys(predicates) as BrowserCapability[]) {
    if (predicates[capability](ua)) {
      capabilities.add(capability);
    }
  }
  return capabilities;
}
github AdaptiveConsulting / ReactiveTraderCloud / src / client / src / rt-platforms / browser / browser.ts View on Github external
const isRunningInIE = () => {
  const browser = new UAParser().getBrowser().name
  return browser && browser.indexOf('IE') !== -1
}
github chrisdwheatley / radiate / src / experimental-features / warn.js View on Github external
},
  link: {
    color: colors.fullWhite
  },
  purple: {
    background: `linear-gradient(22.5deg, rgba(103, 58, 183, .75), ${colors.deepPurple500})`
  },
  blue: {
    background: `linear-gradient(22.5deg, rgba(33, 150, 243, .75), ${colors.blue500})`
  },
  green: {
    background: `linear-gradient(22.5deg, rgba(76, 175, 80, .75), ${colors.green500})`
  }
}

const userAgent = new UAParser()

const browser = userAgent.getBrowser().name
const os = userAgent.getOS().name

const Warn = () => {
  return (
    <div>
      <div style="{[styles.cell,">
        <title title="Radiate">
        &lt;div style={styles.copy}&gt;
          Radiate is a responsive dashboard written in React - built for all screen sizes
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div style={[styles.cell, styles.blue]}&gt;
        &lt;Title title='Enabling CSS Grid Layout' /&gt;
        &lt;div style={styles.copy}&gt;</title></div></div>
github AdaptiveConsulting / ReactiveTraderCloud / src / client / src / rt-system / environment.ts View on Github external
static isRunningInIE() {
    if (isRunningInIE === null) {
      const browser = new UAParser().getBrowser().name
      isRunningInIE = !!browser && browser.indexOf('IE') !== -1
    }
    return isRunningInIE
  }
github Polymer / prpl-server / src / capabilities.ts View on Github external
export function browserCapabilities(userAgent: string): Set {
  const ua = new UAParser(userAgent);
  const capabilities = new Set();
  const predicates = browserPredicates[ua.getBrowser().name] || {};
  for (const capability of Object.keys(predicates) as BrowserCapability[]) {
    if (predicates[capability](ua)) {
      capabilities.add(capability);
    }
  };
  return capabilities;
}

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