2018-09-09 12:08:48 +00:00
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "utf-8" >
< title > bowser.js - 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" >
2019-07-16 19:21:01 +00:00
< script src = "scripts/nav.js" defer > < / script >
2018-09-09 12:08:48 +00:00
< 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 >
2019-07-16 19:21:01 +00:00
< nav >
2018-09-09 12:08:48 +00:00
2020-07-09 19:11:59 +00:00
< 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#assign" > assign< / a > < / li > < li > < a href = "global.html#find" > find< / a > < / li > < 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#getMacOSVersionName" > getMacOSVersionName< / 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 >
2018-09-09 12:08:48 +00:00
< / nav >
< div id = "main" >
< h1 class = "page-title" > bowser.js< / h1 >
< section >
< article >
2018-07-05 19:44:43 +00:00
< pre class = "prettyprint source linenums" > < code > /*!
* Bowser - a browser detector
* https://github.com/lancedikson/bowser
* MIT License | (c) Dustin Diaz 2012-2015
2019-07-16 19:21:01 +00:00
* MIT License | (c) Denis Demchenko 2015-2019
2018-07-05 19:44:43 +00:00
*/
2019-03-06 12:31:37 +00:00
import Parser from './parser.js';
2019-07-16 19:21:01 +00:00
import {
BROWSER_MAP,
ENGINE_MAP,
OS_MAP,
PLATFORMS_MAP,
} from './constants.js';
2018-07-05 19:44:43 +00:00
/**
* Bowser class.
* Keep it simple as much as it can be.
* 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.
2019-07-16 19:21:01 +00:00
*
* @class
* @classdesc Bowser is a static object, that provides an API to the Parsers
* @hideconstructor
2018-07-05 19:44:43 +00:00
*/
class Bowser {
/**
2019-07-16 19:21:01 +00:00
* Creates a {@link Parser} instance
2018-07-05 19:44:43 +00:00
*
* @param {String} UA UserAgent string
2019-07-16 19:21:01 +00:00
* @param {Boolean} [skipParsing=false] Will make the Parser postpone parsing until you ask it
* explicitly. Same as `skipParsing` for {@link Parser}.
2018-07-05 19:44:43 +00:00
* @returns {Parser}
2019-07-17 10:52:54 +00:00
* @throws {Error} when UA is not a String
2018-07-05 19:44:43 +00:00
*
* @example
2018-10-19 17:32:59 +00:00
* const parser = Bowser.getParser(window.navigator.userAgent);
* const result = parser.getResult();
2018-07-05 19:44:43 +00:00
*/
2018-08-18 11:14:56 +00:00
static getParser(UA, skipParsing = false) {
2018-07-05 19:44:43 +00:00
if (typeof UA !== 'string') {
2019-07-17 10:52:54 +00:00
throw new Error('UserAgent should be a string');
2018-07-05 19:44:43 +00:00
}
return new Parser(UA, skipParsing);
}
/**
* Creates a {@link Parser} instance and runs {@link Parser.getResult} immediately
*
* @param UA
* @return {ParsedResult}
2018-10-19 17:32:59 +00:00
*
* @example
* const result = Bowser.parse(window.navigator.userAgent);
2018-07-05 19:44:43 +00:00
*/
static parse(UA) {
2018-07-08 09:09:27 +00:00
return (new Parser(UA)).getResult();
2018-07-05 19:44:43 +00:00
}
2019-07-16 19:21:01 +00:00
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;
}
2018-07-05 19:44:43 +00:00
}
export default Bowser;
2018-09-09 12:08:48 +00:00
< / code > < / pre >
< / article >
< / section >
< / div >
< br class = "clear" >
< footer >
2020-09-12 08:22:31 +00:00
Documentation generated by < a href = "https://github.com/jsdoc3/jsdoc" > JSDoc 3.6.3< / a > on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the < a href = "https://github.com/clenemt/docdash" > docdash< / a > theme.
2018-09-09 12:08:48 +00:00
< / footer >
< script > prettyPrint ( ) ; < / script >
2019-07-16 19:21:01 +00:00
< script src = "scripts/polyfill.js" > < / script >
2018-09-09 12:08:48 +00:00
< script src = "scripts/linenumber.js" > < / script >
2019-07-16 19:21:01 +00:00
2018-09-09 12:08:48 +00:00
< / body >
< / html >