From 2bc8982b428de4d0856a6756c6e1521810a917c3 Mon Sep 17 00:00:00 2001
From: Denis Demchenko Changes of the 2.0
The upcoming 2.0 version has drastically changed API. All available methods can be found in the First of all, require the library: By default, By default, In case if you don't use your own If you use bowser for Node.js, you'd better use You may need to use the source files, so they will be available in the package as well. 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: You could want to filter some particular browsers to provide any special support for them or make any workarounds.
It could look like this: 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. More of API and possibilities you will find in the
diff --git a/docs/Parser.html b/docs/Parser.html
index 40bf929..d56ee5c 100644
--- a/docs/Parser.html
+++ b/docs/Parser.html
@@ -1558,7 +1558,7 @@ like Parser#parseBrowser or Source:
undefined
when the browser is no described in the checkTree
undefined
when the browser is no described in the checkTree
diff --git a/docs/bowser.js.html b/docs/bowser.js.html
index aad1c8f..4de7f93 100644
--- a/docs/bowser.js.html
+++ b/docs/bowser.js.html
@@ -65,7 +65,7 @@ class Bowser {
* 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');
}
@@ -96,7 +96,7 @@ export default Bowser;
diff --git a/docs/global.html b/docs/global.html
index 5e2a961..e84f500 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -758,7 +758,7 @@ like "iPhone"
or "Kindle Fire HD 7"
diff --git a/docs/index.html b/docs/index.html
index efeb771..d192c10 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -59,13 +59,12 @@
docs
folder from now on and on a webpage soon.Use cases
const bowser = require('bowser');
require('bowser')
requires the ES6 version of files, which
+const bowser = require('bowser');
require('bowser')
requires the ES5 version of files, which
do not include any polyfills.babel-polyfill
you may need to have pre-built bundle with all needed polyfills.
So, for you it's suitable to require bowser like this: require('bowser/bundled')
.
As the result, you get a ES5 version of bowser with babel-polyfill
bundled together.require('bowser/es5')
,
-since source files have import
statements, which are not compatible with Node.js yet.Browser props detection
const browser = bowser.getParser(window.navigator.userAgent);
@@ -100,7 +99,7 @@ console.log(impression.userTechData);
}
}
Filtering browsers
const browser = bowser.getParsers(window.navigator.userAgent);
+
const browser = bowser.getParser(window.navigator.userAgent);
const isValidBrowser = browser.satisfies({
// declare browsers per OS
windows: {
@@ -120,6 +119,13 @@ const isValidBrowser = browser.satisfies({
chrome: ">20.1.1432",
firefox: ">31",
opera: ">22"
+
+ // also supports equality operator
+ chrome: "=20.1.1432", // will match particular build only
+
+ // and loose-equality operator
+ chrome: "~20" // will match any 20.* sub-version
+ chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
});
docs
folder.