mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-12-31 11:29:07 +03:00
Add new helper method: isBot() to detect whether current browser is a bot
This commit is contained in:
2
src/helpers/ua-parser-helpers.d.ts
vendored
2
src/helpers/ua-parser-helpers.d.ts
vendored
@@ -6,6 +6,7 @@ import { IResult } from "../main/ua-parser";
|
||||
|
||||
declare function getDeviceVendor(model: string): string | undefined;
|
||||
declare function isAppleSilicon(res: IResult): boolean;
|
||||
declare function isBot(res: IResult): boolean;
|
||||
declare function isChromeFamily(res: IResult): boolean;
|
||||
declare function isElectron(): boolean;
|
||||
declare function isFromEU(): boolean;
|
||||
@@ -15,6 +16,7 @@ declare function isStandalonePWA(): boolean;
|
||||
export {
|
||||
getDeviceVendor,
|
||||
isAppleSilicon,
|
||||
isBot,
|
||||
isChromeFamily,
|
||||
isElectron,
|
||||
isFromEU,
|
||||
|
||||
@@ -33,6 +33,8 @@ const isAppleSilicon = (res) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isBot = (res) => ['cli', 'crawler', 'fetcher', 'module'].includes(res.browser.type);
|
||||
|
||||
const isChromeFamily = (res) => res.engine.is(Engine.BLINK);
|
||||
|
||||
const isElectron = () => !!(process?.versions?.hasOwnProperty('electron') || // node.js
|
||||
@@ -53,6 +55,7 @@ const isStandalonePWA = () => window && (window.matchMedia('(display-mode: stand
|
||||
module.exports = {
|
||||
getDeviceVendor,
|
||||
isAppleSilicon,
|
||||
isBot,
|
||||
isChromeFamily,
|
||||
isElectron,
|
||||
isFromEU,
|
||||
|
||||
Reference in New Issue
Block a user