Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "Util/Util"

Index

Variables

Const TwoPI

TwoPI: number = Math.PI * 2

Two PI constant

Functions

addItemToArray

  • addItemToArray<T>(item: T, array: T[]): boolean

base64Encode

  • base64Encode(inputStr: string): string

canonicalizeAngle

  • canonicalizeAngle(angle: number): number

clamp

  • clamp(val: number, min: number, max: number): number
  • Clamps a value between a min and max inclusive

    Parameters

    • val: number
    • min: number
    • max: number

    Returns number

contains

  • contains(array: Array<any>, obj: any): boolean

extend

  • extend(deep: boolean, target: any, ...objects: any[]): any
  • extend<T1, T2>(target: T1, object2: T2): T1 & T2
  • extend<T1, T2, T3>(target: T1, object2: T2, object3: T3): T1 & T2 & T3
  • extend(target: any, ...objects: any[]): any
  • Merges one or more objects into a single target object

    Parameters

    • deep: boolean

      Whether or not to do a deep clone

    • target: any

      The target object to attach properties on

    • Rest ...objects: any[]

      The objects whose properties to merge

    Returns any

    Merged object with properties from other objects

  • Merges one or more objects into a single target object

    Type parameters

    • T1

    • T2

    Parameters

    • target: T1

      The target object to attach properties on

    • object2: T2

      The second object whose properties to merge

    Returns T1 & T2

    Merged object with properties from other objects

  • Merges one or more objects into a single target object

    Type parameters

    • T1

    • T2

    • T3

    Parameters

    • target: T1

      The target object to attach properties on

    • object2: T2

      The second object whose properties to merge

    • object3: T3

      The third object whose properties to merge

    Returns T1 & T2 & T3

    Merged object with properties from other objects

  • Merges one or more objects into a single target object

    Parameters

    • target: any

      The target object to attach properties on

    • Rest ...objects: any[]

      The objects whose properties to merge

    Returns any

    Merged object with properties from other objects

fail

  • fail(message: never): never

getOppositeSide

getPosition

  • getPosition(el: HTMLElement): Vector

getSideFromDirection

nullish

  • nullish<T>(nullishVal: T | undefined | null, defaultVal: T): T
  • Sugar that will use nullishVal if it's not null or undefined. Simulates the ?? operator

    Type parameters

    • T

    Parameters

    • nullishVal: T | undefined | null
    • defaultVal: T

    Returns T

randomInRange

  • randomInRange(min: number, max: number, random?: Random): number

randomIntInRange

  • randomIntInRange(min: number, max: number, random?: Random): number

removeItemFromArray

  • removeItemFromArray<T>(item: T, array: T[]): boolean

toDegrees

  • toDegrees(radians: number): number

toRadians

  • toRadians(degrees: number): number