{"id":15663592,"url":"https://github.com/richardscarrott/bugz","last_synced_at":"2025-08-21T12:39:55.044Z","repository":{"id":57191116,"uuid":"80349354","full_name":"richardscarrott/bugz","owner":"richardscarrott","description":":bug: Composable User Agent Detection using Ramda","archived":false,"fork":false,"pushed_at":"2019-02-12T23:25:26.000Z","size":70,"stargazers_count":17,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T14:56:56.212Z","etag":null,"topics":["browser","bugz","composition","device","engine","fp","functional-programming","node","nodejs","os","ramda","ua-parser","user-agent","user-agent-parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richardscarrott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-29T14:04:21.000Z","updated_at":"2021-12-19T13:13:49.000Z","dependencies_parsed_at":"2022-09-15T22:22:47.885Z","dependency_job_id":null,"html_url":"https://github.com/richardscarrott/bugz","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardscarrott%2Fbugz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardscarrott%2Fbugz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardscarrott%2Fbugz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardscarrott%2Fbugz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richardscarrott","download_url":"https://codeload.github.com/richardscarrott/bugz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252712599,"owners_count":21792342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","bugz","composition","device","engine","fp","functional-programming","node","nodejs","os","ramda","ua-parser","user-agent","user-agent-parser"],"created_at":"2024-10-03T13:38:33.002Z","updated_at":"2025-05-06T15:28:45.627Z","avatar_url":"https://github.com/richardscarrott.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bugz [![npm version](https://badge.fury.io/js/bugz.svg)](https://badge.fury.io/js/bugz) [![Build Status](https://travis-ci.org/richardscarrott/bugz.svg?branch=master)](https://travis-ci.org/richardscarrott/bugz) [![Coverage Status](https://coveralls.io/repos/github/richardscarrott/bugz/badge.svg?branch=master)](https://coveralls.io/github/richardscarrott/bugz?branch=master)\n\nComposable user agent detection using [`Ramda`](http://ramdajs.com/), powered by [`ua-parser-js`](https://github.com/faisalman/ua-parser-js).\n\n## Why?\n\nBecause browsers have \u003cs\u003ebugs\u003c/s\u003e bugz.\n\n\u003e [MDN offers some good advice about when and *when not* to use user agent detection](https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent).\n\n## Yeah, but why another UA library?\n\nBugz isn't really another library, it's just a lightweight* functional wrapper around [`ua-parser-js`](https://github.com/faisalman/ua-parser-js).\n\n\u003e \\* for those already using Ramda.\n\n## Install\n\n```\n$ npm install ramda\n$ npm install bugz\n```\n\n\u003e Ramda is defined as a peer dependency meaning it needs to be defined in your own package.json.\n\n## Usage\n\nhttps://repl.it/Nlm0/1\n\n```js\nimport { isOSName } from 'bugz';\n\nconst isWindows = isOSName('Windows');\n\nif (isWindows(window.navigator.userAgent)) {\n    console.log('OS is Windows');\n}\n```\n\n```js\nimport { isOSName, isBrowserName } from 'bugz';\nimport { allPass } from 'ramda';\n\nconst isWindows = isOSName('Windows');\nconst isFirefox = isBrowserName('Firefox');\nconst isWindowsFirefox = allPass([\n    isWindows,\n    isFirefox\n]);\n\nif (isWindowsFirefox(window.navigator.userAgent)) {\n    console.log('OS is Windows and Browser is Firefox');\n}\n```\n\n```js\nimport { isOSName, isBrowserName, isBrowserVersionLt } from 'bugz';\nimport { allPass } from 'ramda';\n\nconst isWindows = isOSName('Windows');\nconst isFirefox = isBrowserName('Firefox');\nconst isBrowserVersionLt3_7 = isBrowserVersionLt('3.7');\nconst isWindowsFirefoxLt3_7 = allPass([\n    isWindows,\n    isFirefox,\n    isBrowserVersionLt3_7\n]);\n\nif (isWindowsFirefoxLt3_7(window.navigator.userAgent)) {\n    console.log('OS is Windows and Browser is Firefox \u003c 3.7');\n}\n```\n\n## Examples\n\nFurther examples can be found [here](src/__tests__/composition.js).\n\n## API\n\n\u003e All functions are curried by default.\n\n**about** `(ua: string) → void`  \nLogs all information obtained from the user agent string to the console.\n\n**getBrowser** `(ua: string) → { name: string, version: string, majorVersion: number }`  \nReturns the browser from the user agent string.\n\n**getBrowserName** `(ua: string) → string`  \nReturns the browser name from the user agent string.\n\n**getBrowserVersion** `(ua: string) → string`  \nReturns the browser version from the user agent string.\n\n**getEngine** `(ua: string) → { name: string, version: string }`  \nReturns the engine from the user agent string.\n\n**getEngineName** `(ua: string) → string`  \nReturns the engine name from the user agent string.\n\n**getEngineVersion** `(ua: string) → string`  \nReturns the engine version from the user agent string.\n\n**getOS** `(ua: string) → { name: string, version: string }`  \nReturns the OS from the user agent string.\n\n**getOSName** `(ua: string) → string`  \nReturns the OS name from the user agent string.\n\n**getOSVersion** `(ua: string) → string`  \nReturns the OS version from the user agent string.\n\n**isAndroid** `(ua: string) → boolean`  \nReturns whether or not the operating system is Android.\n\n**isAndroidBrowser** `(ua: string) → boolean`  \nReturns whether or not the browser is Android Browser.\n\n**isBrowserName** `(name: string) → (ua: string) → boolean`  \nReturns whether or not the browser name is `name`.\n\n**isBrowserVersion** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the browser version is `version`.\n\n**isBrowserVersionGt** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the browser version is greater than `version`.\n\n**isBrowserVersionGte** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the browser version is greater than or equal to `version`.\n\n**isBrowserVersionLt** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the browser version is less than `version`.\n\n**isBrowserVersionLte** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the browser version is less than or equal to `version`.\n\n**isChrome** `(ua: string) → boolean`  \nReturns whether or not the browser is Chrome.\n\n**isEdge** `(ua: string) → boolean`  \nReturns whether or not the browser is Edge.\n\n**isEdgeHTML** `(ua: string) → boolean`  \nReturns whether or not the engine is EdgeHTML.\n\n**isEngineName** `(name: string) → (ua: string) → boolean`  \nReturns whether or not the engine name is `name`.\n\n**isEngineVersion** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the engine version is `version`.\n\n**isEngineVersionGt** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the engine version is greater than `version`.\n\n**isEngineVersionGte** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the engine version is greater than or equal to `version`.\n\n**isEngineVersionLt** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the engine version is less than `version`.\n\n**isEngineVersionLte** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the engine version is less than or equal to `version`.\n\n**isFirefox** `(ua: string) → boolean`  \nReturns whether or not the browser is Firefox.\n\n**isGecko** `(ua: string) → boolean`  \nReturns whether or not the engine is Gecko.\n\n**isIE** `(ua: string) → boolean`  \nReturns whether or not the browser is Internet Explorer.\n\n**isIEMobile** `(ua: string) → boolean`  \nReturns whether or not the browser is Internet Explorer Mobile.\n\n**isIOS** `(ua: string) → boolean`  \nReturns whether or not the operating system is iOS.\n\n**isMacOS** `(ua: string) → boolean`  \nReturns whether or not the operating system is Mac OS.\n\n**isMobileSafari** `(ua: string) → boolean`  \nReturns whether or not the browser is Mobile Safari.\n\n**isOSName** `(name: string) → (ua: string) → boolean`  \nReturns whether or not the OS name is `name`.\n\n**isOSVersion** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the OS version is `version`.\n\n**isOSVersionGt** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the OS version is greater than `version`.\n\n**isOSVersionGte** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the OS version is greater than or equal to `version`.\n\n**isOSVersionLt** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the OS version is less than `version`.\n\n**isOSVersionLte** `(version: string) → (ua: string) → boolean`  \nReturns whether or not the OS version is less than or equal to `version`.\n\n**isOpera** `(ua: string) → boolean`  \nReturns whether or not the browser is Opera.\n\n**isOperaMobile** `(ua: string) → boolean`  \nReturns whether or not the browser is Opera Mobile.\n\n**isPresto** `(ua: string) → boolean`  \nReturns whether or not the engine is Presto.\n\n**isSafari** `(ua: string) → boolean`  \nReturns whether or not the browser is Safari (desktop).\n\n**isTrident** `(ua: string) → boolean`  \nReturns whether or not the engine is Trident.\n\n**isWebKit** `(ua: string) → boolean`  \nReturns whether or not the engine is WebKit.\n\n**isWindows** `(ua: string) → boolean`  \nReturns whether or not the operating system is Windows.\n\n**isWindowsPhone** `(ua: string) → boolean`  \nReturns whether or not the operating system is Windows Phone.\n\n**parse** `(ua: string) → { ua: string, browser: { name: string, version: string, majorVersion: string }, engine: { name: string, version: string }, os: { name: string, version: string }`  \nReturns all information obtained from the user agent string.\n\n## Module Formats\n\n### ES2015\n\n```js\nimport { isBrowserName } from 'bugz';\n```\n\n\u003e 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](https://github.com/rollup/rollup/issues/1263). Therefore, a modular CommonJS build is additionally offered.\n\n### CommonJS\n\n```js\nconst bugz = require('bugz');\n```\n\n```js\n// Or modular for optimized builds\nconst isBrowserName = require('bugz/isBrowserName');\nconst isBrowserVersion = require('bugz/isBrowserVersion');\n```\n\n### UMD\n\n```html\n\u003cscript src=\"bugz.umd.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    const isBrowserName = Bugz.isBrowserName;\n\u003c/script\u003e\n```\n\n```js\nrequire(['bugz'], bugz =\u003e {});\n```\n\n## License\nMIT\n\n## Thank you\n\n[![BrowserStack](browserstack.png)](https://www.browserstack.com/ \"BrowserStack\")\n\n[BrowserStack](https://www.browserstack.com/ \"BrowserStack\") for providing a free subscription to support cross browser testing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardscarrott%2Fbugz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichardscarrott%2Fbugz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardscarrott%2Fbugz/lists"}