1
0
mirror of https://github.com/lancedikson/bowser synced 2026-02-09 17:40:09 +00:00
This commit is contained in:
Naor Peled 2026-02-07 18:07:30 +00:00 committed by GitHub
commit 6acd2b2c24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 10402 additions and 11458 deletions

View File

@ -1,11 +1,12 @@
{ {
"presets": [["@babel/preset-env", { "presets": [["@babel/preset-env", {
"useBuiltIns": "entry", "useBuiltIns": "entry",
"corejs": 3,
"modules": "cjs", "modules": "cjs",
"loose": true, "loose": true,
"targets": { "targets": {
"ie": "8", "ie": "11",
"browsers": ">2%" "browsers": ">0.25%"
} }
}]], }]],
"plugins": [ "plugins": [

View File

@ -1,4 +1,6 @@
parser: babel-eslint parserOptions:
ecmaVersion: 2020
sourceType: module
extends: airbnb-base extends: airbnb-base
rules: rules:
no-underscore-dangle: 0 no-underscore-dangle: 0

View File

@ -10,7 +10,7 @@ jobs:
strategy: strategy:
matrix: matrix:
node-version: [12.16.3] node-version: [20, 22, 24]
steps: steps:
- name: Get branch name (merge) - name: Get branch name (merge)

View File

@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 12.16.3 node-version: 20
- uses: actions/cache@v4 - uses: actions/cache@v4
with: with:
path: ~/.npm path: ~/.npm

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node: [12.16.3] node: [20, 22, 24]
name: Node ${{ matrix.node }} name: Node ${{ matrix.node }}
steps: steps:
- name: "Checkout latest code" - name: "Checkout latest code"
@ -37,7 +37,7 @@ jobs:
- name: Set up node - name: Set up node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: "16" node-version: "24"
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Run ESLint - name: Run ESLint

21764
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,36 +27,38 @@
"browser": "es5.js", "browser": "es5.js",
"module": "src/bowser.js", "module": "src/bowser.js",
"types": "index.d.ts", "types": "index.d.ts",
"engines": {
"node": ">=20"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/bowser-js/bowser.git" "url": "git+https://github.com/bowser-js/bowser.git"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.11.6", "@babel/cli": "^7.23.0",
"@babel/core": "^7.8.0", "@babel/core": "^7.23.0",
"@babel/polyfill": "^7.8.3", "@babel/preset-env": "^7.23.0",
"@babel/preset-env": "^7.8.2", "@babel/register": "^7.23.0",
"@babel/register": "^7.8.3",
"ava": "^3.0.0", "ava": "^3.0.0",
"babel-eslint": "^10.0.3", "babel-loader": "^9.1.3",
"babel-loader": "^8.0.6", "babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-add-module-exports": "^1.0.2", "babel-plugin-istanbul": "^6.1.1",
"babel-plugin-istanbul": "^6.0.0", "compression-webpack-plugin": "^10.0.0",
"compression-webpack-plugin": "^4.0.0", "core-js": "^3.33.0",
"coveralls": "^3.0.6", "coveralls": "^3.1.1",
"docdash": "^1.1.1", "docdash": "^2.0.2",
"eslint": "^6.5.1", "eslint": "^8.53.0",
"eslint-config-airbnb-base": "^13.2.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-ava": "^10.0.0", "eslint-plugin-ava": "^14.0.0",
"eslint-plugin-import": "^2.18.2", "eslint-plugin-import": "^2.29.0",
"gh-pages": "^3.0.0", "gh-pages": "^6.1.0",
"jsdoc": "^3.6.3", "jsdoc": "^4.0.2",
"nyc": "^15.0.0", "nyc": "^15.1.0",
"sinon": "^9.0.0", "sinon": "^17.0.1",
"testem": "^3.0.0", "testem": "^3.10.1",
"webpack": "^4.41.0", "webpack": "^5.89.0",
"webpack-bundle-analyzer": "^3.5.2", "webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^3.3.9", "webpack-cli": "^5.1.4",
"yamljs": "^0.3.0" "yamljs": "^0.3.0"
}, },
"ava": { "ava": {

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

View File

@ -9,7 +9,7 @@ module.exports = {
mode: 'production', // "production" | "development" | "none" mode: 'production', // "production" | "development" | "none"
// Chosen mode tells webpack to use its built-in optimizations accordingly. // Chosen mode tells webpack to use its built-in optimizations accordingly.
entry: { entry: {
bundled: ['@babel/polyfill', './src/bowser.js'], bundled: ['core-js/stable', './src/bowser.js'],
es5: './src/bowser.js', es5: './src/bowser.js',
}, // string | object | array }, // string | object | array
// defaults to ./src // defaults to ./src