New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bowser-mini

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bowser-mini

Lightweight browser detector with tiny output

  • 2.8.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Bowser Mini

This is an exact copy of Bowser, except smaller, and only returns something a logger can parse in a much smaller space. Use the below mapper object to translate the short string.

This package is ideal if you're storing log or analytic data.

String format

The string returned is 3 variables, separated by commas.

Variable 1: The Browser/OS/Platform/Engine types.

  • Byte 1: Browser
  • Byte 2: OS
  • Byte 3: Platform
  • Byte 4: Engine

Variable 2: The Browser version.

Variable 3: The OS version.

The Mapper Object...

cons mapper = {
  browser: { // Byte 1
    'A': 'Android Browser',
    'a': 'Amazon Silk',
    'b': 'Bada',
    'B': 'BlackBerry',
    'C': 'Chrome',
    'c': 'Chromium',
    'E': 'Electron',
    'e': 'Epiphany',
    'F': 'Firefox',
    'f': 'Focus',
    'g': 'Generic',
    'G': 'Googlebot',
    'S": 'Google Search',
    'X': 'Internet Explorer',
    'K': 'K-Meleon',
    'm': 'Maxthon',
    'x': 'Microsoft Edge',
    'z': 'MZ Browser',
    'n': 'NAVER Whale Browser',
    'O': 'Opera',
    'o': 'Opera Coast',
    'P': 'PhantomJS',
    'L': 'Playstation 4',
    'p': 'Puffin',
    'u': 'QupZilla',
    'Q': 'QQ Browser',
    'q': 'QQ Browser Lite',
    'S': 'Safari',
    '1': 'Sailfish',
    '2': 'Samsung Internet for Android',
    '3': 'SeaMonkey',
    '4': 'Sleipnir',
    '5': 'Swing',
    '6': 'Tizen',
    '7': 'UC Browser',
    '8': 'Vivaldi',
    '9': 'SlimerJS',
    'W': 'WebOS Browser',
    'w': 'WeChat',
    'Y': 'Yandex Browser',
    '?': 'Unknown'
  },
  os: { // Byte 2
    'W': 'Windows',
    'w': 'Windows Phone',
    'M': 'macOS',
    'i': 'iOS',
    'A': 'Android',
    'W': 'WebOS',
    'B': 'BlackBerry',
    'b': 'Bada',
    'T': 'Tizen',
    'L': 'Linux',
    'C': 'Chrome OS',
    'P': 'PlayStation 4',
    'R': 'Roku'
  },
  platforms: { // Byte 3
    'T': 'tablet',
    'M': 'mobile',
    'D': 'desktop',
    'V': 'tv'
  },
  engines: { // Byte 4
    'E': 'EdgeHTML',
    'B': 'Blink',
    'T': 'Trident',
    'P': 'Presto',
    'G': 'Gecko',
    'W': 'WebKit'
  }
}

Bowser

A small, fast and rich-API browser/platform/engine detector for both browser and node.

  • Small. Use plain ES5-version which is ~4.8kB gzipped.
  • Optimized. Use only those parsers you need — it doesn't do useless work.
  • Multi-platform. It's browser- and node-ready, so you can use it in any environment.

Don't hesitate to support the project on Github or OpenCollective if you like it ❤️ Also, contributors are always welcome!

Financial Contributors on Open Collective Build Status Greenkeeper badge Coverage Status Downloads

Contents

Overview

The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers.

⚠️ Version 2.0 breaking changes ⚠️

Version 2.0 has drastically changed the API. All available methods are on the docs page.

For legacy code, check out the 1.x branch and install it through npm install bowser@1.9.4.

Use cases

First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.

const Bowser = require("bowser"); // CommonJS

import * as Bowser from "bowser"; // TypeScript

import Bowser from "bowser"; // ES6 (and TypeScript with --esModuleInterop enabled)

By default, the exported version is the ES5 transpiled version, which do not include any polyfills.

In case you don't use your own babel-polyfill you may need to have pre-built bundle with all needed polyfills. So, for you it's suitable to require bowser like this: require('bowser/bundled'). As the result, you get a ES5 version of bowser with babel-polyfill bundled together.

You may need to use the source files, so they will be available in the package as well.

Browser props detection

console.log(Bowser.parse(window.navigator.userAgent));

// outputs
"CWDB,79.0.3945.88,NT 10.0"

Keywords

FAQs

Package last updated on 01 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc