1
0
mirror of https://github.com/lancedikson/bowser synced 2026-02-09 17:40:09 +00:00
This commit is contained in:
naorpeled 2026-02-07 19:59:01 +02:00
parent 02d4f94d61
commit d02ba7120a
2 changed files with 13 additions and 14 deletions

View File

@ -111,7 +111,7 @@ class Parser {
} }
const brandLower = brandName.toLowerCase(); const brandLower = brandName.toLowerCase();
return this._hints.brands.some( return this._hints.brands.some(
b => b.brand && b.brand.toLowerCase() === brandLower, (b) => b.brand && b.brand.toLowerCase() === brandLower,
); );
} }
@ -132,7 +132,7 @@ class Parser {
} }
const brandLower = brandName.toLowerCase(); const brandLower = brandName.toLowerCase();
const brand = this._hints.brands.find( const brand = this._hints.brands.find(
b => b.brand && b.brand.toLowerCase() === brandLower, (b) => b.brand && b.brand.toLowerCase() === brandLower,
); );
return brand ? brand.version : undefined; return brand ? brand.version : undefined;
} }
@ -169,7 +169,7 @@ class Parser {
} }
if (Array.isArray(_browser.test)) { if (Array.isArray(_browser.test)) {
return _browser.test.some(condition => this.test(condition)); return _browser.test.some((condition) => this.test(condition));
} }
throw new Error("Browser's test function is not valid"); throw new Error("Browser's test function is not valid");
@ -209,7 +209,6 @@ class Parser {
return this.getBrowser().name || ''; return this.getBrowser().name || '';
} }
/** /**
* Get browser's version * Get browser's version
* @return {String} version of browser * @return {String} version of browser
@ -252,7 +251,7 @@ class Parser {
} }
if (Array.isArray(_os.test)) { if (Array.isArray(_os.test)) {
return _os.test.some(condition => this.test(condition)); return _os.test.some((condition) => this.test(condition));
} }
throw new Error("Browser's test function is not valid"); throw new Error("Browser's test function is not valid");
@ -328,7 +327,7 @@ class Parser {
} }
if (Array.isArray(_platform.test)) { if (Array.isArray(_platform.test)) {
return _platform.test.some(condition => this.test(condition)); return _platform.test.some((condition) => this.test(condition));
} }
throw new Error("Browser's test function is not valid"); throw new Error("Browser's test function is not valid");
@ -379,7 +378,7 @@ class Parser {
} }
if (Array.isArray(_engine.test)) { if (Array.isArray(_engine.test)) {
return _engine.test.some(condition => this.test(condition)); return _engine.test.some((condition) => this.test(condition));
} }
throw new Error("Browser's test function is not valid"); throw new Error("Browser's test function is not valid");
@ -452,7 +451,7 @@ class Parser {
if (platformsAndOSCounter > 0) { if (platformsAndOSCounter > 0) {
const platformsAndOSNames = Object.keys(platformsAndOSes); const platformsAndOSNames = Object.keys(platformsAndOSes);
const OSMatchingDefinition = Utils.find(platformsAndOSNames, name => (this.isOS(name))); const OSMatchingDefinition = Utils.find(platformsAndOSNames, (name) => (this.isOS(name)));
if (OSMatchingDefinition) { if (OSMatchingDefinition) {
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]); const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
@ -464,7 +463,7 @@ class Parser {
const platformMatchingDefinition = Utils.find( const platformMatchingDefinition = Utils.find(
platformsAndOSNames, platformsAndOSNames,
name => (this.isPlatform(name)), (name) => (this.isPlatform(name)),
); );
if (platformMatchingDefinition) { if (platformMatchingDefinition) {
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]); const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
@ -477,7 +476,7 @@ class Parser {
if (browsersCounter > 0) { if (browsersCounter > 0) {
const browserNames = Object.keys(browsers); const browserNames = Object.keys(browsers);
const matchingDefinition = Utils.find(browserNames, name => (this.isBrowser(name, true))); const matchingDefinition = Utils.find(browserNames, (name) => (this.isBrowser(name, true)));
if (matchingDefinition !== void 0) { if (matchingDefinition !== void 0) {
return this.compareVersion(browsers[matchingDefinition]); return this.compareVersion(browsers[matchingDefinition]);
@ -585,7 +584,7 @@ class Parser {
* @returns {Boolean} * @returns {Boolean}
*/ */
some(anythings = []) { some(anythings = []) {
return anythings.some(anything => this.is(anything)); return anythings.some((anything) => this.is(anything));
} }
} }

View File

@ -79,7 +79,7 @@ export default class Utils {
* @return {string} versionName * @return {string} versionName
*/ */
static getMacOSVersionName(version) { static getMacOSVersionName(version) {
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0); const v = version.split('.').splice(0, 2).map((s) => parseInt(s, 10) || 0);
v.push(0); v.push(0);
const major = v[0]; const major = v[0];
const minor = v[1]; const minor = v[1];
@ -136,7 +136,7 @@ export default class Utils {
* @return {string} versionName * @return {string} versionName
*/ */
static getAndroidVersionName(version) { static getAndroidVersionName(version) {
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0); const v = version.split('.').splice(0, 2).map((s) => parseInt(s, 10) || 0);
v.push(0); v.push(0);
if (v[0] === 1 && v[1] < 5) return undefined; if (v[0] === 1 && v[1] < 5) return undefined;
if (v[0] === 1 && v[1] < 6) return 'Cupcake'; if (v[0] === 1 && v[1] < 6) return 'Cupcake';
@ -201,7 +201,7 @@ export default class Utils {
const _version = version + new Array(delta + 1).join('.0'); const _version = version + new Array(delta + 1).join('.0');
// 3) "9.0" -> ["000000000"", "000000009"] // 3) "9.0" -> ["000000000"", "000000009"]
return Utils.map(_version.split('.'), chunk => new Array(20 - chunk.length).join('0') + chunk).reverse(); return Utils.map(_version.split('.'), (chunk) => new Array(20 - chunk.length).join('0') + chunk).reverse();
}); });
// adjust precision for loose comparison // adjust precision for loose comparison