UNPKG

houser-js-utils

Version:

A comprehensive collection of TypeScript utility functions for common development tasks including array manipulation, string processing, date handling, random number generation, validation, and much more.

105 lines (104 loc) 2.86 kB
/** * @module DeviceUtils * @description A collection of utility functions for device detection and capability checking. * @example * ```typescript * import { DeviceUtils } from 'houser-js-utils'; * * // Check if running on mobile device * const isMobile = DeviceUtils.isMobile(); * * // Get device type * const deviceType = DeviceUtils.getDeviceType(); * * // Check for touch support * const hasTouch = DeviceUtils.isTouchDevice(); * ``` */ export declare const DeviceUtils: { /** * Adds a listener for online/offline status changes * @param callback - Function to call when status changes * @returns Function to remove the listener */ addOnlineStatusListener(callback: (isOnline: boolean) => void): () => void; /** * Gets the battery level of the device * @returns Promise resolving to battery level (0-1) or null if not available */ getBatteryLevel(): Promise<number | null>; /** * Gets the connection type of the device * @returns Connection type or null if not available */ getConnectionType(): string | null; /** * Gets the device type (mobile, tablet, desktop) * @returns Device type */ getDeviceType(): "mobile" | "tablet" | "desktop"; /** * Gets the number of CPU cores available * @returns Number of CPU cores */ getHardwareConcurrency(): number; /** * Gets the device language * @returns Device language */ getLanguage(): string; /** * Gets the device memory in GB * @returns Device memory or null if not available */ getMemory(): number | null; /** * Gets the device orientation * @returns Device orientation */ getOrientation(): "portrait" | "landscape"; /** * Gets the device pixel ratio * @returns Device pixel ratio */ getPixelRatio(): number; /** * Gets the device platform * @returns Device platform */ getPlatform(): string; /** * Gets the screen dimensions * @returns Object containing screen width and height */ getScreenDimensions(): { width: number; height: number; }; /** * Gets the device vendor * @returns Device vendor */ getVendor(): string; /** * Checks if a string is a valid MAC address * @param mac - MAC address to validate * @returns True if valid, false otherwise */ isMacAddress(mac: string): boolean; /** * Checks if the device is a mobile device * @returns True if mobile device */ isMobile(): boolean; /** * Checks if the device is online * @returns True if online */ isOnline(): boolean; /** * Checks if the device supports touch events * @returns True if touch is supported */ supportsTouch(): boolean; };