1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Merge branch 'release/2.5.0' into production

This commit is contained in:
Denis Demchenko 2019-07-16 22:28:15 +03:00
commit 5fc17b73a0
28 changed files with 4157 additions and 6601 deletions

2
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,2 @@
github: lancedikson
open_collective: lancedikson

View File

@ -1,7 +1,7 @@
language: node_js language: node_js
after_success: npm run coverage after_success: npm run coverage
node_js: node_js:
- "8.4.0" - "12"
script: script:
- npm run lint - npm run lint
- npm run build - npm run build

View File

@ -1,5 +1,11 @@
# Bowser Changelog # Bowser Changelog
### 2.5.0 (July 16, 2019)
- [ADD] Add constant output so that users can quickly get all types (#325)
- [FIX] Add support for Roku OS (#332)
- [FIX] Update devDependencies
- [FIX] Fix docs, README and added funding information
### 2.4.0 (May 3, 2019) ### 2.4.0 (May 3, 2019)
- [FIX] Update regexp for generic browsers (#310) - [FIX] Update regexp for generic browsers (#310)
- [FIX] Fix issues with module.exports (#318) - [FIX] Fix issues with module.exports (#318)

View File

@ -1,7 +1,12 @@
## Bowser ## Bowser
A browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms. A small, fast and reach-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.
[![Build Status](https://travis-ci.org/lancedikson/bowser.svg?branch=master)](https://travis-ci.org/lancedikson/bowser/) [![Greenkeeper badge](https://badges.greenkeeper.io/lancedikson/bowser.svg)](https://greenkeeper.io/)[![Coverage Status](https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master)](https://coveralls.io/github/lancedikson/bowser?branch=master) Don't hesitate to support the project on Github or [OpenCollective](https://opencollective.com/bowser) if you like it ❤️ Also, contributors are always welcome!
[![Build Status](https://travis-ci.org/lancedikson/bowser.svg?branch=master)](https://travis-ci.org/lancedikson/bowser/) [![Greenkeeper badge](https://badges.greenkeeper.io/lancedikson/bowser.svg)](https://greenkeeper.io/) [![Coverage Status](https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master)](https://coveralls.io/github/lancedikson/bowser?branch=master)
# Contents # Contents
- [Overview](#overview) - [Overview](#overview)

View File

@ -13,6 +13,7 @@
<![endif]--> <![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
@ -24,9 +25,9 @@
<label for="nav-trigger" class="overlay"></label> <label for="nav-trigger" class="overlay"></label>
<nav> <nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav> </nav>
<div id="main"> <div id="main">
@ -47,105 +48,17 @@
Bowser Bowser
</h2> </h2>
<div class="class-description"><p>Bowser class. <div class="class-description"><p>Bowser is a static object, that provides an API to the Parsers</p></div>
Keep it simple as much as it can be.
It's supposed to work with collections of <a href="Parser.html">Parser</a> instances
rather then solve one-instance problems.
All the one-instance stuff is located in Parser class.</p></div>
</header> </header>
<article> <article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Bowser"><span class="type-signature"></span>new Bowser<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line16">line 16</a>
</li></ul></dd>
</dl>
</div>
@ -177,7 +90,7 @@ All the one-instance stuff is located in Parser class.</p></div>
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line29">line 29</a> <a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line51">line 51</a>
</li></ul></dd> </li></ul></dd>
@ -217,7 +130,7 @@ All the one-instance stuff is located in Parser class.</p></div>
<div class="description"> <div class="description">
<p>Creates a module:parser:Parser instance</p> <p>Creates a <a href="Parser.html">Parser</a> instance</p>
</div> </div>
@ -332,7 +245,8 @@ const result = parser.getResult();</code></pre>
</td> </td>
<td class="description last"><p>same as skipParsing for <a href="Parser.html">Parser</a></p></td> <td class="description last"><p>Will make the Parser postpone parsing until you ask it
explicitly. Same as <code>skipParsing</code> for <a href="Parser.html">Parser</a>.</p></td>
</tr> </tr>
@ -350,6 +264,8 @@ const result = parser.getResult();</code></pre>
<h5>Throws:</h5> <h5>Throws:</h5>
@ -368,7 +284,7 @@ const result = parser.getResult();</code></pre>
</dt> </dt>
<dd> <dd>
<span class="param-type">Error</span> <span class="param-type"><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></span>
</dd> </dd>
@ -406,6 +322,7 @@ const result = parser.getResult();</code></pre>
<h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<span class="signature">(UA)</span><span class="type-signature"> &rarr; {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4> <h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<span class="signature">(UA)</span><span class="type-signature"> &rarr; {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4>
@ -418,7 +335,7 @@ const result = parser.getResult();</code></pre>
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line45">line 45</a> <a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line67">line 67</a>
</li></ul></dd> </li></ul></dd>
@ -532,6 +449,8 @@ const result = parser.getResult();</code></pre>
<h5>Returns:</h5> <h5>Returns:</h5>
@ -558,6 +477,7 @@ const result = parser.getResult();</code></pre>
</article> </article>
</section> </section>
@ -572,12 +492,14 @@ const result = parser.getResult();</code></pre>
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:50:23 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer> </footer>
<script>prettyPrint();</script> <script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script> <script src="scripts/linenumber.js"></script>
</body> </body>
</html> </html>

View File

@ -0,0 +1,234 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>BowserUAIsNotAStringError - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">BowserUAIsNotAStringError</h1>
<section>
<header>
<h2>
BowserUAIsNotAStringError
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="BowserUAIsNotAStringError"><span class="type-signature"></span>new BowserUAIsNotAStringError<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line20">line 20</a>
</li></ul></dd>
</dl>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -13,6 +13,7 @@
<![endif]--> <![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
@ -24,9 +25,9 @@
<label for="nav-trigger" class="overlay"></label> <label for="nav-trigger" class="overlay"></label>
<nav> <nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav> </nav>
<div id="main"> <div id="main">
@ -74,7 +75,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line10">line 10</a> <a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line23">line 23</a>
</li></ul></dd> </li></ul></dd>
@ -248,6 +249,9 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
</div> </div>
@ -264,6 +268,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h3 class="subsection-title">Methods</h3> <h3 class="subsection-title">Methods</h3>
@ -345,6 +351,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -373,6 +381,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getBrowserName"><span class="type-signature"></span>getBrowserName<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="getBrowserName"><span class="type-signature"></span>getBrowserName<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
@ -447,6 +456,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -479,6 +490,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getBrowserVersion"><span class="type-signature"></span>getBrowserVersion<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="getBrowserVersion"><span class="type-signature"></span>getBrowserVersion<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
@ -553,6 +565,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -585,6 +599,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getEngine"><span class="type-signature"></span>getEngine<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> <h4 class="name" id="getEngine"><span class="type-signature"></span>getEngine<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -659,6 +674,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -687,6 +704,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getEngineName"><span class="type-signature"></span>getEngineName<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="getEngineName"><span class="type-signature"></span>getEngineName<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
@ -761,6 +779,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -793,6 +813,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getOS"><span class="type-signature"></span>getOS<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> <h4 class="name" id="getOS"><span class="type-signature"></span>getOS<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -879,6 +900,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h5>Returns:</h5> <h5>Returns:</h5>
@ -904,6 +927,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getOSName"><span class="type-signature"></span>getOSName<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="getOSName"><span class="type-signature"></span>getOSName<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></h4>
@ -1042,6 +1066,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h5>Returns:</h5> <h5>Returns:</h5>
@ -1071,6 +1097,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getOSVersion"><span class="type-signature"></span>getOSVersion<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="getOSVersion"><span class="type-signature"></span>getOSVersion<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
@ -1145,6 +1172,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -1177,6 +1206,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getPlatform"><span class="type-signature"></span>getPlatform<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> <h4 class="name" id="getPlatform"><span class="type-signature"></span>getPlatform<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -1251,6 +1281,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -1279,6 +1311,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getPlatformType"><span class="type-signature"></span>getPlatformType<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <h4 class="name" id="getPlatformType"><span class="type-signature"></span>getPlatformType<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4>
@ -1425,6 +1458,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h5>Returns:</h5> <h5>Returns:</h5>
@ -1450,6 +1485,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getResult"><span class="type-signature"></span>getResult<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4> <h4 class="name" id="getResult"><span class="type-signature"></span>getResult<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4>
@ -1524,6 +1560,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -1552,6 +1590,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="getUA"><span class="type-signature"></span>getUA<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="getUA"><span class="type-signature"></span>getUA<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
@ -1626,6 +1665,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
@ -1658,6 +1699,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<h4 class="name" id="is"><span class="type-signature"></span>is<span class="signature">(anything)</span><span class="type-signature"> &rarr; {Boolean}</span></h4> <h4 class="name" id="is"><span class="type-signature"></span>is<span class="signature">(anything)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
@ -1670,7 +1712,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line477">line 477</a> <a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line476">line 476</a>
</li></ul></dd> </li></ul></dd>
@ -1785,6 +1827,8 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h5>Returns:</h5> <h5>Returns:</h5>
@ -1810,6 +1854,7 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h4 class="name" id="isBrowser"><span class="type-signature"></span>isBrowser<span class="signature">(browserName, includingAlias<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <h4 class="name" id="isBrowser"><span class="type-signature"></span>isBrowser<span class="signature">(browserName, includingAlias<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
@ -1981,6 +2026,8 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h5>Returns:</h5> <h5>Returns:</h5>
@ -2006,6 +2053,7 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h4 class="name" id="parse"><span class="type-signature"></span>parse<span class="signature">()</span><span class="type-signature"></span></h4> <h4 class="name" id="parse"><span class="type-signature"></span>parse<span class="signature">()</span><span class="type-signature"></span></h4>
@ -2086,6 +2134,9 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
@ -2164,6 +2215,8 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
@ -2192,6 +2245,7 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h4 class="name" id="parseEngine"><span class="type-signature"></span>parseEngine<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> <h4 class="name" id="parseEngine"><span class="type-signature"></span>parseEngine<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -2266,6 +2320,8 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
@ -2294,6 +2350,7 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h4 class="name" id="parseOS"><span class="type-signature"></span>parseOS<span class="signature">()</span><span class="type-signature"> &rarr; {*|Object}</span></h4> <h4 class="name" id="parseOS"><span class="type-signature"></span>parseOS<span class="signature">()</span><span class="type-signature"> &rarr; {*|Object}</span></h4>
@ -2368,6 +2425,8 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
@ -2399,6 +2458,7 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h4 class="name" id="parsePlatform"><span class="type-signature"></span>parsePlatform<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4> <h4 class="name" id="parsePlatform"><span class="type-signature"></span>parsePlatform<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -2473,6 +2533,8 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
@ -2501,6 +2563,7 @@ the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</
<h4 class="name" id="satisfies"><span class="type-signature"></span>satisfies<span class="signature">(checkTree)</span><span class="type-signature"> &rarr; {Boolean|undefined}</span></h4> <h4 class="name" id="satisfies"><span class="type-signature"></span>satisfies<span class="signature">(checkTree)</span><span class="type-signature"> &rarr; {Boolean|undefined}</span></h4>
@ -2639,6 +2702,8 @@ and should have browsers specs on the bottom-laying layer</p></td>
<h5>Returns:</h5> <h5>Returns:</h5>
@ -2672,6 +2737,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<h4 class="name" id="some"><span class="type-signature"></span>some<span class="signature">(anythings)</span><span class="type-signature"> &rarr; {Boolean}</span></h4> <h4 class="name" id="some"><span class="type-signature"></span>some<span class="signature">(anythings)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
@ -2684,7 +2750,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line486">line 486</a> <a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line485">line 485</a>
</li></ul></dd> </li></ul></dd>
@ -2798,6 +2864,8 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<h5>Returns:</h5> <h5>Returns:</h5>
@ -2823,6 +2891,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<h4 class="name" id="test"><span class="type-signature"></span>test<span class="signature">(regex)</span><span class="type-signature"> &rarr; {Boolean}</span></h4> <h4 class="name" id="test"><span class="type-signature"></span>test<span class="signature">(regex)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
@ -2949,6 +3018,8 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<h5>Returns:</h5> <h5>Returns:</h5>
@ -2975,6 +3046,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
</article> </article>
</section> </section>
@ -2989,12 +3061,14 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:50:23 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer> </footer>
<script>prettyPrint();</script> <script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script> <script src="scripts/linenumber.js"></script>
</body> </body>
</html> </html>

View File

@ -13,6 +13,7 @@
<![endif]--> <![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
@ -24,9 +25,9 @@
<label for="nav-trigger" class="overlay"></label> <label for="nav-trigger" class="overlay"></label>
<nav> <nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav> </nav>
<div id="main"> <div id="main">
@ -45,9 +46,26 @@
* Bowser - a browser detector * Bowser - a browser detector
* https://github.com/lancedikson/bowser * https://github.com/lancedikson/bowser
* MIT License | (c) Dustin Diaz 2012-2015 * MIT License | (c) Dustin Diaz 2012-2015
* MIT License | (c) Denis Demchenko 2015-2017 * MIT License | (c) Denis Demchenko 2015-2019
*/ */
import Parser from './parser.js'; import Parser from './parser.js';
import {
BROWSER_MAP,
ENGINE_MAP,
OS_MAP,
PLATFORMS_MAP,
} from './constants.js';
/**
* @class
* @property name
*/
class BowserUAIsNotAStringError extends Error {
constructor(message) {
super(message);
this.name = 'BowserUAIsNotAStringError';
}
}
/** /**
* Bowser class. * Bowser class.
@ -55,15 +73,20 @@ import Parser from './parser.js';
* It's supposed to work with collections of {@link Parser} instances * It's supposed to work with collections of {@link Parser} instances
* rather then solve one-instance problems. * rather then solve one-instance problems.
* All the one-instance stuff is located in Parser class. * All the one-instance stuff is located in Parser class.
*
* @class
* @classdesc Bowser is a static object, that provides an API to the Parsers
* @hideconstructor
*/ */
class Bowser { class Bowser {
/** /**
* Creates a {@link module:parser:Parser} instance * Creates a {@link Parser} instance
* *
* @param {String} UA UserAgent string * @param {String} UA UserAgent string
* @param {Boolean} [skipParsing=false] same as skipParsing for {@link Parser} * @param {Boolean} [skipParsing=false] Will make the Parser postpone parsing until you ask it
* explicitly. Same as `skipParsing` for {@link Parser}.
* @returns {Parser} * @returns {Parser}
* @throws {Error} when UA is not a String * @throws {BowserUAIsNotAStringError} when UA is not a String
* *
* @example * @example
* const parser = Bowser.getParser(window.navigator.userAgent); * const parser = Bowser.getParser(window.navigator.userAgent);
@ -71,7 +94,7 @@ class Bowser {
*/ */
static getParser(UA, skipParsing = false) { static getParser(UA, skipParsing = false) {
if (typeof UA !== 'string') { if (typeof UA !== 'string') {
throw new Error('UserAgent should be a string'); throw new BowserUAIsNotAStringError('UserAgent should be a string');
} }
return new Parser(UA, skipParsing); return new Parser(UA, skipParsing);
} }
@ -88,6 +111,22 @@ class Bowser {
static parse(UA) { static parse(UA) {
return (new Parser(UA)).getResult(); return (new Parser(UA)).getResult();
} }
static get BROWSER_MAP() {
return BROWSER_MAP;
}
static get ENGINE_MAP() {
return ENGINE_MAP;
}
static get OS_MAP() {
return OS_MAP;
}
static get PLATFORMS_MAP() {
return PLATFORMS_MAP;
}
} }
export default Bowser; export default Bowser;
@ -105,12 +144,14 @@ export default Bowser;
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:50:23 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer> </footer>
<script>prettyPrint();</script> <script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script> <script src="scripts/linenumber.js"></script>
</body> </body>
</html> </html>

View File

@ -13,6 +13,7 @@
<![endif]--> <![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
@ -24,9 +25,9 @@
<label for="nav-trigger" class="overlay"></label> <label for="nav-trigger" class="overlay"></label>
<nav> <nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav> </nav>
<div id="main"> <div id="main">
@ -114,6 +115,8 @@
<h3 class="subsection-title">Methods</h3> <h3 class="subsection-title">Methods</h3>
@ -174,21 +177,21 @@
<div class="description"> <div class="description">
<p>Get Android version name <p>Get Android version name
1.5 - Cupcake 1.5 - Cupcake
1.6 - Donut 1.6 - Donut
2.0 - Eclair 2.0 - Eclair
2.1 - Eclair 2.1 - Eclair
2.2 - Froyo 2.2 - Froyo
2.x - Gingerbread 2.x - Gingerbread
3.x - Honeycomb 3.x - Honeycomb
4.0 - Ice Cream Sandwich 4.0 - Ice Cream Sandwich
4.1 - Jelly Bean 4.1 - Jelly Bean
4.4 - KitKat 4.4 - KitKat
5.x - Lollipop 5.x - Lollipop
6.x - Marshmallow 6.x - Marshmallow
7.x - Nougat 7.x - Nougat
8.x - Oreo 8.x - Oreo
9.x - ?</p> 9.x - ?</p>
</div> </div>
@ -267,6 +270,8 @@
<h5>Returns:</h5> <h5>Returns:</h5>
@ -296,6 +301,7 @@
<h4 class="name" id="getBrowserAlias"><span class="type-signature"></span>getBrowserAlias<span class="signature">(browserName)</span><span class="type-signature"> &rarr; {string}</span></h4> <h4 class="name" id="getBrowserAlias"><span class="type-signature"></span>getBrowserAlias<span class="signature">(browserName)</span><span class="type-signature"> &rarr; {string}</span></h4>
@ -427,6 +433,8 @@
<h5>Returns:</h5> <h5>Returns:</h5>
@ -452,6 +460,166 @@
<h4 class="name" id="getBrowserTypeByAlias"><span class="type-signature"></span>getBrowserTypeByAlias<span class="signature">(browserName)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line215">line 215</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get short version/alias for a browser name</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>getBrowserAlias('edge') // Microsoft Edge</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>browserName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="getFirstMatch"><span class="type-signature"></span>getFirstMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> &rarr; {Array|Object|*|boolean|string}</span></h4> <h4 class="name" id="getFirstMatch"><span class="type-signature"></span>getFirstMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> &rarr; {Array|Object|*|boolean|string}</span></h4>
@ -601,6 +769,8 @@
<h5>Returns:</h5> <h5>Returns:</h5>
@ -638,6 +808,7 @@
<h4 class="name" id="getSecondMatch"><span class="type-signature"></span>getSecondMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> &rarr; {Array|Object|*|boolean|string}</span></h4> <h4 class="name" id="getSecondMatch"><span class="type-signature"></span>getSecondMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> &rarr; {Array|Object|*|boolean|string}</span></h4>
@ -782,6 +953,8 @@
<h5>Returns:</h5> <h5>Returns:</h5>
@ -819,6 +992,7 @@
<h4 class="name" id="getVersionPrecision"><span class="type-signature"></span>getVersionPrecision<span class="signature">(version)</span><span class="type-signature"> &rarr; {number}</span></h4> <h4 class="name" id="getVersionPrecision"><span class="type-signature"></span>getVersionPrecision<span class="signature">(version)</span><span class="type-signature"> &rarr; {number}</span></h4>
@ -950,6 +1124,8 @@
<h5>Returns:</h5> <h5>Returns:</h5>
@ -975,6 +1151,7 @@
<h4 class="name" id="map"><span class="type-signature"></span>map<span class="signature">(arr, iterator)</span><span class="type-signature"> &rarr; {Array}</span></h4> <h4 class="name" id="map"><span class="type-signature"></span>map<span class="signature">(arr, iterator)</span><span class="type-signature"> &rarr; {Array}</span></h4>
@ -1124,6 +1301,8 @@
<h5>Returns:</h5> <h5>Returns:</h5>
@ -1149,6 +1328,7 @@
<h4 class="name" id="matchAndReturnConst"><span class="type-signature"></span>matchAndReturnConst<span class="signature">(regexp, ua, _const)</span><span class="type-signature"> &rarr; {*}</span></h4> <h4 class="name" id="matchAndReturnConst"><span class="type-signature"></span>matchAndReturnConst<span class="signature">(regexp, ua, _const)</span><span class="type-signature"> &rarr; {*}</span></h4>
@ -1321,6 +1501,8 @@
<h5>Returns:</h5> <h5>Returns:</h5>
@ -1345,6 +1527,7 @@
<h3 class="subsection-title">Type Definitions</h3> <h3 class="subsection-title">Type Definitions</h3>
@ -1995,12 +2178,14 @@ like <code>&quot;iPhone&quot;</code> or <code>&quot;Kindle Fire HD 7&quot;</code
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:50:23 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer> </footer>
<script>prettyPrint();</script> <script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script> <script src="scripts/linenumber.js"></script>
</body> </body>
</html> </html>

View File

@ -13,6 +13,7 @@
<![endif]--> <![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
@ -24,9 +25,9 @@
<label for="nav-trigger" class="overlay"></label> <label for="nav-trigger" class="overlay"></label>
<nav> <nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav> </nav>
<div id="main"> <div id="main">
@ -39,6 +40,12 @@
<section class="package">
<h3> </h3>
</section>
@ -50,32 +57,48 @@
<section class="readme"> <section class="readme">
<article><h2>Bowser</h2><p>A browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.</p> <article><h2>Bowser</h2>
<p><a href="https://travis-ci.org/lancedikson/bowser/"><img src="https://travis-ci.org/lancedikson/bowser.svg?branch=master" alt="Build Status"></a> <a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/lancedikson/bowser.svg" alt="Greenkeeper badge"></a><a href="https://coveralls.io/github/lancedikson/bowser?branch=master"><img src="https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master" alt="Coverage Status"></a></p> <p>A small, fast and reach-API browser/platform/engine detector for both browser and node.</p>
<h1>Contents</h1><ul> <ul>
<li><strong>Small.</strong> Use plain ES5-version which is ~4.8kB gzipped.</li>
<li><strong>Optimized.</strong> Use only those parsers you need — it doesn't do useless work.</li>
<li><strong>Multi-platform.</strong> It's browser- and node-ready, so you can use it in any environment.</li>
</ul>
<p>Don't hesitate to support the project on Github or <a href="https://opencollective.com/bowser">OpenCollective</a> if you like it ❤️ Also, contributors are always welcome!</p>
<p><a href="https://travis-ci.org/lancedikson/bowser/"><img src="https://travis-ci.org/lancedikson/bowser.svg?branch=master" alt="Build Status"></a> <a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/lancedikson/bowser.svg" alt="Greenkeeper badge"></a> <a href="https://coveralls.io/github/lancedikson/bowser?branch=master"><img src="https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master" alt="Coverage Status"></a></p>
<h1>Contents</h1>
<ul>
<li><a href="#overview">Overview</a></li> <li><a href="#overview">Overview</a></li>
<li><a href="#use-cases">Use cases</a></li> <li><a href="#use-cases">Use cases</a></li>
<li><a href="#advanced-usage">Advanced usage</a></li> <li><a href="#advanced-usage">Advanced usage</a></li>
<li><a href="#contributing">How can I help?</a></li> <li><a href="#contributing">How can I help?</a></li>
</ul> </ul>
<h1>Overview</h1><p>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.</p> <h1>Overview</h1>
<h3>⚠️ Version 2.0 breaking changes ⚠️</h3><p>Version 2.0 has drastically changed the API. All available methods are on the <a href="https://lancedikson.github.io/bowser/docs">docs page</a>.</p> <p>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.</p>
<h3>⚠️ Version 2.0 breaking changes ⚠️</h3>
<p>Version 2.0 has drastically changed the API. All available methods are on the <a href="https://lancedikson.github.io/bowser/docs">docs page</a>.</p>
<p><em>For legacy code, check out the <a href="https://github.com/lancedikson/bowser/tree/v1.x">1.x</a> branch and install it through <code>npm install bowser@1.9.4</code>.</em></p> <p><em>For legacy code, check out the <a href="https://github.com/lancedikson/bowser/tree/v1.x">1.x</a> branch and install it through <code>npm install bowser@1.9.4</code>.</em></p>
<h1>Use cases</h1><p>First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.</p> <h1>Use cases</h1>
<p>First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.</p>
<pre class="prettyprint source lang-javascript"><code>const Bowser = require(&quot;bowser&quot;); // CommonJS <pre class="prettyprint source lang-javascript"><code>const Bowser = require(&quot;bowser&quot;); // CommonJS
import * as Bowser from &quot;bowser&quot;; // TypeScript import * as Bowser from &quot;bowser&quot;; // TypeScript
import Bowser from &quot;bowser&quot;; // ES6 (and TypeScript with --esModuleInterop enabled)</code></pre><p>By default, the exported version is the <em>ES5 transpiled version</em>, which <strong>do not</strong> include any polyfills.</p> import Bowser from &quot;bowser&quot;; // ES6 (and TypeScript with --esModuleInterop enabled)
</code></pre>
<p>By default, the exported version is the <em>ES5 transpiled version</em>, which <strong>do not</strong> include any polyfills.</p>
<p>In case you don't use your own <code>babel-polyfill</code> you may need to have pre-built bundle with all needed polyfills. <p>In case you don't use your own <code>babel-polyfill</code> you may need to have pre-built bundle with all needed polyfills.
So, for you it's suitable to require bowser like this: <code>require('bowser/bundled')</code>. So, for you it's suitable to require bowser like this: <code>require('bowser/bundled')</code>.
As the result, you get a ES5 version of bowser with <code>babel-polyfill</code> bundled together.</p> As the result, you get a ES5 version of bowser with <code>babel-polyfill</code> bundled together.</p>
<p>You may need to use the source files, so they will be available in the package as well.</p> <p>You may need to use the source files, so they will be available in the package as well.</p>
<h2>Browser props detection</h2><p>Often we need to pick users' browser properties such as the name, the version, the rendering engine and so on. Here is an example how to do it with Bowser:</p> <h2>Browser props detection</h2>
<p>Often we need to pick users' browser properties such as the name, the version, the rendering engine and so on. Here is an example how to do it with Bowser:</p>
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent); <pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
console.log(`The current browser name is &quot;${browser.getBrowserName()}&quot;`); console.log(`The current browser name is &quot;${browser.getBrowserName()}&quot;`);
// The current browser name is &quot;Internet Explorer&quot;</code></pre><p>or</p> // The current browser name is &quot;Internet Explorer&quot;
</code></pre>
<p>or</p>
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent); <pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
console.log(browser.getBrowser()); console.log(browser.getBrowser());
@ -83,7 +106,9 @@ console.log(browser.getBrowser());
{ {
name: &quot;Internet Explorer&quot; name: &quot;Internet Explorer&quot;
version: &quot;11.0&quot; version: &quot;11.0&quot;
}</code></pre><p>or</p> }
</code></pre>
<p>or</p>
<pre class="prettyprint source lang-javascript"><code>console.log(Bowser.parse(window.navigator.userAgent)); <pre class="prettyprint source lang-javascript"><code>console.log(Bowser.parse(window.navigator.userAgent));
// outputs // outputs
@ -104,7 +129,10 @@ console.log(browser.getBrowser());
name: &quot;Trident&quot; name: &quot;Trident&quot;
version: &quot;7.0&quot; version: &quot;7.0&quot;
} }
}</code></pre><h2>Filtering browsers</h2><p>You could want to filter some particular browsers to provide any special support for them or make any workarounds. }
</code></pre>
<h2>Filtering browsers</h2>
<p>You could want to filter some particular browsers to provide any special support for them or make any workarounds.
It could look like this:</p> It could look like this:</p>
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent); <pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
const isValidBrowser = browser.satisfies({ const isValidBrowser = browser.satisfies({
@ -133,16 +161,21 @@ const isValidBrowser = browser.satisfies({
// and loose-equality operator // and loose-equality operator
chrome: &quot;~20&quot; // will match any 20.* sub-version chrome: &quot;~20&quot; // will match any 20.* sub-version
chrome: &quot;~20.1&quot; // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1) chrome: &quot;~20.1&quot; // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
});</code></pre><p>Settings for any particular OS or platform has more priority and redefines settings of standalone browsers. });
</code></pre>
<p>Settings for any particular OS or platform has more priority and redefines settings of standalone browsers.
Thus, you can define OS or platform specific rules and they will have more priority in the end.</p> Thus, you can define OS or platform specific rules and they will have more priority in the end.</p>
<p>More of API and possibilities you will find in the <code>docs</code> folder.</p> <p>More of API and possibilities you will find in the <code>docs</code> folder.</p>
<h3>Browser names for <code>.satisfies()</code></h3><p>By default you are supposed to use the full browser name for <code>.satisfies</code>. <h3>Browser names for <code>.satisfies()</code></h3>
<p>By default you are supposed to use the full browser name for <code>.satisfies</code>.
But, there's a short way to define a browser using short aliases. The full But, there's a short way to define a browser using short aliases. The full
list of aliases can be found in <a href="src/constants.js">the file</a>.</p> list of aliases can be found in <a href="src/constants.js">the file</a>.</p>
<h2>Similar Projects</h2><ul> <h2>Similar Projects</h2>
<ul>
<li><a href="https://github.com/BigBadBleuCheese/Kong">Kong</a> - A C# port of Bowser.</li> <li><a href="https://github.com/BigBadBleuCheese/Kong">Kong</a> - A C# port of Bowser.</li>
</ul> </ul>
<h2>License</h2><p>Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.</p></article> <h2>License</h2>
<p>Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.</p></article>
</section> </section>
@ -157,12 +190,14 @@ list of aliases can be found in <a href="src/constants.js">the file</a>.</p>
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:50:23 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer> </footer>
<script>prettyPrint();</script> <script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script> <script src="scripts/linenumber.js"></script>
</body> </body>
</html> </html>

View File

@ -13,6 +13,7 @@
<![endif]--> <![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
@ -24,9 +25,9 @@
<label for="nav-trigger" class="overlay"></label> <label for="nav-trigger" class="overlay"></label>
<nav> <nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav> </nav>
<div id="main"> <div id="main">
@ -452,15 +453,14 @@ class Parser {
* @returns {boolean} * @returns {boolean}
*/ */
isBrowser(browserName, includingAlias = false) { isBrowser(browserName, includingAlias = false) {
const defaultBrowserName = this.getBrowserName(); const defaultBrowserName = this.getBrowserName().toLowerCase();
const possibleNames = [defaultBrowserName.toLowerCase()]; let browserNameLower = browserName.toLowerCase();
const alias = Utils.getBrowserAlias(defaultBrowserName); const alias = Utils.getBrowserTypeByAlias(browserNameLower);
if (includingAlias &amp;&amp; typeof alias !== 'undefined') { if (includingAlias &amp;&amp; alias) {
possibleNames.push(alias.toLowerCase()); browserNameLower = alias.toLowerCase();
} }
return browserNameLower === defaultBrowserName;
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
} }
compareVersion(version) { compareVersion(version) {
@ -546,12 +546,14 @@ export default Parser;
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:50:23 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer> </footer>
<script>prettyPrint();</script> <script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script> <script src="scripts/linenumber.js"></script>
</body> </body>
</html> </html>

View File

@ -1,11 +1,20 @@
function hideAllButCurrent(){ function hideAllButCurrent(){
//by default all submenut items are hidden //by default all submenut items are hidden
$("nav > ul > li > ul li").hide(); //but we need to rehide them for search
document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
parent.style.display = "none";
});
//only current page (if it exists) should be opened //only current page (if it exists) should be opened
var file = window.location.pathname.split("/").pop(); var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
$("nav > ul > li > a[href^='"+file+"']").parent().find("> ul li").show(); document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
var href = parent.attributes.href.value.replace(/\.html/, '');
if (file === href) {
parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
elem.style.display = "block";
});
}
});
} }
$( document ).ready(function() {
hideAllButCurrent(); hideAllButCurrent();
});

12
docs/scripts/nav.js Normal file
View File

@ -0,0 +1,12 @@
function scrollToNavItem() {
var path = window.location.href.split('/').pop().replace(/\.html/, '');
document.querySelectorAll('nav a').forEach(function(link) {
var href = link.attributes.href.value.replace(/\.html/, '');
if (path === href) {
link.scrollIntoView({block: 'center'});
return;
}
})
}
scrollToNavItem();

4
docs/scripts/polyfill.js Normal file
View File

@ -0,0 +1,4 @@
//IE Fix, src: https://www.reddit.com/r/programminghorror/comments/6abmcr/nodelist_lacks_foreach_in_internet_explorer/
if (typeof(NodeList.prototype.forEach)!==typeof(alert)){
NodeList.prototype.forEach=Array.prototype.forEach;
}

View File

@ -1,42 +1,83 @@
$( document ).ready(function() {
jQuery.expr[':'].Contains = function(a,i,m){
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
};
//on search
$("#nav-search").on("keyup", function(event) {
var search = $(this).val();
if (!search) {
//no search, show all results
$("nav > ul > li").show();
if(typeof hideAllButCurrent === "function"){ var searchAttr = 'data-search-mode';
//let's do what ever collapse wants to do function contains(a,m){
hideAllButCurrent(); return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1;
} };
else{
//menu by default should be opened //on search
$("nav > ul > li > ul li").show(); document.getElementById("nav-search").addEventListener("keyup", function(event) {
} var search = this.value.toUpperCase();
}
else{ if (!search) {
//we are searching //no search, show all results
//show all parents document.documentElement.removeAttribute(searchAttr);
$("nav > ul > li").show();
//hide all results document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) {
$("nav > ul > li > ul li").hide(); elem.style.display = "block";
//show results matching filter });
$("nav > ul > li > ul").find("a:Contains("+search+")").parent().show();
//hide parents without children if (typeof hideAllButCurrent === "function"){
$("nav > ul > li").each(function(){ //let's do what ever collapse wants to do
if($(this).find("a:Contains("+search+")").length == 0 && $(this).children("ul").length === 0){ hideAllButCurrent();
//has no child at all and does not contain text } else {
$(this).hide(); //menu by default should be opened
} document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
else if($(this).find("a:Contains("+search+")").length == 0 && $(this).find("ul").children(':visible').length == 0){ elem.style.display = "block";
//has no visible child and does not contain text
$(this).hide();
}
}); });
} }
}); } else {
//we are searching
document.documentElement.setAttribute(searchAttr, '');
//show all parents
document.querySelectorAll("nav > ul > li").forEach(function(elem) {
elem.style.display = "block";
});
//hide all results
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
elem.style.display = "none";
});
//show results matching filter
document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) {
if (!contains(elem.parentNode, search)) {
return;
}
elem.parentNode.style.display = "block";
});
//hide parents without children
document.querySelectorAll("nav > ul > li").forEach(function(parent) {
var countSearchA = 0;
parent.querySelectorAll("a").forEach(function(elem) {
if (contains(elem, search)) {
countSearchA++;
}
});
var countUl = 0;
var countUlVisible = 0;
parent.querySelectorAll("ul").forEach(function(ulP) {
// count all elements that match the search
if (contains(ulP, search)) {
countUl++;
}
// count all visible elements
var children = ulP.children
for (i=0; i<children.length; i++) {
var elem = children[i];
if (elem.style.display != "none") {
countUlVisible++;
}
}
});
if (countSearchA == 0 && countUl === 0){
//has no child at all and does not contain text
parent.style.display = "none";
} else if(countSearchA == 0 && countUlVisible == 0){
//has no visible child and does not contain text
parent.style.display = "none";
}
});
}
}); });

View File

@ -16,7 +16,6 @@ body {
padding: 0 20px; padding: 0 20px;
font-family: 'Helvetica Neue', Helvetica, sans-serif; font-family: 'Helvetica Neue', Helvetica, sans-serif;
font-size: 16px; font-size: 16px;
line-height: 160%;
} }
img { img {
@ -41,8 +40,13 @@ article a:hover, article a:active {
border-bottom-color: #222; border-bottom-color: #222;
} }
article .description a {
word-break: break-word;
}
p, ul, ol, blockquote { p, ul, ol, blockquote {
margin-bottom: 1em; margin-bottom: 1em;
line-height: 160%;
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
@ -65,6 +69,7 @@ h1.page-title {
font-size: 48px; font-size: 48px;
margin: 1em 30px; margin: 1em 30px;
line-height: 100%; line-height: 100%;
word-wrap: break-word;
} }
h2 { h2 {
@ -179,6 +184,10 @@ nav #nav-search{
margin-top: 20px; margin-top: 20px;
} }
nav.wrap a{
word-wrap: break-word;
}
nav h3 { nav h3 {
margin-top: 12px; margin-top: 12px;
font-size: 13px; font-size: 13px;
@ -234,13 +243,12 @@ nav ul ul a:active {
} }
nav h2 { nav h2 {
font-size: 12px; font-size: 13px;
margin: 0; margin: 10px 0 0 0;
padding: 0; padding: 0;
} }
nav > h2 > a { nav > h2 > a {
display: block;
margin: 10px 0 -10px; margin: 10px 0 -10px;
color: #606 !important; color: #606 !important;
} }
@ -596,6 +604,15 @@ span.param-type, .params td .param-type, .param-type dd {
z-index: 1; z-index: 1;
} }
/* nav level */
.level-hide {
display: none;
}
html[data-search-mode] .level-hide {
display: block;
}
@media only screen and (min-width: 320px) and (max-width: 680px) { @media only screen and (min-width: 320px) and (max-width: 680px) {
body { body {
overflow-x: hidden; overflow-x: hidden;

View File

@ -13,6 +13,7 @@
<![endif]--> <![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
@ -24,9 +25,9 @@
<label for="nav-trigger" class="overlay"></label> <label for="nav-trigger" class="overlay"></label>
<nav> <nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
</nav> </nav>
<div id="main"> <div id="main">
@ -41,7 +42,7 @@
<section> <section>
<article> <article>
<pre class="prettyprint source linenums"><code>import { BROWSER_ALIASES_MAP } from './constants.js'; <pre class="prettyprint source linenums"><code>import { BROWSER_MAP, BROWSER_ALIASES_MAP } from './constants.js';
export default class Utils { export default class Utils {
/** /**
@ -245,6 +246,19 @@ export default class Utils {
static getBrowserAlias(browserName) { static getBrowserAlias(browserName) {
return BROWSER_ALIASES_MAP[browserName]; return BROWSER_ALIASES_MAP[browserName];
} }
/**
* Get short version/alias for a browser name
*
* @example
* getBrowserAlias('edge') // Microsoft Edge
*
* @param {string} browserName
* @return {string}
*/
static getBrowserTypeByAlias(browserAlia) {
return BROWSER_MAP[browserAlia] || '';
}
} }
</code></pre> </code></pre>
</article> </article>
@ -260,12 +274,14 @@ export default class Utils {
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:50:23 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer> </footer>
<script>prettyPrint();</script> <script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script> <script src="scripts/linenumber.js"></script>
</body> </body>
</html> </html>

9393
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "bowser", "name": "bowser",
"version": "2.4.0", "version": "2.5.0",
"description": "Lightweight browser detector", "description": "Lightweight browser detector",
"keywords": [ "keywords": [
"browser", "browser",
@ -26,29 +26,29 @@
"url": "git+https://github.com/lancedikson/bowser.git" "url": "git+https://github.com/lancedikson/bowser.git"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.2.3", "@babel/cli": "^7.5.0",
"@babel/core": "^7.2.2", "@babel/core": "^7.5.4",
"@babel/polyfill": "^7.2.5", "@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.2.3", "@babel/preset-env": "^7.5.4",
"@babel/register": "^7.0.0", "@babel/register": "^7.4.4",
"ava": "^1.4.1", "ava": "^2.2.0",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.2",
"babel-loader": "^8.0.5", "babel-loader": "^8.0.6",
"babel-plugin-add-module-exports": "^1.0.2", "babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-istanbul": "^5.1.1", "babel-plugin-istanbul": "^5.1.4",
"coveralls": "^3.0.2", "coveralls": "^3.0.5",
"docdash": "^1.0.0", "docdash": "^1.1.1",
"eslint": "^5.16.0", "eslint": "^6.0.1",
"eslint-config-airbnb-base": "^13.1.0", "eslint-config-airbnb-base": "^13.2.0",
"eslint-plugin-ava": "^6.0.0", "eslint-plugin-ava": "^7.1.0",
"eslint-plugin-import": "^2.17.2", "eslint-plugin-import": "^2.18.0",
"gh-pages": "^2.0.1", "gh-pages": "^2.0.1",
"jsdoc": "^3.5.5", "jsdoc": "^3.6.3",
"nyc": "^14.0.0", "nyc": "^14.1.1",
"sinon": "^7.2.4", "sinon": "^7.3.2",
"testem": "^2.15.1", "testem": "^2.17.0",
"webpack": "^4.28.4", "webpack": "^4.35.3",
"webpack-cli": "^3.2.1", "webpack-cli": "^3.3.6",
"yamljs": "^0.3.0" "yamljs": "^0.3.0"
}, },
"ava": { "ava": {
@ -64,14 +64,14 @@
}, },
"scripts": { "scripts": {
"build": "webpack --config webpack.config.js", "build": "webpack --config webpack.config.js",
"deploy": "jsdoc -c jsdoc.json && gh-pages --dist docs --dest docs", "generate-and-deploy-docs": "npm run generate-docs && gh-pages --dist docs --dest docs",
"prepublishOnly": "npm run build", "prepublishOnly": "npm run build",
"lint": "eslint ./src", "lint": "eslint ./src",
"testem": "testem", "testem": "testem",
"test": "nyc --reporter=html --reporter=text ava", "test": "nyc --reporter=html --reporter=text ava",
"test:watch": "ava --watch", "test:watch": "ava --watch",
"coverage": "nyc report --reporter=text-lcov | coveralls", "coverage": "nyc report --reporter=text-lcov | coveralls",
"docs": "jsdoc -c jsdoc.json" "generate-docs": "jsdoc -c jsdoc.json"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -2,9 +2,26 @@
* Bowser - a browser detector * Bowser - a browser detector
* https://github.com/lancedikson/bowser * https://github.com/lancedikson/bowser
* MIT License | (c) Dustin Diaz 2012-2015 * MIT License | (c) Dustin Diaz 2012-2015
* MIT License | (c) Denis Demchenko 2015-2017 * MIT License | (c) Denis Demchenko 2015-2019
*/ */
import Parser from './parser.js'; import Parser from './parser.js';
import {
BROWSER_MAP,
ENGINE_MAP,
OS_MAP,
PLATFORMS_MAP,
} from './constants.js';
/**
* @class
* @property name
*/
class BowserUAIsNotAStringError extends Error {
constructor(message) {
super(message);
this.name = 'BowserUAIsNotAStringError';
}
}
/** /**
* Bowser class. * Bowser class.
@ -12,15 +29,20 @@ import Parser from './parser.js';
* It's supposed to work with collections of {@link Parser} instances * It's supposed to work with collections of {@link Parser} instances
* rather then solve one-instance problems. * rather then solve one-instance problems.
* All the one-instance stuff is located in Parser class. * All the one-instance stuff is located in Parser class.
*
* @class
* @classdesc Bowser is a static object, that provides an API to the Parsers
* @hideconstructor
*/ */
class Bowser { class Bowser {
/** /**
* Creates a {@link module:parser:Parser} instance * Creates a {@link Parser} instance
* *
* @param {String} UA UserAgent string * @param {String} UA UserAgent string
* @param {Boolean} [skipParsing=false] same as skipParsing for {@link Parser} * @param {Boolean} [skipParsing=false] Will make the Parser postpone parsing until you ask it
* explicitly. Same as `skipParsing` for {@link Parser}.
* @returns {Parser} * @returns {Parser}
* @throws {Error} when UA is not a String * @throws {BowserUAIsNotAStringError} when UA is not a String
* *
* @example * @example
* const parser = Bowser.getParser(window.navigator.userAgent); * const parser = Bowser.getParser(window.navigator.userAgent);
@ -28,7 +50,7 @@ class Bowser {
*/ */
static getParser(UA, skipParsing = false) { static getParser(UA, skipParsing = false) {
if (typeof UA !== 'string') { if (typeof UA !== 'string') {
throw new Error('UserAgent should be a string'); throw new BowserUAIsNotAStringError('UserAgent should be a string');
} }
return new Parser(UA, skipParsing); return new Parser(UA, skipParsing);
} }
@ -45,6 +67,22 @@ class Bowser {
static parse(UA) { static parse(UA) {
return (new Parser(UA)).getResult(); return (new Parser(UA)).getResult();
} }
static get BROWSER_MAP() {
return BROWSER_MAP;
}
static get ENGINE_MAP() {
return ENGINE_MAP;
}
static get OS_MAP() {
return OS_MAP;
}
static get PLATFORMS_MAP() {
return PLATFORMS_MAP;
}
} }
export default Bowser; export default Bowser;

View File

@ -35,4 +35,74 @@ export const BROWSER_ALIASES_MAP = {
'WebOS Browser': 'webos', 'WebOS Browser': 'webos',
WeChat: 'wechat', WeChat: 'wechat',
'Yandex Browser': 'yandex', 'Yandex Browser': 'yandex',
Roku: 'roku',
};
export const BROWSER_MAP = {
amazon_silk: 'Amazon Silk',
android: 'Android Browser',
bada: 'Bada',
blackberry: 'BlackBerry',
chrome: 'Chrome',
chromium: 'Chromium',
epiphany: 'Epiphany',
firefox: 'Firefox',
focus: 'Focus',
generic: 'Generic',
googlebot: 'Googlebot',
ie: 'Internet Explorer',
k_meleon: 'K-Meleon',
maxthon: 'Maxthon',
edge: 'Microsoft Edge',
mz: 'MZ Browser',
naver: 'NAVER Whale Browser',
opera: 'Opera',
opera_coast: 'Opera Coast',
phantomjs: 'PhantomJS',
puffin: 'Puffin',
qupzilla: 'QupZilla',
safari: 'Safari',
sailfish: 'Sailfish',
samsung_internet: 'Samsung Internet for Android',
seamonkey: 'SeaMonkey',
sleipnir: 'Sleipnir',
swing: 'Swing',
tizen: 'Tizen',
uc: 'UC Browser',
vivaldi: 'Vivaldi',
webos: 'WebOS Browser',
wechat: 'WeChat',
yandex: 'Yandex Browser',
};
export const PLATFORMS_MAP = {
tablet: 'tablet',
mobile: 'mobile',
desktop: 'desktop',
tv: 'tv',
};
export const OS_MAP = {
WindowsPhone: 'Windows Phone',
Windows: 'Windows',
MacOS: 'macOS',
iOS: 'iOS',
Android: 'Android',
WebOS: 'WebOS',
BlackBerry: 'BlackBerry',
Bada: 'Bada',
Tizen: 'Tizen',
Linux: 'Linux',
ChromeOS: 'Chrome OS',
PlayStation4: 'PlayStation 4',
Roku: 'Roku',
};
export const ENGINE_MAP = {
EdgeHTML: 'EdgeHTML',
Blink: 'Blink',
Trident: 'Trident',
Presto: 'Presto',
Gecko: 'Gecko',
WebKit: 'WebKit',
}; };

View File

@ -1,4 +1,5 @@
import Utils from './utils.js'; import Utils from './utils.js';
import { ENGINE_MAP } from './constants.js';
/* /*
* More specific goes first * More specific goes first
@ -15,7 +16,7 @@ export default [
// return blink if it's blink-based one // return blink if it's blink-based one
if (isBlinkBased) { if (isBlinkBased) {
return { return {
name: 'Blink', name: ENGINE_MAP.Blink,
}; };
} }
@ -23,7 +24,7 @@ export default [
const version = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua); const version = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
return { return {
name: 'EdgeHTML', name: ENGINE_MAP.EdgeHTML,
version, version,
}; };
}, },
@ -34,7 +35,7 @@ export default [
test: [/trident/i], test: [/trident/i],
describe(ua) { describe(ua) {
const engine = { const engine = {
name: 'Trident', name: ENGINE_MAP.Trident,
}; };
const version = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua); const version = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua);
@ -54,7 +55,7 @@ export default [
}, },
describe(ua) { describe(ua) {
const engine = { const engine = {
name: 'Presto', name: ENGINE_MAP.Presto,
}; };
const version = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua); const version = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua);
@ -76,7 +77,7 @@ export default [
}, },
describe(ua) { describe(ua) {
const engine = { const engine = {
name: 'Gecko', name: ENGINE_MAP.Gecko,
}; };
const version = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua); const version = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua);
@ -94,7 +95,7 @@ export default [
test: [/(apple)?webkit\/537\.36/i], test: [/(apple)?webkit\/537\.36/i],
describe() { describe() {
return { return {
name: 'Blink', name: ENGINE_MAP.Blink,
}; };
}, },
}, },
@ -104,7 +105,7 @@ export default [
test: [/(apple)?webkit/i], test: [/(apple)?webkit/i],
describe(ua) { describe(ua) {
const engine = { const engine = {
name: 'WebKit', name: ENGINE_MAP.WebKit,
}; };
const version = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua); const version = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua);

View File

@ -1,13 +1,26 @@
import Utils from './utils.js'; import Utils from './utils.js';
import { OS_MAP } from './constants.js';
export default [ export default [
/* Roku */
{
test: [/Roku\/DVP/],
describe(ua) {
const version = Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i, ua);
return {
name: OS_MAP.Roku,
version,
};
},
},
/* Windows Phone */ /* Windows Phone */
{ {
test: [/windows phone/i], test: [/windows phone/i],
describe(ua) { describe(ua) {
const version = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua); const version = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
return { return {
name: 'Windows Phone', name: OS_MAP.WindowsPhone,
version, version,
}; };
}, },
@ -21,7 +34,7 @@ export default [
const versionName = Utils.getWindowsVersionName(version); const versionName = Utils.getWindowsVersionName(version);
return { return {
name: 'Windows', name: OS_MAP.Windows,
version, version,
versionName, versionName,
}; };
@ -34,7 +47,7 @@ export default [
describe(ua) { describe(ua) {
const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.'); const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.');
return { return {
name: 'macOS', name: OS_MAP.MacOS,
version, version,
}; };
}, },
@ -47,7 +60,7 @@ export default [
const version = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, '.'); const version = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, '.');
return { return {
name: 'iOS', name: OS_MAP.iOS,
version, version,
}; };
}, },
@ -64,7 +77,7 @@ export default [
const version = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua); const version = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
const versionName = Utils.getAndroidVersionName(version); const versionName = Utils.getAndroidVersionName(version);
const os = { const os = {
name: 'Android', name: OS_MAP.Android,
version, version,
}; };
if (versionName) { if (versionName) {
@ -80,7 +93,7 @@ export default [
describe(ua) { describe(ua) {
const version = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua); const version = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
const os = { const os = {
name: 'WebOS', name: OS_MAP.WebOS,
}; };
if (version && version.length) { if (version && version.length) {
@ -99,7 +112,7 @@ export default [
|| Utils.getFirstMatch(/\bbb(\d+)/i, ua); || Utils.getFirstMatch(/\bbb(\d+)/i, ua);
return { return {
name: 'BlackBerry', name: OS_MAP.BlackBerry,
version, version,
}; };
}, },
@ -112,7 +125,7 @@ export default [
const version = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua); const version = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua);
return { return {
name: 'Bada', name: OS_MAP.Bada,
version, version,
}; };
}, },
@ -125,7 +138,7 @@ export default [
const version = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua); const version = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua);
return { return {
name: 'Tizen', name: OS_MAP.Tizen,
version, version,
}; };
}, },
@ -136,7 +149,7 @@ export default [
test: [/linux/i], test: [/linux/i],
describe() { describe() {
return { return {
name: 'Linux', name: OS_MAP.Linux,
}; };
}, },
}, },
@ -146,7 +159,7 @@ export default [
test: [/CrOS/], test: [/CrOS/],
describe() { describe() {
return { return {
name: 'Chrome OS', name: OS_MAP.ChromeOS,
}; };
}, },
}, },
@ -157,7 +170,7 @@ export default [
describe(ua) { describe(ua) {
const version = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua); const version = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua);
return { return {
name: 'PlayStation 4', name: OS_MAP.PlayStation4,
version, version,
}; };
}, },

View File

@ -1,11 +1,5 @@
import Utils from './utils.js'; import Utils from './utils.js';
import { PLATFORMS_MAP } from './constants.js';
const TYPES_LABELS = {
tablet: 'tablet',
mobile: 'mobile',
desktop: 'desktop',
tv: 'tv',
};
/* /*
* Tablets go first since usually they have more specific * Tablets go first since usually they have more specific
@ -30,7 +24,7 @@ export default [
describe(ua) { describe(ua) {
const model = Utils.getFirstMatch(/(can-l01)/i, ua) && 'Nova'; const model = Utils.getFirstMatch(/(can-l01)/i, ua) && 'Nova';
const platform = { const platform = {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
vendor: 'Huawei', vendor: 'Huawei',
}; };
if (model) { if (model) {
@ -45,7 +39,7 @@ export default [
test: [/nexus\s*(?:7|8|9|10).*/i], test: [/nexus\s*(?:7|8|9|10).*/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.tablet, type: PLATFORMS_MAP.tablet,
vendor: 'Nexus', vendor: 'Nexus',
}; };
}, },
@ -56,7 +50,7 @@ export default [
test: [/ipad/i], test: [/ipad/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.tablet, type: PLATFORMS_MAP.tablet,
vendor: 'Apple', vendor: 'Apple',
model: 'iPad', model: 'iPad',
}; };
@ -68,7 +62,7 @@ export default [
test: [/kftt build/i], test: [/kftt build/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.tablet, type: PLATFORMS_MAP.tablet,
vendor: 'Amazon', vendor: 'Amazon',
model: 'Kindle Fire HD 7', model: 'Kindle Fire HD 7',
}; };
@ -80,7 +74,7 @@ export default [
test: [/silk/i], test: [/silk/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.tablet, type: PLATFORMS_MAP.tablet,
vendor: 'Amazon', vendor: 'Amazon',
}; };
}, },
@ -91,7 +85,7 @@ export default [
test: [/tablet/i], test: [/tablet/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.tablet, type: PLATFORMS_MAP.tablet,
}; };
}, },
}, },
@ -106,7 +100,7 @@ export default [
describe(ua) { describe(ua) {
const model = Utils.getFirstMatch(/(ipod|iphone)/i, ua); const model = Utils.getFirstMatch(/(ipod|iphone)/i, ua);
return { return {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
vendor: 'Apple', vendor: 'Apple',
model, model,
}; };
@ -118,7 +112,7 @@ export default [
test: [/nexus\s*[0-6].*/i, /galaxy nexus/i], test: [/nexus\s*[0-6].*/i, /galaxy nexus/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
vendor: 'Nexus', vendor: 'Nexus',
}; };
}, },
@ -129,7 +123,7 @@ export default [
test: [/[^-]mobi/i], test: [/[^-]mobi/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
}; };
}, },
}, },
@ -141,7 +135,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
vendor: 'BlackBerry', vendor: 'BlackBerry',
}; };
}, },
@ -154,7 +148,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
}; };
}, },
}, },
@ -166,7 +160,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
vendor: 'Microsoft', vendor: 'Microsoft',
}; };
}, },
@ -180,7 +174,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.tablet, type: PLATFORMS_MAP.tablet,
}; };
}, },
}, },
@ -192,7 +186,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.mobile, type: PLATFORMS_MAP.mobile,
}; };
}, },
}, },
@ -204,7 +198,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.desktop, type: PLATFORMS_MAP.desktop,
vendor: 'Apple', vendor: 'Apple',
}; };
}, },
@ -217,7 +211,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.desktop, type: PLATFORMS_MAP.desktop,
}; };
}, },
}, },
@ -229,7 +223,7 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.desktop, type: PLATFORMS_MAP.desktop,
}; };
}, },
}, },
@ -241,7 +235,19 @@ export default [
}, },
describe() { describe() {
return { return {
type: TYPES_LABELS.tv, type: PLATFORMS_MAP.tv,
};
},
},
/* Roku */
{
test(parser) {
return parser.getOSName(true) === 'roku';
},
describe() {
return {
type: PLATFORMS_MAP.tv,
}; };
}, },
}, },

View File

@ -409,15 +409,14 @@ class Parser {
* @returns {boolean} * @returns {boolean}
*/ */
isBrowser(browserName, includingAlias = false) { isBrowser(browserName, includingAlias = false) {
const defaultBrowserName = this.getBrowserName(); const defaultBrowserName = this.getBrowserName().toLowerCase();
const possibleNames = [defaultBrowserName.toLowerCase()]; let browserNameLower = browserName.toLowerCase();
const alias = Utils.getBrowserAlias(defaultBrowserName); const alias = Utils.getBrowserTypeByAlias(browserNameLower);
if (includingAlias && typeof alias !== 'undefined') { if (includingAlias && alias) {
possibleNames.push(alias.toLowerCase()); browserNameLower = alias.toLowerCase();
} }
return browserNameLower === defaultBrowserName;
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
} }
compareVersion(version) { compareVersion(version) {

View File

@ -1,4 +1,4 @@
import { BROWSER_ALIASES_MAP } from './constants.js'; import { BROWSER_MAP, BROWSER_ALIASES_MAP } from './constants.js';
export default class Utils { export default class Utils {
/** /**
@ -202,4 +202,17 @@ export default class Utils {
static getBrowserAlias(browserName) { static getBrowserAlias(browserName) {
return BROWSER_ALIASES_MAP[browserName]; return BROWSER_ALIASES_MAP[browserName];
} }
/**
* Get short version/alias for a browser name
*
* @example
* getBrowserAlias('edge') // Microsoft Edge
*
* @param {string} browserName
* @return {string}
*/
static getBrowserTypeByAlias(browserAlia) {
return BROWSER_MAP[browserAlia] || '';
}
} }

View File

@ -308,6 +308,18 @@
type: "mobile" type: "mobile"
engine: engine:
name: "Blink" name: "Blink"
- ua: "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36 Roku/DVP-7.53 (147.53E04068A)"
spec:
browser:
name: "Chrome"
version: "60.0.3112.113"
os:
name: "Roku"
version: "7.53"
platform:
type: "tv"
engine:
name: "Blink"
Amazon Silk: Amazon Silk:
- -
ua: "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true" ua: "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true"
@ -2666,3 +2678,16 @@
engine: engine:
name: "WebKit" name: "WebKit"
version: "605.1.15" version: "605.1.15"
Roku:
-
ua: "Roku/DVP-9.0 (047.00E09044A)"
spec:
browser:
name: "Roku"
version: "DVP-9.0"
os:
name: "Roku"
version: "9.0"
platform:
type: "tv"
engine: {}

View File

@ -1,6 +1,7 @@
import test from 'ava'; import test from 'ava';
import sinon from 'sinon'; import sinon from 'sinon';
import Parser from '../../src/parser'; import Parser from '../../src/parser';
import Bowser from '../../src/bowser';
const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1165'; const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1165';
const parser = new Parser(UA, true); const parser = new Parser(UA, true);
@ -164,6 +165,12 @@ test('Parser.is should pass', (t) => {
t.is(parser.is('macos'), true); t.is(parser.is('macos'), true);
}); });
test('Parser.is using constants should pass', (t) => {
t.is(parser.is(Bowser.BROWSER_MAP.opera), true);
t.is(parser.is(Bowser.PLATFORMS_MAP.desktop), true);
t.is(parser.is(Bowser.OS_MAP.MacOS), true);
});
test('Parser.some should pass', (t) => { test('Parser.some should pass', (t) => {
t.is(parser.some(['opera', 'chrome', 'firefox']), true); t.is(parser.some(['opera', 'chrome', 'firefox']), true);
t.is(parser.some(['macos', 'windows']), true); t.is(parser.some(['macos', 'windows']), true);