Package Exports
- @utilify/browser
- @utilify/browser/dist/index.cjs
- @utilify/browser/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@utilify/browser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Browser Utilities
The browser utility functions provide a variety of methods for interacting with the browser environment. These functions help simplify common operations, such as checking the connection state, detecting touch devices, and more.
Installation
To install the browser utility functions, use one of the following commands, depending on your package manager:
npm install @utilify/browseryarn add @utilify/browserpnpm add @utilify/browserOnce installed, you can import the functions into your project, using either ESM or CJS.
Usage
This library supports both the ESM and CJS module systems.
import { getLanguage, getTheme, isOnline } from '@utilify/browser';const { getLanguage, getTheme, isOnline } = require('@utilify/browser');Overview
Here’s an overview of the functions available in the browser utility package:
getLanguage
function getLanguage(): string | undefined Returns the browser’s language code.
getTheme
function getTheme(): string | undefined Returns the current theme preference of the user.
isCookieEnabled
function isCookieEnabled(): boolean | undefined Checks if cookies are enabled in the browser.
isCryptoAvailable
function isCryptoAvailable(): boolean | undefined Checks if the Web Crypto API is available.
isFullscreenEnabled
function isFullscreenEnabled(): boolean | undefined Checks if fullscreen mode is enabled.
isOnline
function isOnline(): boolean | undefined Checks if the browser is online.
isTouchDevice
function isTouchDevice(): boolean | undefined Checks if the device supports touch events.
toggleFullscreen
function toggleFullscreen(elem: HTMLElement): void Toggles fullscreen mode for the given element.