From 7abc8b9ecc816ac30ad746cac7014a9111e6d02a Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Thu, 9 Nov 2023 13:41:37 +0700 Subject: [PATCH] Add new helper method `isChromiumBased()` to check whether the current browser is a Chromium-based browser --- package-lock.json | 4 ++-- src/helpers/ua-parser-helpers.d.ts | 6 ++++-- src/helpers/ua-parser-helpers.js | 11 ++++++----- test/playwright-test-main.spec.mjs | 1 - 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index b6c911479..2ae23f28c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ua-parser-js", - "version": "2.0.0-alpha.3", + "version": "2.0.0-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ua-parser-js", - "version": "2.0.0-alpha.3", + "version": "2.0.0-beta.1", "funding": [ { "type": "opencollective", diff --git a/src/helpers/ua-parser-helpers.d.ts b/src/helpers/ua-parser-helpers.d.ts index 6a0e5705f..4a233af13 100644 --- a/src/helpers/ua-parser-helpers.d.ts +++ b/src/helpers/ua-parser-helpers.d.ts @@ -4,8 +4,10 @@ import { IResult } from "../main/ua-parser"; -declare function isAppleSilicon(res:IResult): boolean; +declare function isAppleSilicon(res: IResult): boolean; +declare function isChromiumBased(res: IResult): boolean; export { - isAppleSilicon + isAppleSilicon, + isChromiumBased } \ No newline at end of file diff --git a/src/helpers/ua-parser-helpers.js b/src/helpers/ua-parser-helpers.js index 180c8f211..302a9e9d6 100644 --- a/src/helpers/ua-parser-helpers.js +++ b/src/helpers/ua-parser-helpers.js @@ -7,14 +7,15 @@ /*jshint esversion: 6 */ -const { CPU, OS } = require('../enums/ua-parser-enums'); +const { CPU, OS, Engine } = require('../enums/ua-parser-enums'); -const isAppleSilicon = function (res) { - return res.os.is(OS.MACOS) && res.cpu.is(CPU.ARM); -} +const isAppleSilicon = (res) => res.os.is(OS.MACOS) && res.cpu.is(CPU.ARM); + +const isChromiumBased = (res) => res.engine.is(Engine.BLINK); module.exports = { - isAppleSilicon + isAppleSilicon, + isChromiumBased } // TODO: create test \ No newline at end of file diff --git a/test/playwright-test-main.spec.mjs b/test/playwright-test-main.spec.mjs index 83e523845..982e9429f 100644 --- a/test/playwright-test-main.spec.mjs +++ b/test/playwright-test-main.spec.mjs @@ -1,4 +1,3 @@ -// @ts-check import { test, expect } from '@playwright/test'; import path from 'path'; import url from 'url';