1
0
mirror of https://github.com/lancedikson/bowser synced 2026-03-02 03:40:27 +00:00

Rebuild documentation

This commit is contained in:
Denis Demchenko
2018-07-08 12:09:27 +03:00
parent d12a988d7c
commit 3a9c4b3a3d
9 changed files with 453 additions and 203 deletions

View File

@@ -22,7 +22,7 @@
<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>
<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#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#satisfies">satisfies</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">
@@ -255,10 +255,10 @@ class Parser {
/**
* Get platform name
* @param {Boolean} toLowerCase
* @param {Boolean} [toLowerCase=false]
* @return {*}
*/
getPlatformType(toLowerCase) {
getPlatformType(toLowerCase = false) {
const { type } = this.getPlatform();
if (toLowerCase) {
@@ -360,7 +360,8 @@ class Parser {
* which can include a platform or an OS on the first layer
* and should have browsers specs on the bottom-laying layer
*
* @returns {Boolean} whether the browser satisfies the set conditions or not
* @returns {Boolean|undefined} Whether the browser satisfies the set conditions or not.
* Returns `undefined` when the browser is no described in the checkTree object.
*
* @example
* const browser = new Bowser(UA);
@@ -370,25 +371,64 @@ class Parser {
* // or with platforms
* if (browser.check({desktop: { chrome: '>118.01.1322' } }))
*/
compare(checkTree) {
const keysToProcess = Object.keys(checkTree);
return keysToProcess.some((browserAttribute) => {
const objectOrVersion = checkTree[browserAttribute];
satisfies(checkTree) {
const platformsAndOSes = {};
let platformsAndOSCounter = 0;
const browsers = {};
let browsersCounter = 0;
if (typeof objectOrVersion === 'object') {
return (this.isOs(browserAttribute) || this.isPlatform(browserAttribute))
&amp;&amp; this.compare(objectOrVersion);
const allDefinitions = Object.keys(checkTree);
allDefinitions.forEach((key) => {
const currentDefinition = checkTree[key];
if (typeof currentDefinition === 'string') {
browsers[key] = currentDefinition;
browsersCounter += 1;
} else if (typeof currentDefinition === 'object') {
platformsAndOSes[key] = currentDefinition;
platformsAndOSCounter += 1;
}
});
if (platformsAndOSCounter > 0) {
const platformsAndOSNames = Object.keys(platformsAndOSes);
const OSMatchingDefinition = platformsAndOSNames.find(name => (this.isOS(name)));
if (OSMatchingDefinition) {
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
if (osResult !== void 0) {
return osResult;
}
}
return this.isBrowser(browserAttribute) &amp;&amp; this.satisfies(objectOrVersion);
});
const platformMatchingDefinition = platformsAndOSNames.find(name => (this.isPlatform(name)));
if (platformMatchingDefinition) {
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
if (platformResult !== void 0) {
return platformResult;
}
}
}
if (browsersCounter > 0) {
const browserNames = Object.keys(browsers);
const matchingDefinition = browserNames.find(name => (this.isBrowser(name)));
if (matchingDefinition !== void 0) {
return this.compareVersion(browsers[matchingDefinition]);
}
}
return undefined;
}
isBrowser(browserName) {
return this.getBrowserName(true) === String(browserName).toLowerCase();
}
satisfies(version) {
compareVersion(version) {
let expectedResult = 0;
let comparableVersion = version;
@@ -404,7 +444,7 @@ class Parser {
return compareVersions(this.getBrowserVersion(), comparableVersion) === expectedResult;
}
isOs(osName) {
isOS(osName) {
return this.getOSName(true) === String(osName).toLowerCase();
}
@@ -419,7 +459,7 @@ class Parser {
* @returns {Boolean}
*/
is(anything) {
return this.isBrowser(anything) || this.isOs(anything) || this.isPlatform(anything);
return this.isBrowser(anything) || this.isOS(anything) || this.isPlatform(anything);
}
}
@@ -436,7 +476,7 @@ export default Parser;
<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.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Jul 08 2018 12:09:12 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>