mirror of
https://github.com/lancedikson/bowser
synced 2026-03-02 03:40:27 +00:00
feat: add the ability to use an array of versions in Parser.satisfies() (#466)
This commit is contained in:
@@ -441,7 +441,7 @@ class Parser {
|
||||
|
||||
allDefinitions.forEach((key) => {
|
||||
const currentDefinition = checkTree[key];
|
||||
if (typeof currentDefinition === 'string') {
|
||||
if (typeof currentDefinition === 'string' || Array.isArray(currentDefinition)) {
|
||||
browsers[key] = currentDefinition;
|
||||
browsersCounter += 1;
|
||||
} else if (typeof currentDefinition === 'object') {
|
||||
@@ -480,7 +480,7 @@ class Parser {
|
||||
const matchingDefinition = Utils.find(browserNames, name => (this.isBrowser(name, true)));
|
||||
|
||||
if (matchingDefinition !== void 0) {
|
||||
return this.compareVersion(browsers[matchingDefinition]);
|
||||
return this.compareVersions(browsers[matchingDefinition]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,6 +504,19 @@ class Parser {
|
||||
return browserNameLower === defaultBrowserName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if browser version equals the version or equals one of versions
|
||||
* @param {(string|string[])} versionsOrVersion versions strings array or version string
|
||||
* @returns {boolean}
|
||||
*/
|
||||
compareVersions(versionsOrVersion) {
|
||||
if (typeof versionsOrVersion === 'string') {
|
||||
return this.compareVersion(versionsOrVersion);
|
||||
}
|
||||
|
||||
return versionsOrVersion.some(version => this.compareVersion(version));
|
||||
}
|
||||
|
||||
compareVersion(version) {
|
||||
let expectedResults = [0];
|
||||
let comparableVersion = version;
|
||||
|
||||
Reference in New Issue
Block a user