mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-16 15:11:50 +03:00
Fix #660 - Add new helper method: getDeviceVendor() to guess the device vendor from a model name
This commit is contained in:
2
src/helpers/ua-parser-helpers.d.ts
vendored
2
src/helpers/ua-parser-helpers.d.ts
vendored
@@ -4,12 +4,14 @@
|
||||
|
||||
import { IResult } from "../main/ua-parser";
|
||||
|
||||
declare function getDeviceVendor(model: string): string | undefined;
|
||||
declare function isAppleSilicon(res: IResult): boolean;
|
||||
declare function isChromeFamily(res: IResult): boolean;
|
||||
declare function isFrozenUA(ua: string): boolean;
|
||||
declare function isStandalonePWA(): boolean;
|
||||
|
||||
export {
|
||||
getDeviceVendor,
|
||||
isAppleSilicon,
|
||||
isChromeFamily,
|
||||
isFrozenUA,
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const { CPU, OS, Engine } = require('../enums/ua-parser-enums');
|
||||
const { UAParser } = require('../main/ua-parser');
|
||||
|
||||
const getDeviceVendor = (model) => UAParser(`Mozilla/5.0 (Linux; Android 10; ${model}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36`).device.vendor;
|
||||
|
||||
const isAppleSilicon = (res) => {
|
||||
if (res.os.is(OS.MACOS)) {
|
||||
@@ -44,6 +47,7 @@ const isStandalonePWA = () => window && (window.matchMedia('(display-mode: stand
|
||||
document.referrer.startsWith('app-info://platform/microsoft-store'));
|
||||
|
||||
module.exports = {
|
||||
getDeviceVendor,
|
||||
isAppleSilicon,
|
||||
isChromeFamily,
|
||||
isFrozenUA,
|
||||
|
||||
Reference in New Issue
Block a user