All files / utils browser.ts

92.3% Statements 12/13
50% Branches 5/10
75% Functions 3/4
88.88% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52        94x                 94x                   94x 1x                     94x 1x                 94x 14x          
/**
 * @module Utils
 */
 
import * as MH from "@lisn/globals/minification-helpers";
 
/**
 * Returns true if the device has a touch screen.
 *
 * @category Browser info
 *
 * @since v1.2.0
 */
export const isTouchScreen = () =>
  MH.hasDOM() ? matchMedia("(any-pointer: coarse)").matches : false;
 
/**
 * Returns true if the browser supports position: sticky.
 *
 * @category Browser info
 *
 * @since v1.2.0
 */
export const supportsSticky = () =>
  MH.hasDOM()
    ? typeof CSS !== "undefined" && CSS.supports("position", "sticky")
    : false;
 
/**
 * Returns true if the page is in quirks mode.
 *
 * @category Browser info
 *
 * @since v1.2.0
 */
export const isInQuirksMode = () =>
  MH.hasDOM() ? document.compatMode === "BackCompat" : false;
 
/**
 * Returns true if the device is mobile (based on user agent).
 *
 * @category Browser info
 *
 * @since v1.2.0
 */
export const isMobile = () =>
  MH.hasDOM()
    ? MH.userAgent.match(
        /Mobile|Android|Silk\/|Kindle|BlackBerry|Opera Mini|Opera Mobi/,
      ) !== null
    : false;