Add new helper method isChromiumBased() to check whether the current browser is a Chromium-based browser

This commit is contained in:
Faisal Salman 2023-11-09 13:41:37 +07:00
parent 7ad3e3b451
commit 7abc8b9ecc
4 changed files with 12 additions and 10 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "2.0.0-alpha.3", "version": "2.0.0-beta.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "2.0.0-alpha.3", "version": "2.0.0-beta.1",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",

View File

@ -4,8 +4,10 @@
import { IResult } from "../main/ua-parser"; 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 { export {
isAppleSilicon isAppleSilicon,
isChromiumBased
} }

View File

@ -7,14 +7,15 @@
/*jshint esversion: 6 */ /*jshint esversion: 6 */
const { CPU, OS } = require('../enums/ua-parser-enums'); const { CPU, OS, Engine } = require('../enums/ua-parser-enums');
const isAppleSilicon = function (res) { const isAppleSilicon = (res) => res.os.is(OS.MACOS) && res.cpu.is(CPU.ARM);
return res.os.is(OS.MACOS) && res.cpu.is(CPU.ARM);
} const isChromiumBased = (res) => res.engine.is(Engine.BLINK);
module.exports = { module.exports = {
isAppleSilicon isAppleSilicon,
isChromiumBased
} }
// TODO: create test // TODO: create test

View File

@ -1,4 +1,3 @@
// @ts-check
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import path from 'path'; import path from 'path';
import url from 'url'; import url from 'url';