1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00
lancedikson_bowser/docs/Parser.html
2018-07-05 22:44:43 +03:00

2513 lines
28 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Parser - 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">
</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="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#compare">compare</a></li><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#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#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#test">test</a></li></ul></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<div id="main">
<h1 class="page-title">Parser</h1>
<section>
<header>
<h2>
Parser
</h2>
<div class="class-description"><p>The main class that arranges the whole parsing process.</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Parser"><span class="type-signature"></span>new Parser<span class="signature">(UA, skipParsing<span class="signature-attributes">opt</span>)</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="parser.js.html">parser.js</a>, <a href="parser.js.html#line10">line 10</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Create instance of Parser</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>UA</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>User-Agent string</p></td>
</tr>
<tr>
<td class="name"><code>skipParsing</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>parser can skip parsing in purpose of performance
improvements if you need to make a more particular parsing
like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Parser.html#parsePlatform">Parser#parsePlatform</a></p></td>
</tr>
</tbody>
</table>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="compare"><span class="type-signature"></span>compare<span class="signature">(checkTree)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line334">line 334</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Check if parsed browser matches certain conditions</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const browser = new Bowser(UA);
if (browser.check({chrome: '>118.01.1322' }))
// or with os
if (browser.check({windows: { chrome: '>118.01.1322' } }))
// or with platforms
if (browser.check({desktop: { chrome: '>118.01.1322' } }))</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>checkTree</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>It's one or two layered object,
which can include a platform or an OS on the first layer
and should have browsers specs on the bottom-laying layer</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>whether the browser satisfies the set conditions or not</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="getBrowser"><span class="type-signature"></span>getBrowser<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line105">line 105</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get parsed browser object</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="getBrowserName"><span class="type-signature"></span>getBrowserName<span class="signature">()</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="parser.js.html">parser.js</a>, <a href="parser.js.html#line119">line 119</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get browser's name</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>Browser's name or an empty string</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="getBrowserVersion"><span class="type-signature"></span>getBrowserVersion<span class="signature">()</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="parser.js.html">parser.js</a>, <a href="parser.js.html#line133">line 133</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get browser's version</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>version of browser</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="getEngine"><span class="type-signature"></span>getEngine<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line262">line 262</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get parsed engine</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="getOS"><span class="type-signature"></span>getOS<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line148">line 148</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get OS</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>this.getOS();
{
name: 'macOS',
version: '10.11.12'
}</code></pre>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<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>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line187">line 187</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get OS name</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>toLowerCase</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>return lower-cased value</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>name of the OS — macOS, Windows, Linux, etc.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="getOSVersion"><span class="type-signature"></span>getOSVersion<span class="signature">()</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="parser.js.html">parser.js</a>, <a href="parser.js.html#line201">line 201</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get OS version</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>full version with dots ('10.11.12', '5.6', etc)</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="getPlatform"><span class="type-signature"></span>getPlatform<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line209">line 209</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get parsed platform</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="getPlatformType"><span class="type-signature"></span>getPlatformType<span class="signature">(toLowerCase)</span><span class="type-signature"> &rarr; {*}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line222">line 222</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get platform name</p>
</div>
<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>toLowerCase</code></td>
<td class="type">
<span class="param-type">Boolean</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">*</span>
</dd>
</dl>
<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>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line312">line 312</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get parsed result</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#ParsedResult">ParsedResult</a></span>
</dd>
</dl>
<h4 class="name" id="getUA"><span class="type-signature"></span>getUA<span class="signature">()</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="parser.js.html">parser.js</a>, <a href="parser.js.html#line60">line 60</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get UserAgent string of current Parser instance</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>User-Agent String of the current <Parser> object</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="is"><span class="type-signature"></span>is<span class="signature">(anything)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line382">line 382</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Is anything? Check if the browser is called &quot;anything&quot;,
the OS called &quot;anything&quot; or the platform called &quot;anything&quot;</p>
</div>
<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>anything</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">Boolean</span>
</dd>
</dl>
<h4 class="name" id="parse"><span class="type-signature"></span>parse<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="parser.js.html">parser.js</a>, <a href="parser.js.html#line299">line 299</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Parse full information about the browser</p>
</div>
<h4 class="name" id="parseBrowser"><span class="type-signature"></span>parseBrowser<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line77">line 77</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get parsed browser object</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="parseEngine"><span class="type-signature"></span>parseEngine<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line274">line 274</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get parsed platform</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="parseOS"><span class="type-signature"></span>parseOS<span class="signature">()</span><span class="type-signature"> &rarr; {*|Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line160">line 160</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Parse OS and save it to this.parsedResult.os</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
|
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="parsePlatform"><span class="type-signature"></span>parsePlatform<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line236">line 236</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Get parsed platform</p>
</div>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="test"><span class="type-signature"></span>test<span class="signature">(regex)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line69">line 69</a>
</li></ul></dd>
</dl>
<div class="description">
<p>Test a UA string for a regexp</p>
</div>
<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>regex</code></td>
<td class="type">
<span class="param-type">RegExp</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">Boolean</span>
</dd>
</dl>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Jul 05 2018 22:44:07 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>