3.0.0 • Published 6 months ago

@utilify/browser v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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, generating secure hashes, and more.

Installation

To install the browser utility functions, use one of the following commands, depending on your package manager:

npm install @utilify/browser
yarn add @utilify/browser
pnpm add @utilify/browser

Once 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.

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.