@ -532,6 +449,8 @@ const result = parser.getResult();</code></pre>
<h5>Returns:</h5>
@ -552,6 +471,7 @@ const result = parser.getResult();</code></pre>
@ -572,12 +492,14 @@ const result = parser.getResult();</code></pre>
<brclass="clear">
<footer>
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:53:54 GMT+0300 (EEST) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 09 2020 22:13:18 GMT+0300 (Eastern European Summer Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="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 <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
@ -2798,6 +2864,8 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<h5>Returns:</h5>
@ -2818,6 +2886,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
@ -2949,6 +3018,8 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<h5>Returns:</h5>
@ -2969,6 +3040,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
@ -2989,12 +3061,14 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
<brclass="clear">
<footer>
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:53:54 GMT+0300 (EEST) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 09 2020 22:13:18 GMT+0300 (Eastern European Summer Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
@ -55,13 +62,18 @@ import Parser from './parser.js';
* It's supposed to work with collections of {@link Parser} instances
* rather then solve one-instance problems.
* 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 {
/**
* Creates a {@link module:parser:Parser} instance
* Creates a {@link Parser} instance
*
* @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}
* @throws {Error} when UA is not a String
*
@ -88,6 +100,22 @@ class Bowser {
static parse(UA) {
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;
@ -105,12 +133,14 @@ export default Bowser;
<brclass="clear">
<footer>
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:53:54 GMT+0300 (EEST) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 09 2020 22:13:18 GMT+0300 (Eastern European Summer Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
@ -1995,12 +2706,14 @@ like <code>"iPhone"</code> or <code>"Kindle Fire HD 7"</code
<brclass="clear">
<footer>
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:53:54 GMT+0300 (EEST) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 09 2020 22:13:18 GMT+0300 (Eastern European Summer Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
<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>
<p>A small, fast and rich-API browser/platform/engine detector for both browser and node.</p>
<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 <ahref="https://opencollective.com/bowser">OpenCollective</a> if you like it ❤️ Also, contributors are always welcome!</p>
<p><ahref="https://opencollective.com/bowser"><imgsrc="https://opencollective.com/bowser/all/badge.svg?label=financial+contributors"alt="Financial Contributors on Open Collective"></a><ahref="https://travis-ci.org/lancedikson/bowser/"><imgsrc="https://travis-ci.org/lancedikson/bowser.svg?branch=master"alt="Build Status"></a><ahref="https://greenkeeper.io/"><imgsrc="https://badges.greenkeeper.io/lancedikson/bowser.svg"alt="Greenkeeper badge"></a><ahref="https://coveralls.io/github/lancedikson/bowser?branch=master"><imgsrc="https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master"alt="Coverage Status"></a><imgsrc="https://img.shields.io/npm/dm/bowser"alt="Downloads"></p>
<li><ahref="#contributing">How can I help?</a></li>
</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>
<h3>⚠️ Version 2.0 breaking changes ⚠️</h3><p>Version 2.0 has drastically changed the API. All available methods are on the <ahref="https://lancedikson.github.io/bowser/docs">docs page</a>.</p>
<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. Check it out on this page: https://bowser-js.github.io/bowser-online/.</p>
<h3>⚠️ Version 2.0 breaking changes ⚠️</h3>
<p>Version 2.0 has drastically changed the API. All available methods are on the <ahref="https://lancedikson.github.io/bowser/docs">docs page</a>.</p>
<p><em>For legacy code, check out the <ahref="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>
import * as Bowser from "bowser"; // TypeScript
import Bowser from "bowser"; // 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 "bowser"; // 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.
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>
<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>
}</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.
chrome: "=20.1.1432", // will match particular build only
// and loose-equality operator
chrome: "~20" // will match any 20.* sub-version
chrome: "~20", // will match any 20.* sub-version
chrome: "~20.1" // 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>
<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
list of aliases can be found in <ahref="src/constants.js">the file</a>.</p>
<h2>Similar Projects</h2><ul>
<h2>Similar Projects</h2>
<ul>
<li><ahref="https://github.com/BigBadBleuCheese/Kong">Kong</a> - A C# port of Bowser.</li>
</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>Contributors</h2>
<h3>Code Contributors</h3>
<p>This project exists thanks to all the people who contribute. [<ahref="CONTRIBUTING.md">Contribute</a>].
<p>Support this project with your organization. Your logo will show up here with a link to your website. [<ahref="https://opencollective.com/bowser/contribute">Contribute</a>]</p>
<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>
@ -157,12 +210,14 @@ list of aliases can be found in <a href="src/constants.js">the file</a>.</p>
<brclass="clear">
<footer>
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:53:54 GMT+0300 (EEST) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 09 2020 22:13:18 GMT+0300 (Eastern European Summer Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:53:54 GMT+0300 (EEST) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 09 2020 22:13:18 GMT+0300 (Eastern European Summer Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
<preclass="prettyprint source linenums"><code>import { BROWSER_ALIASES_MAP } from './constants.js';
<preclass="prettyprint source linenums"><code>import { BROWSER_MAP, BROWSER_ALIASES_MAP } from './constants.js';
export default class Utils {
/**
@ -96,6 +97,46 @@ export default class Utils {
}
}
/**
* Get macOS version name
* 10.5 - Leopard
* 10.6 - Snow Leopard
* 10.7 - Lion
* 10.8 - Mountain Lion
* 10.9 - Mavericks
* 10.10 - Yosemite
* 10.11 - El Capitan
* 10.12 - Sierra
* 10.13 - High Sierra
* 10.14 - Mojave
* 10.15 - Catalina
*
* @example
* getMacOSVersionName("10.14") // 'Mojave'
*
* @param {string} version
* @return {string} versionName
*/
static getMacOSVersionName(version) {
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
v.push(0);
if (v[0] !== 10) return undefined;
switch (v[1]) {
case 5: return 'Leopard';
case 6: return 'Snow Leopard';
case 7: return 'Lion';
case 8: return 'Mountain Lion';
case 9: return 'Mavericks';
case 10: return 'Yosemite';
case 11: return 'El Capitan';
case 12: return 'Sierra';
case 13: return 'High Sierra';
case 14: return 'Mojave';
case 15: return 'Catalina';
default: return undefined;
}
}
/**
* Get Android version name
* 1.5 - Cupcake
@ -112,7 +153,7 @@ export default class Utils {
* 6.x - Marshmallow
* 7.x - Nougat
* 8.x - Oreo
* 9.x - ?
* 9.x - Pie
*
* @example
* getAndroidVersionName("7.0") // 'Nougat'
@ -137,6 +178,7 @@ export default class Utils {
if (v[0] === 6) return 'Marshmallow';
if (v[0] === 7) return 'Nougat';
if (v[0] === 8) return 'Oreo';
if (v[0] === 9) return 'Pie';
return undefined;
}
@ -212,6 +254,8 @@ export default class Utils {
return -1;
}
}
return undefined;
}
/**
@ -233,6 +277,54 @@ export default class Utils {
return result;
}
/**
* Array::find polyfill
*
* @param {Array} arr
* @param {Function} predicate
* @return {Array}
*/
static find(arr, predicate) {
let i;
let l;
if (Array.prototype.find) {
return Array.prototype.find.call(arr, predicate);
}
for (i = 0, l = arr.length; i < l; i += 1) {
const value = arr[i];
if (predicate(value, i)) {
return value;
}
}
return undefined;
}
/**
* Object::assign polyfill
*
* @param {Object} obj
* @param {Object} ...objs
* @return {Object}
*/
static assign(obj, ...assigners) {
const result = obj;
let i;
let l;
if (Object.assign) {
return Object.assign(obj, ...assigners);
}
for (i = 0, l = assigners.length; i < l; i += 1) {
const assigner = assigners[i];
if (typeof assigner === 'object' && assigner !== null) {
const keys = Object.keys(assigner);
keys.forEach((key) => {
result[key] = assigner[key];
});
}
}
return obj;
}
/**
* Get short version/alias for a browser name
*
@ -245,6 +337,19 @@ export default class Utils {
static getBrowserAlias(browserName) {
return BROWSER_ALIASES_MAP[browserName];
}
/**
* Get short version/alias for a browser name
*
* @example
* getBrowserAlias('edge') // Microsoft Edge
*
* @param {string} browserAlias
* @return {string}
*/
static getBrowserTypeByAlias(browserAlias) {
return BROWSER_MAP[browserAlias] || '';
}
}
</code></pre>
</article>
@ -260,12 +365,14 @@ export default class Utils {
<brclass="clear">
<footer>
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri May 03 2019 21:53:54 GMT+0300 (EEST) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 09 2020 22:13:18 GMT+0300 (Eastern European Summer Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.