Skip to content

Commit

Permalink
Add new helper method isChromiumBased() to check whether the curren…
Browse files Browse the repository at this point in the history
…t browser is a Chromium-based browser
  • Loading branch information
faisalman committed Nov 9, 2023
1 parent 7ad3e3b commit 7abc8b9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/helpers/ua-parser-helpers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 6 additions & 5 deletions src/helpers/ua-parser-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion test/playwright-test-main.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
import { test, expect } from '@playwright/test';
import path from 'path';
import url from 'url';
Expand Down

0 comments on commit 7abc8b9

Please sign in to comment.