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

Change Parser.check to Parser.compare

This commit is contained in:
Denis Demchenko
2018-07-04 22:43:57 +03:00
parent 0c1564f1cd
commit 48638e7363
3 changed files with 12 additions and 11 deletions

View File

@@ -285,6 +285,7 @@ class Parser {
}
getResult() {
/* TODO: Make this function pure, return a new object instead of the reference */
return this.parsedResult;
}
@@ -303,14 +304,14 @@ class Parser {
* // or with platforms
* if (browser.check({desktop: { chrome: '>118.01.1322' } }))
*/
check(checkTree) {
compare(checkTree) {
const keysToProcess = Object.keys(checkTree);
return keysToProcess.some((browserAttribute) => {
const objectOrVersion = checkTree[browserAttribute];
if (typeof objectOrVersion === 'object') {
return (this.isOs(browserAttribute) || this.isPlatform(browserAttribute))
&& this.check(objectOrVersion);
&& this.compare(objectOrVersion);
}
return this.isBrowser(browserAttribute) && this.satisfies(objectOrVersion);