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

Finish Parser#_parseBrowser function

This commit is contained in:
Denis Demchenko
2017-04-09 22:09:47 +03:00
parent 9e46db26ed
commit d57094d857
3 changed files with 61 additions and 16 deletions

View File

@@ -35,12 +35,22 @@ class Parser {
_parseBrowser() {
this.parsedResult.browser = {};
const browser = browsersList.find((browser) => {
return browser.test(this);
const browser = browsersList.find(_browser => {
if (typeof _browser.test === 'function') {
return _browser.test(this);
}
if (_browser.test instanceof Array) {
return _browser.test.some((condition) => {
return this.test(condition);
});
}
throw new Error("Browser's test function is not valid");
});
if (browser) {
this.parsedResult.browser = browser.parse(this.getUA());
this.parsedResult.browser = browser.detect(this.getUA());
}
return this.parsedResult.browser;