Skip to content

Commit

Permalink
Regen docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lancedikson committed Aug 18, 2018
1 parent d039ce0 commit 2bc8982
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/Bowser.html
Expand Up @@ -559,7 +559,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 22 2018 19:42:18 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.5.5</a> on Sat Aug 18 2018 14:14:47 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
6 changes: 3 additions & 3 deletions docs/Parser.html
Expand Up @@ -1558,7 +1558,7 @@ <h4 class="name" id="is"><span class="type-signature"></span>is<span class="sign

<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#line427">line 427</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line432">line 432</a>
</li></ul></dd>


Expand Down Expand Up @@ -2376,7 +2376,7 @@ <h4 class="name" id="some"><span class="type-signature"></span>some<span class="

<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#line436">line 436</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line441">line 441</a>
</li></ul></dd>


Expand Down Expand Up @@ -2679,7 +2679,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 22 2018 19:42:18 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.5.5</a> on Sat Aug 18 2018 14:14:47 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
4 changes: 2 additions & 2 deletions docs/bowser.js.html
Expand Up @@ -65,7 +65,7 @@ <h1 class="page-title">bowser.js</h1>
* const bowser = new Bowser(window.navigator.userAgent);
* bowser.getResult()
*/
static getParser(UA, skipParsing=false) {
static getParser(UA, skipParsing = false) {
if (typeof UA !== 'string') {
throw new Error('UserAgent should be a string');
}
Expand Down Expand Up @@ -96,7 +96,7 @@ <h1 class="page-title">bowser.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 22 2018 19:42:18 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.5.5</a> on Sat Aug 18 2018 14:14:47 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/global.html
Expand Up @@ -758,7 +758,7 @@ <h6>Properties</h6>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 22 2018 19:42:18 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.5.5</a> on Sat Aug 18 2018 14:14:47 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
16 changes: 11 additions & 5 deletions docs/index.html
Expand Up @@ -59,13 +59,12 @@ <h1>Overview</h1><p>The library is made to help to detect what browser your user
<p><strong>Changes of the 2.0</strong>
The upcoming 2.0 version has drastically changed API. All available methods can be found in the <code>docs</code> folder from now on and on a webpage soon.</p>
<h1>Use cases</h1><p>First of all, require the library:</p>
<pre class="prettyprint source lang-javascript"><code>const bowser = require('bowser');</code></pre><p>By default, <code>require('bowser')</code> requires the <em>ES6 version of files</em>, which
<pre class="prettyprint source lang-javascript"><code>const bowser = require('bowser');</code></pre><p>By default, <code>require('bowser')</code> requires the <em>ES5 version of files</em>, which
<strong>do not</strong> include any polyfills.</p>
<p>In case if 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>If you use bowser for Node.js, you'd better use <code>require('bowser/es5')</code>,
since source files have <code>import</code> statements, which are not compatible with Node.js yet.</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 make it with Bowser:</p>
<pre class="prettyprint source lang-javascript"><code>const browser = bowser.getParser(window.navigator.userAgent);

Expand Down Expand Up @@ -100,7 +99,7 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti
}
}</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>
<pre class="prettyprint source lang-javascript"><code>const browser = bowser.getParsers(window.navigator.userAgent);
<pre class="prettyprint source lang-javascript"><code>const browser = bowser.getParser(window.navigator.userAgent);
const isValidBrowser = browser.satisfies({
// declare browsers per OS
windows: {
Expand All @@ -120,6 +119,13 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti
chrome: &quot;>20.1.1432&quot;,
firefox: &quot;>31&quot;,
opera: &quot;>22&quot;

// also supports equality operator
chrome: &quot;=20.1.1432&quot;, // will match particular build only

// and loose-equality operator
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)
});</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>
Expand All @@ -144,7 +150,7 @@ <h3>License</h3><p>Licensed as MIT. All rights not explicitly granted in the MIT
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 22 2018 19:42:18 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.5.5</a> on Sat Aug 18 2018 14:14:47 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
9 changes: 7 additions & 2 deletions docs/parser.js.html
Expand Up @@ -436,6 +436,7 @@ <h1 class="page-title">parser.js</h1>
compareVersion(version) {
let expectedResult = 0;
let comparableVersion = version;
let isLoose = false;

if (version[0] === '>') {
expectedResult = 1;
Expand All @@ -445,8 +446,12 @@ <h1 class="page-title">parser.js</h1>
comparableVersion = version.substr(1);
} else if (version[0] === '=') {
comparableVersion = version.substr(1);
} else if (version[0] === '~') {
isLoose = true;
comparableVersion = version.substr(1);
}
return compareVersions(this.getBrowserVersion(), comparableVersion) === expectedResult;

return compareVersions(this.getBrowserVersion(), comparableVersion, isLoose) === expectedResult;
}

isOS(osName) {
Expand Down Expand Up @@ -490,7 +495,7 @@ <h1 class="page-title">parser.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 22 2018 19:42:18 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.5.5</a> on Sat Aug 18 2018 14:14:47 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
32 changes: 20 additions & 12 deletions docs/utils.js.html
Expand Up @@ -107,23 +107,26 @@ <h1 class="page-title">utils.js</h1>
* Calculate browser version weight
*
* @example
* compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1
* compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1
* compareVersions(['1.10.2.1', '1.10.2.1']); // 0
* compareVersions(['1.10.2.1', '1.0800.2']); // -1
* compareVersions('1.10.2.1', '1.8.2.1.90') // 1
* compareVersions('1.010.2.1', '1.09.2.1.90'); // 1
* compareVersions('1.10.2.1', '1.10.2.1'); // 0
* compareVersions('1.10.2.1', '1.0800.2'); // -1
* compareVersions('1.10.2.1', '1.10', true); // 0
*
* @param {String} versionA versions versions to compare
* @param {String} versionB versions versions to compare
* @param {boolean} [isLoose] enable loose comparison
* @return {Number} comparison result: -1 when versionA is lower,
* 1 when versionA is bigger, 0 when both equal
*/
/* eslint consistent-return: 1 */
static compareVersions(versionA, versionB) {
static compareVersions(versionA, versionB, isLoose = false) {
// 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
let precision = Math.max(
Utils.getVersionPrecision(versionA),
Utils.getVersionPrecision(versionB),
);
const versionAPrecision = Utils.getVersionPrecision(versionA);
const versionBPrecision = Utils.getVersionPrecision(versionB);

let precision = Math.max(versionAPrecision, versionBPrecision);
let lastPrecision = 0;

const chunks = Utils.map([versionA, versionB], (version) => {
const delta = precision - Utils.getVersionPrecision(version);
Expand All @@ -135,14 +138,19 @@ <h1 class="page-title">utils.js</h1>
return Utils.map(_version.split('.'), chunk => new Array(20 - chunk.length).join('0') + chunk).reverse();
});

// adjust precision for loose comparison
if (isLoose) {
lastPrecision = precision - Math.min(versionAPrecision, versionBPrecision);
}

// iterate in reverse order by reversed chunks array
precision -= 1;
while (precision >= 0) {
while (precision >= lastPrecision) {
// 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
if (chunks[0][precision] > chunks[1][precision]) {
return 1;
} else if (chunks[0][precision] === chunks[1][precision]) {
if (precision === 0) {
if (precision === lastPrecision) {
// all version chunks are same
return 0;
}
Expand Down Expand Up @@ -186,7 +194,7 @@ <h1 class="page-title">utils.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 22 2018 19:42:18 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.5.5</a> on Sat Aug 18 2018 14:14:47 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down

0 comments on commit 2bc8982

Please sign in to comment.