How to use the detect-browser.detect function in detect-browser

To help you get started, we’ve selected a few detect-browser 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 mozilla / hubs / src / utils / vr-caps-detect.js View on Github external
const { detect } = require("detect-browser");

const browser = detect();

// Precision on device detection is fuzzy -- we can sometimes know if a device is definitely
// available, or definitely *not* available, and assume it may be available otherwise.
export const VR_DEVICE_AVAILABILITY = {
  yes: "yes", // Implies VR can be launched into on this device immediately, in this browser
  no: "no", // Implies this VR device is definitely not supported regardless of browser
  maybe: "maybe" // Implies this device may support this VR platform, but may not be installed or in a compatible browser
};

function isMaybeGearVRCompatibleDevice(ua) {
  return /\WAndroid\W/.test(ua);
}

function isMaybeDaydreamCompatibleDevice(ua) {
  return /\WAndroid\W/.test(ua);
}
github JimmyVV / httplive / src / httpflv / src / index.js View on Github external
constructor(url = '', config = {}) {
        super();

        this._browser = detect();


        // replace the object
        if (typeof url === 'object') {
            config = url;
        } else if (typeof url === 'string') {
            this._url = url;
        }


        switch (this._browser && this._browser.name) {
            case 'chrome':
            case "safari":
                this._xhr = new FetchChunked(config);
                break;
            case 'firefox':
github DefinitelyTyped / DefinitelyTyped / types / detect-browser / detect-browser-tests.ts View on Github external
import { detect } from 'detect-browser';
const browser = detect();

if (browser) {
    const name: string = browser.name;
    const version: string = browser.version;
}
github metasfresh / metasfresh-webui-frontend / src / containers / Login.js View on Github external
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { detect } from 'detect-browser';

import LoginForm from '../components/app/LoginForm';

const BROWSER = detect();

class Login extends Component {
  constructor(props) {
    super(props);
  }

  UNSAFE_componentWillMount() {
    const { logged, dispatch } = this.props;
    if (logged) {
      dispatch(push('/'));
    }
  }

  browserSupport = (...supportedBrowsers) => {
    const userBrowser = BROWSER.name;
    let isSupported = false;
github gotify / server / ui / src / actions / UserAction.ts View on Github external
export function login(username: string, password: string) {
    const browser = detect();
    const name = (browser && browser.name + ' ' + browser.version) || 'unknown browser';
    authenticating();
    axios
        .create()
        .request({
            url: config.get('url') + 'client',
            method: 'POST',
            data: {name},
            auth: {username, password},
        })
        .then((resp) => {
            GlobalAction.snack(`A client named '${name}' was created for your session.`);
            setAuthorizationToken(resp.data.token);
            tryAuthenticate()
                .then(GlobalAction.initialLoad)
                .catch(() =>
github polkadot-js / apps / packages / app-accounts / src / Banner.tsx View on Github external
[
  {
    browsers: {
      chrome: 'https://chrome.google.com/webstore/detail/polkadot%7Bjs%7D-extension/mopnmbcafieddcagagdcbnhejhlodfdd',
      firefox: 'https://addons.mozilla.org/en-US/firefox/addon/polkadot-js-extension/'
    },
    desc: 'Basic account injection and signer',
    name: 'polkadot-js extension'
  }
].forEach(({ browsers, desc, name }): void => {
  Object.entries(browsers).forEach(([browser, link]): void => {
    available[browser as Browser].push({ link, desc, name });
  });
});

const browserInfo = detect();
const browserName: Browser | null = (browserInfo && (browserInfo.name as Browser)) || null;
const isSupported = browserName && Object.keys(available).includes(browserName);

function Banner ({ className, t }: Props): React.ReactElement | null {
  if (isWeb3Injected || !isSupported || !browserName) {
    return null;
  }

  return (
    <div>
      <div>
        <div>
          <p>{t('It is recommended that you create/store your accounts securely and externally from the app. On {{yourBrowser}} the following browser extensions are available for use -', {
            replace: {
              yourBrowser: stringUpperFirst(browserName)
            }</p></div></div></div>
github marp-team / marp-web / src / components / utils.ts View on Github external
import { detect } from 'detect-browser'

const browser = detect()

export function combineClass(from, ...classes: string[]) {
  const combined = {
    ...from,
    class: [from.className || from.class, ...classes].filter(k => k).join(' '),
  }

  delete combined.className
  return combined
}

export function isChrome() {
  return browser && browser.name === 'chrome'
}
github cryptii / cryptii / src / Browser.js View on Github external
static identify () {
    if (identifier === null) {
      const browser = detect()
      identifier = browser
        ? `${browser.name}-${browser.version.replace(/\./g, '-')}`
        : false
    }
    return identifier
  }
github kbumsik / opus-media-recorder / src / OpusMediaRecorder.js View on Github external
const { EventTarget, defineEventAttribute } = require('event-target-shim');
const { detect } = require('detect-browser');
const browser = detect();

const AudioContext = global.AudioContext || global.webkitAudioContext;
const BUFFER_SIZE = 4096;

/**
 * Reference: https://w3c.github.io/mediacapture-record/#mediarecorder-api
 * @extends EventTarget
 */
class OpusMediaRecorder extends EventTarget {
  /**
   * A function that returns the encoder web worker
   * @name workerFactory
   * @function
   * @returns {worker} An instance of ./encoderWorker.js web worker.
   */

detect-browser

Unpack a browser type and version from the useragent string

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis