import browserParsersList from './parser-browsers';
-import osParsersList from './parser-os';
-import platformParsersList from './parser-platforms';
-import enginesParsersList from './parser-engines';
-import { compareVersions } from './utils';
+ import browserParsersList from './parser-browsers.js';
+import osParsersList from './parser-os.js';
+import platformParsersList from './parser-platforms.js';
+import enginesParsersList from './parser-engines.js';
+import Utils from './utils.js';
/**
* The main class that arranges the whole parsing process.
@@ -481,7 +481,7 @@ class Parser {
}
return expectedResults.indexOf(
- compareVersions(currentBrowserVersion, comparableVersion, isLoose),
+ Utils.compareVersions(currentBrowserVersion, comparableVersion, isLoose),
) > -1;
}
@@ -532,7 +532,7 @@ export default Parser;
diff --git a/docs/utils.js.html b/docs/utils.js.html
index 425f4fd..4e1bdcb 100644
--- a/docs/utils.js.html
+++ b/docs/utils.js.html
@@ -26,7 +26,7 @@
@@ -41,7 +41,7 @@
- class Utils {
+ export default class Utils {
/**
* Get first matched item for a string
* @param {RegExp} regexp
@@ -231,8 +231,6 @@
return result;
}
}
-
-module.exports = Utils;
@@ -247,7 +245,7 @@ module.exports = Utils;
diff --git a/docs/Parser.html b/docs/Parser.html index 5921b4b..cae36d6 100644 --- a/docs/Parser.html +++ b/docs/Parser.html @@ -26,7 +26,7 @@
undefined
when the browser is no described in the checkTree
diff --git a/docs/bowser.js.html b/docs/bowser.js.html index b3a4f3f..a3c551b 100644 --- a/docs/bowser.js.html +++ b/docs/bowser.js.html @@ -26,7 +26,7 @@
diff --git a/docs/global.html b/docs/global.html index 8a2650f..6b7e103 100644 --- a/docs/global.html +++ b/docs/global.html @@ -26,7 +26,7 @@
Methods
+ + + + + + +getAndroidVersionName(version) → {string}
+ + + + + + +-
+
+
+
- Source: +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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'
+
+
+
+
+ Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
version |
+
+
+ + + +string + + + + | + + + + + ++ |
Returns:
+ + +versionName
+-
+
- + Type + +
- + +string + + + +
getFirstMatch(regexp, ua) → {Array|Object|*|boolean|string}
+ + + + + + +-
+
+
+
- Source: +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Get first matched item for a string
+Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
regexp |
+
+
+ + + +RegExp + + + + | + + + + + ++ |
ua |
+
+
+ + + +String + + + + | + + + + + ++ |
Returns:
+ + + + +-
+
- + Type + +
- + +Array +| + +Object +| + +* +| + +boolean +| + +string + + + +
getSecondMatch(regexp, ua) → {Array|Object|*|boolean|string}
+ + + + + + +-
+
+
+
- Source: +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Get second matched item for a string
+Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
regexp |
+
+
+ + + | + + + + + ++ |
ua |
+
+
+ + + +String + + + + | + + + + + ++ |
Returns:
+ + + + +-
+
- + Type + +
- + +Array +| + +Object +| + +* +| + +boolean +| + +string + + + +
getVersionPrecision(version) → {number}
+ + + + + + +-
+
+
+
- Source: +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Get version precisions count
+Example
+ +getVersionPrecision("1.10.3") // 3
+
+
+
+
+ Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
version |
+
+
+ + + +string + + + + | + + + + + ++ |
Returns:
+ + + + +-
+
- + Type + +
- + +number + + + +
map(arr, iterator) → {Array}
+ + + + + + +-
+
+
+
- Source: +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Array::map polyfill
+Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
arr |
+
+
+ + + +Array + + + + | + + + + + ++ |
iterator |
+
+
+ + + +function + + + + | + + + + + ++ |
Returns:
+ + + + +-
+
- + Type + +
- + +Array + + + +
matchAndReturnConst(regexp, ua, _const) → {*}
+ + + + + + +-
+
+
+
- Source: +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Match a regexp and return a constant or undefined
+Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
regexp |
+
+
+ + + +RegExp + + + + | + + + + + ++ |
ua |
+
+
+ + + +String + + + + | + + + + + ++ |
_const |
+
+
+ + + +* + + + + | + + + + + +Any const that will be returned if regexp matches the string |
+
Returns:
+ + + + +-
+
- + Type + +
- + +* + + + +
Type Definitions
@@ -766,7 +1839,7 @@ like"iPhone"
or "Kindle Fire HD 7"
diff --git a/docs/index.html b/docs/index.html
index cf1673b..6a8be54 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -26,7 +26,7 @@
Overview
The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers.
-Changes of version 2.0
-The version 2.0 has drastically changed API. All available methods can be found in the docs
folder from now on and on a webpage soon.
⚠️ Version 2.0 breaking changes ⚠️
Version 2.0 has drastically changed the API. All available methods are on the docs page.
For legacy code, check out the 1.x branch and install it through npm install bowser@1.9.4
.
Use cases
First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.
const Bowser = require("bowser"); // CommonJS
@@ -77,15 +76,15 @@ As the result, you get a ES5 version of bowser with babel-polyfill
console.log(`The current browser name is "${browser.getBrowserName()}"`);
// The current browser name is "Internet Explorer"
or
-const impression = new Impression();
-
-const browser = Bowser.getParser(window.navigator.userAgent);
-const browserInfo = browser.getBrowser();
-impression.brName = browserInfo.name;
-impression.brVer = browserInfo.version;
or
const browser = Bowser.getParser(window.navigator.userAgent);
-impression.userTechData = browser.parse();
-console.log(impression.userTechData);
+console.log(browser.getBrowser());
+
+// outputs
+{
+ name: "Internet Explorer"
+ version: "11.0"
+}
or
+console.log(Bowser.parse(window.navigator.userAgent));
// outputs
{
@@ -155,7 +154,7 @@ Thus, you can define OS or platform specific rules and they will have more prior
diff --git a/docs/parser.js.html b/docs/parser.js.html
index 793aa17..ef5bcc6 100644
--- a/docs/parser.js.html
+++ b/docs/parser.js.html
@@ -26,7 +26,7 @@
@@ -41,11 +41,11 @@
-