Skip to content

⬅️ Back to Table of Contents

📄 is.ts

📊 Analysis Summary

Metric Count
🔧 Functions 11
📊 Variables & Constants 3

📚 Table of Contents

🛠️ File Location:

📂 packages/shared/utils/is.ts

Variables & Constants

Name Type Kind Value Exported
isClient boolean const typeof window !== 'undefined' && typeof document !== 'undefined'
isWorker boolean const typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope
toString () => string const Object.prototype.toString

Functions

isDef(val: T): val is T

Code
<T = any>(val?: T): val is T => typeof val !== 'undefined'
  • Parameters:
  • val: T
  • Return Type: val is T

notNullish(val: T | null | undefined): val is T

Code
<T = any>(val?: T | null | undefined): val is T => val != null
  • Parameters:
  • val: T | null | undefined
  • Return Type: val is T

assert(condition: boolean, infos: any[]): void

Code
(condition: boolean, ...infos: any[]) => {
  if (!condition)
    console.warn(...infos)
}
  • Parameters:
  • condition: boolean
  • infos: any[]
  • Return Type: void
  • Calls:
  • console.warn

isObject(val: any): val is object

Code
(val: any): val is object =>
  toString.call(val) === '[object Object]'
  • Parameters:
  • val: any
  • Return Type: val is object

now(): number

Code
() => Date.now()
  • Return Type: number
  • Calls:
  • Date.now

timestamp(): number

Code
() => +Date.now()
  • Return Type: number

clamp(n: number, min: number, max: number): number

Code
(n: number, min: number, max: number) => Math.min(max, Math.max(min, n))
  • Parameters:
  • n: number
  • min: number
  • max: number
  • Return Type: number
  • Calls:
  • Math.min

noop(): void

Code
() => {}
  • Return Type: void

rand(min: number, max: number): number

Code
(min: number, max: number) => {
  min = Math.ceil(min)
  max = Math.floor(max)
  return Math.floor(Math.random() * (max - min + 1)) + min
}
  • Parameters:
  • min: number
  • max: number
  • Return Type: number
  • Calls:
  • Math.ceil
  • Math.floor
  • Math.random

hasOwn(val: T, key: K): key is K

Code
<T extends object, K extends keyof T>(val: T, key: K): key is K => Object.prototype.hasOwnProperty.call(val, key)
  • Parameters:
  • val: T
  • key: K
  • Return Type: key is K
  • Calls:
  • Object.prototype.hasOwnProperty.call

getIsIOS(): boolean

Code
function getIsIOS() {
  return isClient && window?.navigator?.userAgent && (
    (/iP(?:ad|hone|od)/.test(window.navigator.userAgent))
    // The new iPad Pro Gen3 does not identify itself as iPad, but as Macintosh.
    // https://github.com/vueuse/vueuse/issues/3577
    || (window?.navigator?.maxTouchPoints > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent))
  )
}
  • Return Type: boolean
  • Calls:
  • /iP(?:ad|hone|od)/.test
  • /iPad|Macintosh/.test
  • Internal Comments:
    // The new iPad Pro Gen3 does not identify itself as iPad, but as Macintosh.
    // https://github.com/vueuse/vueuse/issues/3577