mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Fix the docs
This commit is contained in:
parent
cab0d0d946
commit
a87ccad88a
@ -105,14 +105,14 @@ 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
|
||||
|
@ -572,7 +572,7 @@ const result = parser.getResult();</code></pre>
|
||||
<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>
|
||||
|
@ -1564,7 +1564,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
@ -2211,7 +2211,7 @@ the OS called "anything" or the platform called "anything"</
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
@ -2382,7 +2382,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
@ -2422,7 +2422,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
@ -2687,7 +2687,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
||||
<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>
|
||||
|
@ -105,7 +105,7 @@ export default Bowser;
|
||||
<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>
|
||||
|
@ -766,7 +766,7 @@ like <code>"iPhone"</code> or <code>"Kindle Fire HD 7"</code
|
||||
<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>
|
||||
|
@ -62,9 +62,10 @@
|
||||
<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("bowser"); // CommonJS
|
||||
|
||||
import * as Bowser from "bowser" // 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>
|
||||
@ -83,6 +84,7 @@ impression.brVer = browserInfo.version;</code></pre><p>or</p>
|
||||
<pre class="prettyprint source lang-javascript"><code>const browser = bowser.getParser(window.navigator.userAgent);
|
||||
impression.userTechData = browser.parse();
|
||||
console.log(impression.userTechData);
|
||||
|
||||
// outputs
|
||||
{
|
||||
browser: {
|
||||
@ -115,14 +117,14 @@ 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
|
||||
@ -134,8 +136,9 @@ const isValidBrowser = browser.satisfies({
|
||||
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>
|
||||
@ -156,7 +159,7 @@ check if all tests are still passing.</p>
|
||||
<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>
|
||||
|
@ -358,8 +358,7 @@ class Parser {
|
||||
* @return {ParsedResult}
|
||||
*/
|
||||
getResult() {
|
||||
/* TODO: Make this function pure, return a new object instead of the reference */
|
||||
return this.parsedResult;
|
||||
return Object.assign({}, this.parsedResult);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -438,7 +437,7 @@ class Parser {
|
||||
}
|
||||
|
||||
compareVersion(version) {
|
||||
let expectedResult = 0;
|
||||
let expectedResults = [0];
|
||||
let comparableVersion = version;
|
||||
let isLoose = false;
|
||||
|
||||
@ -448,12 +447,19 @@ class Parser {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
if (version[0] === '>' || version[0] === '<') {
|
||||
comparableVersion = version.substr(1);
|
||||
if (version[1] === '=') {
|
||||
isLoose = true;
|
||||
comparableVersion = version.substr(2);
|
||||
} else {
|
||||
expectedResults = [];
|
||||
}
|
||||
if (version[0] === '>') {
|
||||
expectedResult = 1;
|
||||
comparableVersion = version.substr(1);
|
||||
} else if (version[0] === '<') {
|
||||
expectedResult = -1;
|
||||
comparableVersion = version.substr(1);
|
||||
expectedResults.push(1);
|
||||
} else {
|
||||
expectedResults.push(-1);
|
||||
}
|
||||
} else if (version[0] === '=') {
|
||||
comparableVersion = version.substr(1);
|
||||
} else if (version[0] === '~') {
|
||||
@ -461,7 +467,9 @@ class Parser {
|
||||
comparableVersion = version.substr(1);
|
||||
}
|
||||
|
||||
return compareVersions(currentBrowserVersion, comparableVersion, isLoose) === expectedResult;
|
||||
return expectedResults.indexOf(
|
||||
compareVersions(currentBrowserVersion, comparableVersion, isLoose),
|
||||
) > -1;
|
||||
}
|
||||
|
||||
isOS(osName) {
|
||||
@ -483,7 +491,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}
|
||||
*/
|
||||
@ -507,7 +515,7 @@ export default Parser;
|
||||
<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>
|
||||
|
@ -94,6 +94,50 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 && v[1] < 5) return undefined;
|
||||
if (v[0] === 1 && v[1] < 6) return 'Cupcake';
|
||||
if (v[0] === 1 && v[1] >= 6) return 'Donut';
|
||||
if (v[0] === 2 && v[1] < 2) return 'Eclair';
|
||||
if (v[0] === 2 && v[1] === 2) return 'Froyo';
|
||||
if (v[0] === 2 && v[1] > 2) return 'Gingerbread';
|
||||
if (v[0] === 3) return 'Honeycomb';
|
||||
if (v[0] === 4 && v[1] < 1) return 'Ice Cream Sandwich';
|
||||
if (v[0] === 4 && v[1] < 4) return 'Jelly Bean';
|
||||
if (v[0] === 4 && 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
|
||||
*
|
||||
@ -203,7 +247,7 @@ module.exports = Utils;
|
||||
<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>
|
||||
|
@ -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}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user