Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

The utils module contains various utility interfaces and functions.

Index

Functions

combineUrl

  • combineUrl(...parts: string[]): string
  • Combines the given parts and returns them as an URL, avoiding duplicate slashes.

    Parameters

    • Rest ...parts: string[]

    Returns string

flatten

  • flatten<T>(array: T[]): T[]
  • Flattens an array of arrays of items of type T, returning a single array that consists of the concatenation of the original arrays. This is especially useful for arrays of arrays of observables since the lodash doesn't handle these correctly.

    Type parameters

    • T

    Parameters

    • array: T[]

    Returns T[]

getOrCreateMapEntry

  • getOrCreateMapEntry<T>(map: IMap<T>, key: string, initializer: function): T
  • Type parameters

    • T

    Parameters

    • map: IMap<T>
    • key: string
    • initializer: function
        • (): T
        • Returns T

    Returns T

randomUuid

  • randomUuid(): string
  • Generates a random UUID to set the ID of an element or unit to. There is no intrinsic ID collision detection/avoidance mechanism but it's good enough in practice.

    Returns string

removeFromArray

  • removeFromArray<T>(list: T[], item: T): void
  • Type parameters

    • T

    Parameters

    • list: T[]
    • item: T

    Returns void

resetAlreadyPrintedWarningsState

  • resetAlreadyPrintedWarningsState(): void
  • resets the state of remembered warnings; so that all warnings are reported again.

    Returns void

serializeToJs

  • Given a unit, generates JavaScript(/TypeScript) code that would re-create the same unit. Useful as scaffolding for model generators.

    Parameters

    Returns string

warnOnce

  • warnOnce(message: string): void
  • Prints a warning, but only if it has not been printed before

    Parameters

    • message: string

    Returns void

Generated using TypeDoc