Skip to content

Commit

Permalink
Fix the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lancedikson committed Jan 19, 2019
1 parent cab0d0d commit a87ccad
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 34 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ const isValidBrowser = browser.satisfies({

// per platform (mobile, desktop or tablet)
mobile: {
safari: '>9',
safari: '>=9',
'android browser': '>3.10'
},

// or in general
chrome: ">20.1.1432",
chrome: "~20.1.1432",
firefox: ">31",
opera: ">22"
opera: ">=22"

// also supports equality operator
chrome: "=20.1.1432", // will match particular build only

Expand Down
2 changes: 1 addition & 1 deletion docs/Bowser.html
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 19 2018 19:31:53 GMT+0200 (Central European Summer Time) 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 Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
10 changes: 5 additions & 5 deletions docs/Parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,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#line438">line 438</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line446">line 446</a>
</li></ul></dd>


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

<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#line340">line 340</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line339">line 339</a>
</li></ul></dd>


Expand Down Expand Up @@ -2382,7 +2382,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#line447">line 447</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line455">line 455</a>
</li></ul></dd>


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


<div class="description">
<p>Check if any of the given values satifies this.is(anything)</p>
<p>Check if any of the given values satisfies this.is(anything)</p>
</div>


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

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 19 2018 19:31:53 GMT+0200 (Central European Summer Time) 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 Jan 19 2019 15:43:45 GMT+0200 (EET) 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/bowser.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,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 Fri Oct 19 2018 19:31:53 GMT+0200 (Central European Summer Time) 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 Jan 19 2019 15:43:45 GMT+0200 (EET) 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
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ <h6>Properties</h6>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 19 2018 19:31:53 GMT+0200 (Central European Summer Time) 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 Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
21 changes: 12 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ <h1>Overview</h1><p>The library is made to help to detect what browser your user
<p><em>Please, note that this is an alpha version. Check out the <a href="https://github.com/lancedikson/bowser/tree/v1.x">1.x</a> branch for a stable version.</em></p>
<p><strong>Changes of version 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>ES5 version of files</em>, which
<strong>do not</strong> include any polyfills.</p>
<h1>Use cases</h1><p>First of all, require the library. This is a UMD Module, so it will work for AMD, Typescript and CommonJS module systems.</p>
<pre class="prettyprint source lang-javascript"><code>const Bowser = require(&quot;bowser&quot;); // CommonJS

import * as Bowser from &quot;bowser&quot; // Typescript</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>
Expand All @@ -83,6 +84,7 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti
<pre class="prettyprint source lang-javascript"><code>const browser = bowser.getParser(window.navigator.userAgent);
impression.userTechData = browser.parse();
console.log(impression.userTechData);

// outputs
{
browser: {
Expand Down Expand Up @@ -115,14 +117,14 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti

// per platform (mobile, desktop or tablet)
mobile: {
safari: '>9',
safari: '>=9',
'android browser': '>3.10'
},

// or in general
chrome: &quot;>20.1.1432&quot;,
chrome: &quot;~20.1.1432&quot;,
firefox: &quot;>31&quot;,
opera: &quot;>22&quot;
opera: &quot;>=22&quot;

// also supports equality operator
chrome: &quot;=20.1.1432&quot;, // will match particular build only
Expand All @@ -134,8 +136,9 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti
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>
<h1>Contributing</h1><p>If you'd like to contribute a change to bowser, modify the files in <code>src/</code>, then run the following (you'll need node + npm installed):</p>
<pre class="prettyprint source lang-sh"><code>$ npm install
$ npm test</code></pre><h3>Adding tests</h3><p>See the list in <code>test/acceptance/useragentstrings.yml</code> with example user agents and their expected bowser object.</p>
<pre class="prettyprint source lang-sh"><code>$ npm install #build
$ npm test #run tests
$ npm run lint #check lint rules</code></pre><h3>Adding tests</h3><p>See the list in <code>test/acceptance/useragentstrings.yml</code> with example user agents and their expected bowser object.</p>
<p>Whenever you add support for new browsers or notice a bug / mismatch, please update the list and
check if all tests are still passing.</p>
<h3>Similar Projects</h3><ul>
Expand All @@ -156,7 +159,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 Fri Oct 19 2018 19:31:53 GMT+0200 (Central European Summer Time) 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 Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
30 changes: 19 additions & 11 deletions docs/parser.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ <h1 class="page-title">parser.js</h1>
* @return {ParsedResult}
*/
getResult() {
/* TODO: Make this function pure, return a new object instead of the reference */
return this.parsedResult;
return Object.assign({}, this.parsedResult);
}

/**
Expand Down Expand Up @@ -438,7 +437,7 @@ <h1 class="page-title">parser.js</h1>
}

compareVersion(version) {
let expectedResult = 0;
let expectedResults = [0];
let comparableVersion = version;
let isLoose = false;

Expand All @@ -448,20 +447,29 @@ <h1 class="page-title">parser.js</h1>
return void 0;
}

if (version[0] === '>') {
expectedResult = 1;
comparableVersion = version.substr(1);
} else if (version[0] === '&lt;') {
expectedResult = -1;
if (version[0] === '>' || version[0] === '&lt;') {
comparableVersion = version.substr(1);
if (version[1] === '=') {
isLoose = true;
comparableVersion = version.substr(2);
} else {
expectedResults = [];
}
if (version[0] === '>') {
expectedResults.push(1);
} else {
expectedResults.push(-1);
}
} else if (version[0] === '=') {
comparableVersion = version.substr(1);
} else if (version[0] === '~') {
isLoose = true;
comparableVersion = version.substr(1);
}

return compareVersions(currentBrowserVersion, comparableVersion, isLoose) === expectedResult;
return expectedResults.indexOf(
compareVersions(currentBrowserVersion, comparableVersion, isLoose),
) > -1;
}

isOS(osName) {
Expand All @@ -483,7 +491,7 @@ <h1 class="page-title">parser.js</h1>
}

/**
* Check if any of the given values satifies this.is(anything)
* Check if any of the given values satisfies this.is(anything)
* @param {String[]} anythings
* @returns {Boolean}
*/
Expand All @@ -507,7 +515,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 Fri Oct 19 2018 19:31:53 GMT+0200 (Central European Summer Time) 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 Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
46 changes: 45 additions & 1 deletion docs/utils.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,50 @@ <h1 class="page-title">utils.js</h1>
}
}

/**
* Get Android version name
* 1.5 - Cupcake
* 1.6 - Donut
* 2.0 - Eclair
* 2.1 - Eclair
* 2.2 - Froyo
* 2.x - Gingerbread
* 3.x - Honeycomb
* 4.0 - Ice Cream Sandwich
* 4.1 - Jelly Bean
* 4.4 - KitKat
* 5.x - Lollipop
* 6.x - Marshmallow
* 7.x - Nougat
* 8.x - Oreo
* 9.x - ?
*
* @example
* getAndroidVersionName("7.0") // 'Nougat'
*
* @param {string} version
* @return {string} versionName
*/
static getAndroidVersionName(version) {
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
v.push(0);
if (v[0] === 1 &amp;&amp; v[1] &lt; 5) return undefined;
if (v[0] === 1 &amp;&amp; v[1] &lt; 6) return 'Cupcake';
if (v[0] === 1 &amp;&amp; v[1] >= 6) return 'Donut';
if (v[0] === 2 &amp;&amp; v[1] &lt; 2) return 'Eclair';
if (v[0] === 2 &amp;&amp; v[1] === 2) return 'Froyo';
if (v[0] === 2 &amp;&amp; v[1] > 2) return 'Gingerbread';
if (v[0] === 3) return 'Honeycomb';
if (v[0] === 4 &amp;&amp; v[1] &lt; 1) return 'Ice Cream Sandwich';
if (v[0] === 4 &amp;&amp; v[1] &lt; 4) return 'Jelly Bean';
if (v[0] === 4 &amp;&amp; v[1] >= 4) return 'KitKat';
if (v[0] === 5) return 'Lollipop';
if (v[0] === 6) return 'Marshmallow';
if (v[0] === 7) return 'Nougat';
if (v[0] === 8) return 'Oreo';
return undefined;
}

/**
* Get version precisions count
*
Expand Down Expand Up @@ -203,7 +247,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 Fri Oct 19 2018 19:31:53 GMT+0200 (Central European Summer Time) 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 Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class Parser {
}

/**
* Check if any of the given values satifies this.is(anything)
* Check if any of the given values satisfies this.is(anything)
* @param {String[]} anythings
* @returns {Boolean}
*/
Expand Down

0 comments on commit a87ccad

Please sign in to comment.