All Projects โ†’ richardscarrott โ†’ Bugz

richardscarrott / Bugz

Licence: mit
๐Ÿ› Composable User Agent Detection using Ramda

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Bugz

Device Detector Js
A precise user agent parser and device detector written in TypeScript
Stars: โœญ 193 (+1186.67%)
Mutual labels:  os, user-agent, device, browser
Bow
๐Ÿน Bow is a cross-platform library for Typed Functional Programming in Swift
Stars: โœญ 538 (+3486.67%)
Mutual labels:  composition, functional-programming, fp
Kotlin Result
A multiplatform Result monad for modelling success or failure operations.
Stars: โœญ 369 (+2360%)
Mutual labels:  functional-programming, fp, browser
Rambda
Faster and smaller alternative to Ramda
Stars: โœญ 1,066 (+7006.67%)
Mutual labels:  ramda, functional-programming, fp
Parser Javascript
Browser sniffing gone too far โ€” A useragent parser library for JavaScript
Stars: โœญ 66 (+340%)
Mutual labels:  user-agent, device, browser
Promised Pipe
A ramda.pipe-like utility that handles promises internally with zero dependencies
Stars: โœญ 64 (+326.67%)
Mutual labels:  ramda, composition, fp
Agent
๐Ÿ‘ฎ A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect
Stars: โœญ 3,891 (+25840%)
Mutual labels:  user-agent, browser
Swift Web
๐Ÿ•ธ A collection of Swift server-side frameworks for handling HTML, CSS, routing and middleware.
Stars: โœญ 415 (+2666.67%)
Mutual labels:  composition, functional-programming
Fasy
FP iterators that are both eager and asynchronous
Stars: โœญ 488 (+3153.33%)
Mutual labels:  functional-programming, fp
Performance Analysis Js
Map/Reduce/Filter/Find Vs For loop Vs For each Vs Lodash vs Ramda
Stars: โœญ 532 (+3446.67%)
Mutual labels:  ramda, functional-programming
Monio
Async-capable IO monad for JS
Stars: โœญ 311 (+1973.33%)
Mutual labels:  functional-programming, fp
Fp Jargon Zh
ๅ‡ฝๆ•ฐๅผ็ผ–็จ‹ๆœฏ่ฏญๅŠ็คบไพ‹ใ€‚ๆœฌ้กน็›ฎ่ฏ‘่‡ช https://github.com/hemanth/functional-programming-jargon
Stars: โœญ 507 (+3280%)
Mutual labels:  functional-programming, fp
Browser.php
A PHP Class to detect a user's Browser. This encapsulation provides a breakdown of the browser and the version of the browser using the browser's user-agent string. This is not a guaranteed solution but provides an overall accurate way to detect what browser a user is using.
Stars: โœญ 546 (+3540%)
Mutual labels:  user-agent, browser
Fun Task
Abstraction for managing asynchronous code in JS
Stars: โœญ 363 (+2320%)
Mutual labels:  functional-programming, fp
Detect Gpu
Classifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications.
Stars: โœญ 460 (+2966.67%)
Mutual labels:  device, browser
Scriptum
A fool's scriptum on functional programming
Stars: โœญ 346 (+2206.67%)
Mutual labels:  composition, functional-programming
Funfix
Functional Programming Library for JavaScript, TypeScript and Flow โœจโšก๏ธ
Stars: โœญ 596 (+3873.33%)
Mutual labels:  functional-programming, fp
Fkit
A functional programming toolkit for JavaScript.
Stars: โœญ 588 (+3820%)
Mutual labels:  functional-programming, fp
Frameless
Expressive types for Spark.
Stars: โœญ 717 (+4680%)
Mutual labels:  functional-programming, fp
Exokit
Native VR/AR/XR engine for JavaScript ๐Ÿฆ–
Stars: โœญ 809 (+5293.33%)
Mutual labels:  engine, browser

Bugz npm version Build Status Coverage Status

Composable user agent detection using Ramda, powered by ua-parser-js.

Why?

Because browsers have bugs bugz.

MDN offers some good advice about when and when not to use user agent detection.

Yeah, but why another UA library?

Bugz isn't really another library, it's just a lightweight* functional wrapper around ua-parser-js.

* for those already using Ramda.

Install

$ npm install ramda
$ npm install bugz

Ramda is defined as a peer dependency meaning it needs to be defined in your own package.json.

Usage

https://repl.it/Nlm0/1

import { isOSName } from 'bugz';

const isWindows = isOSName('Windows');

if (isWindows(window.navigator.userAgent)) {
    console.log('OS is Windows');
}
import { isOSName, isBrowserName } from 'bugz';
import { allPass } from 'ramda';

const isWindows = isOSName('Windows');
const isFirefox = isBrowserName('Firefox');
const isWindowsFirefox = allPass([
    isWindows,
    isFirefox
]);

if (isWindowsFirefox(window.navigator.userAgent)) {
    console.log('OS is Windows and Browser is Firefox');
}
import { isOSName, isBrowserName, isBrowserVersionLt } from 'bugz';
import { allPass } from 'ramda';

const isWindows = isOSName('Windows');
const isFirefox = isBrowserName('Firefox');
const isBrowserVersionLt3_7 = isBrowserVersionLt('3.7');
const isWindowsFirefoxLt3_7 = allPass([
    isWindows,
    isFirefox,
    isBrowserVersionLt3_7
]);

if (isWindowsFirefoxLt3_7(window.navigator.userAgent)) {
    console.log('OS is Windows and Browser is Firefox < 3.7');
}

Examples

Further examples can be found here.

API

All functions are curried by default.

about (ua: string) โ†’ void
Logs all information obtained from the user agent string to the console.

getBrowser (ua: string) โ†’ { name: string, version: string, majorVersion: number }
Returns the browser from the user agent string.

getBrowserName (ua: string) โ†’ string
Returns the browser name from the user agent string.

getBrowserVersion (ua: string) โ†’ string
Returns the browser version from the user agent string.

getEngine (ua: string) โ†’ { name: string, version: string }
Returns the engine from the user agent string.

getEngineName (ua: string) โ†’ string
Returns the engine name from the user agent string.

getEngineVersion (ua: string) โ†’ string
Returns the engine version from the user agent string.

getOS (ua: string) โ†’ { name: string, version: string }
Returns the OS from the user agent string.

getOSName (ua: string) โ†’ string
Returns the OS name from the user agent string.

getOSVersion (ua: string) โ†’ string
Returns the OS version from the user agent string.

isAndroid (ua: string) โ†’ boolean
Returns whether or not the operating system is Android.

isAndroidBrowser (ua: string) โ†’ boolean
Returns whether or not the browser is Android Browser.

isBrowserName (name: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the browser name is name.

isBrowserVersion (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the browser version is version.

isBrowserVersionGt (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the browser version is greater than version.

isBrowserVersionGte (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the browser version is greater than or equal to version.

isBrowserVersionLt (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the browser version is less than version.

isBrowserVersionLte (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the browser version is less than or equal to version.

isChrome (ua: string) โ†’ boolean
Returns whether or not the browser is Chrome.

isEdge (ua: string) โ†’ boolean
Returns whether or not the browser is Edge.

isEdgeHTML (ua: string) โ†’ boolean
Returns whether or not the engine is EdgeHTML.

isEngineName (name: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the engine name is name.

isEngineVersion (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the engine version is version.

isEngineVersionGt (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the engine version is greater than version.

isEngineVersionGte (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the engine version is greater than or equal to version.

isEngineVersionLt (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the engine version is less than version.

isEngineVersionLte (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the engine version is less than or equal to version.

isFirefox (ua: string) โ†’ boolean
Returns whether or not the browser is Firefox.

isGecko (ua: string) โ†’ boolean
Returns whether or not the engine is Gecko.

isIE (ua: string) โ†’ boolean
Returns whether or not the browser is Internet Explorer.

isIEMobile (ua: string) โ†’ boolean
Returns whether or not the browser is Internet Explorer Mobile.

isIOS (ua: string) โ†’ boolean
Returns whether or not the operating system is iOS.

isMacOS (ua: string) โ†’ boolean
Returns whether or not the operating system is Mac OS.

isMobileSafari (ua: string) โ†’ boolean
Returns whether or not the browser is Mobile Safari.

isOSName (name: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the OS name is name.

isOSVersion (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the OS version is version.

isOSVersionGt (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the OS version is greater than version.

isOSVersionGte (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the OS version is greater than or equal to version.

isOSVersionLt (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the OS version is less than version.

isOSVersionLte (version: string) โ†’ (ua: string) โ†’ boolean
Returns whether or not the OS version is less than or equal to version.

isOpera (ua: string) โ†’ boolean
Returns whether or not the browser is Opera.

isOperaMobile (ua: string) โ†’ boolean
Returns whether or not the browser is Opera Mobile.

isPresto (ua: string) โ†’ boolean
Returns whether or not the engine is Presto.

isSafari (ua: string) โ†’ boolean
Returns whether or not the browser is Safari (desktop).

isTrident (ua: string) โ†’ boolean
Returns whether or not the engine is Trident.

isWebKit (ua: string) โ†’ boolean
Returns whether or not the engine is WebKit.

isWindows (ua: string) โ†’ boolean
Returns whether or not the operating system is Windows.

isWindowsPhone (ua: string) โ†’ boolean
Returns whether or not the operating system is Windows Phone.

parse (ua: string) โ†’ { ua: string, browser: { name: string, version: string, majorVersion: string }, engine: { name: string, version: string }, os: { name: string, version: string }
Returns all information obtained from the user agent string.

Module Formats

ES2015

import { isBrowserName } from 'bugz';

Unfortuantely tree shaking isn't particularly effective on Bugz because most exports are pure curried functions which aren't currently susceptible to dead code elimination. Therefore, a modular CommonJS build is additionally offered.

CommonJS

const bugz = require('bugz');
// Or modular for optimized builds
const isBrowserName = require('bugz/isBrowserName');
const isBrowserVersion = require('bugz/isBrowserVersion');

UMD

<script src="bugz.umd.js"></script>
<script>
    const isBrowserName = Bugz.isBrowserName;
</script>
require(['bugz'], bugz => {});

License

MIT

Thank you

BrowserStack

BrowserStack for providing a free subscription to support cross browser testing.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].