Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "geocortex/framework/utils/utils"

Index

Variables

Let activeLogSources

activeLogSources: string[]

Import this let to check the current active log sources

Const base64keyStr

base64keyStr: string

Functions

addEventListener

  • addEventListener(obj: any, type: any, listener: any): void
  • Add an event listener to an object.

    Parameters

    • obj: any

      The object to add the event listener to.

    • type: any

      The type of event to listen for.

    • listener: any

      The object that receives a notification when an event occurs.

    Returns void

alphaNumericToken

  • alphaNumericToken(length?: number): string
  • Generates a random alphanumeric token, given a length.

    Parameters

    • Optional length: number

      The length of the token to generate. If no length is provided, a default length of 8 characters is used.

    Returns string

base64Decode

  • base64Decode(input: string): string
  • Decodes a Base-64 string.

    Parameters

    • input: string

      The text input to decode.

    Returns string

base64Encode

  • base64Encode(input: string): string
  • Base-64 encodes a chunk of UTF-8 data.

    Parameters

    • input: string

      The text input to encode.

    Returns string

clamp

  • clamp(value: number, min: number, max: number): number
  • Restricts a value to be within a specified range.

    Parameters

    • value: number

      The value to clamp

    • min: number

      The minimum value. If value is less than min, min will be returned

    • max: number

      The maximum value. If value is greater than max, max will be returned

    Returns number

dateToISOStringNoMs

  • dateToISOStringNoMs(date: Date): string
  • A convenient function to get the ISO formatted date with no milliseconds OGC services require this for this TIME value in GetMap requests

    Parameters

    • date: Date

      The date to format

    Returns string

getProp

  • getProp<T>(obj: any, path: string[]): T
  • Safely attempt to get a nested property from an object without doing a long string of null checks in your code :) Pass in the object and the path to test and you will either be returned the value or 'undefined' if it does not exist Array access can form part of the path, for example: ["user", "posts", 0, "comments", 0] will attempt to access the first comment on the first post for that user.

    Type parameters

    • T

    Parameters

    • obj: any

      Any object to access a property from

    • path: string[]

      the path to the property

    Returns T

isDefined

  • isDefined(value: any): boolean
  • Parameters

    • value: any

    Returns boolean

isEmptyObject

  • isEmptyObject(obj: any): boolean
  • $.isEmptyObject returns strange positives. This tests exclusively for {}

    Parameters

    • obj: any

    Returns boolean

isInteger

  • isInteger(value: any): boolean
  • Test if a value is an integer number Official polyfill from MDN

    Parameters

    • value: any

    Returns boolean

isNullOrUndefined

  • isNullOrUndefined(value: any): boolean
  • Parameters

    • value: any

    Returns boolean

isObject

  • isObject(obj: any): boolean
  • Returns true if the passed in value is an object (not a primitive) From MDN: 'The Object constructor creates an object wrapper for the given value. If the value is null or undefined, it will create and return an empty object, otherwise, it will return an object of a type that corresponds to the given value. If the value is an object already, it will return the value.'

    Parameters

    • obj: any

    Returns boolean

isPercentage

  • isPercentage(value: string): boolean
  • Returns true if a value is a percentage value, false otherwise.

    Parameters

    • value: string

      The value being evaluated.

    Returns boolean

isUrl

  • isUrl(value: string): boolean
  • Checks whether the supplied string represents a URL.

    Parameters

    • value: string

      The value to check.

    Returns boolean

makeUrlAbsolute

  • makeUrlAbsolute(url: string): string
  • Makes a relative URL absolute.

    Parameters

    • url: string

      The URL to make absolute.

    Returns string

reverseMap

  • reverseMap(map: any): __type
  • Helper function to create a bi-directional mapping

    Parameters

    • map: any

    Returns __type

setActiveLogSources

  • setActiveLogSources(sources: string[]): void
  • Import this function to set the active log sources. The Trace functionality needs to know this for proper operation.

    Parameters

    • sources: string[]

      A string[] containing "gvh", "event", "command", "view", "time", "binding" or any combination thereof. "all" turns everything on when assigned to the array by itself

    Returns void

utf8Decode

  • utf8Decode(input: string): string
  • Decodes a UTF-8 value into its string representation.

    Parameters

    • input: string

    Returns string

utf8Encode

  • utf8Encode(s: string): string
  • Encodes a string into its UTF-8 representation.

    Parameters

    • s: string

      The string to encode.

    Returns string