How to use the bowser.getParser function in bowser

To help you get started, we’ve selected a few bowser 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 feross / simple-peer / test / common.js View on Github external
exports.isBrowser = function (name) {
  if (typeof (window) === 'undefined') return false
  const satifyObject = {}
  if (name === 'ios') { // bowser can't directly name iOS Safari
    satifyObject.mobile = { safari: '>=0' }
  } else {
    satifyObject[name] = '>=0'
  }
  return bowser.getParser(window.navigator.userAgent).satisfies(satifyObject)
}
github crowbartools / MixrElixr / src / background / background.js View on Github external
import moment from 'moment';
import TTLCache from './TTLCache';

import Bowser from 'bowser';
const browserEnv = Bowser.getParser(window.navigator.userAgent);
const onlyLocalStorage = browserEnv.satisfies({
    Linux: {
        Chrome: '>0'
    },
    'Chrome OS': {
        Chrome: '>0'
    }
});

global.browser = require('webextension-polyfill');

// constants
const ELIXR_CLIENT_ID = 'd2158e591bb347931751bef151ee3bf3e5c8cb9608924a7a';
const CURRENT_USER_URL = 'https://mixer.com/api/v1/users/current';
const PAGE_LIMIT = 100;
const FOLLOWS_URL = `https://mixer.com/api/v1/users/{userId}/follows?fields=id,token,name,type,user&where=online:eq:true&limit=${PAGE_LIMIT}`;
github versatica / mediasoup-client / src / Device.ts View on Github external
if (typeof navigator === 'object' && navigator.product === 'ReactNative')
	{
		if (typeof RTCPeerConnection === 'undefined')
		{
			logger.warn('detectDevice() | unsupported ReactNative without RTCPeerConnection');

			return;
		}

		return ReactNative;
	}
	// Browser.
	else if (typeof navigator === 'object' && typeof navigator.userAgent === 'string')
	{
		const ua = navigator.userAgent;
		const browser = bowser.getParser(ua);
		const engine = browser.getEngine();

		// Chrome and Chromium.
		if (browser.satisfies({ chrome: '>=74', chromium: '>=74' }))
		{
			return Chrome74;
		}
		else if (browser.satisfies({ chrome: '>=70', chromium: '>=70' }))
		{
			return Chrome70;
		}
		else if (browser.satisfies({ chrome: '>=67', chromium: '>=67' }))
		{
			return Chrome67;
		}
		else if (browser.satisfies({ chrome: '>=55', chromium: '>=55' }))
github inker / draw / src / utils / browser.ts View on Github external
import bowser from 'bowser'

const parser = bowser.getParser(window.navigator.userAgent)
const platformType = parser.getPlatformType()

export const isHandheld = platformType === 'mobile' || platformType === 'tablet'

export const isFirefox = parser.getBrowserName() === 'Firefox'
github peterjoseph / Reeve / client / App.js View on Github external
browserVersionCheck() {
		const activeBrowser = bowser.getParser(window.navigator.userAgent);
		const isSupported = activeBrowser.satisfies(MINIMUM_BROWSER_VERSIONS);
		if (!isSupported) {
			notify.show(t("error.outdatedBrowser"), "warning");
		}
	}
github DiceBear / avatars / packages / avatars-initials-sprites / src / index.ts View on Github external
fontSize: 50,
    chars: 2,
    userAgent: typeof window !== 'undefined' && window.navigator && window.navigator.userAgent,
    ...options
  };

  let backgroundColors: string[] = [];
  let isInternetExplorer =
    options.userAgent &&
    Bowser.getParser(options.userAgent).satisfies({
      ie: '>0',
      edge: '>0'
    });
  let isSafari =
    options.userAgent &&
    Bowser.getParser(options.userAgent).satisfies({
      safari: '>0'
    });

  Object.keys(Color.collection).forEach((backgroundColor: keyof ColorCollection) => {
    if (
      options.backgroundColors === undefined ||
      options.backgroundColors.length === 0 ||
      options.backgroundColors.indexOf(backgroundColor) !== -1
    ) {
      backgroundColors.push(Color.collection[backgroundColor][options.backgroundColorLevel]);
    }
  });

  return function(random: Random) {
    let backgroundColor = random.pickone(backgroundColors);
    let seedInitials = (initials(random.seed.trim()) as string).toLocaleUpperCase().slice(0, options.chars);
github dessant / buster / src / utils / common.js View on Github external
async function getBrowser() {
  let name, version;
  try {
    ({name, version} = await browser.runtime.getBrowserInfo());
  } catch (e) {}

  if (!name) {
    ({name, version} = Bowser.getParser(
      window.navigator.userAgent
    ).getBrowser());
  }

  name = name.toLowerCase();

  return {name, version};
}
github uber / deck.gl / website / src / components / demos / heatmap-demo.js View on Github external
function shouldEnableColorDomain() {
  const OS_NAMES_TO_DETECT = ['windows', 'ios'];
  const parser = Bowser.getParser(window.navigator.userAgent);
  const currentOS = parser.getOSName(true);
  return OS_NAMES_TO_DETECT.includes(currentOS);
}
github zouhir / browser-media-support / src / components / app.js View on Github external
componentDidMount() {
		if( typeof document === 'undefined' ) return;
		let ua = bowser.getParser(window.navigator.userAgent) 
		let {browser, platform, os} = ua.parsedResult;
		this.setState({
			browser: `${browser.name} ${browser.version}`,
			os: `${os.name} ${os.versionName ? os.versionName : os.version}`,
			platform: platform.type
		})
	}
github unchained-capital / unchained-wallets / src / interaction.js View on Github external
constructor({network}) {
    this.network = network;
    this.environment = Bowser.getParser(window.navigator.userAgent);
    this.failureText = '';
    this.failureCode = '';
  }