Options
All
  • Public
  • Public/Protected
  • All
Menu

Module core/utils

Index

Type aliases

JSONArray

JSONArray: JSONValue[]

JSONObject

JSONObject: {}

Type declaration

JSONPrimitive

JSONPrimitive: string | number | boolean

JSONValue

Functions

generateUUIDv4

  • generateUUIDv4(): string
  • Generates a UUIDv4.

    Will provide a fallback in case crypto is not available, which makes the "uuid" package generator not work.

    Important

    This workaround is here for usage in Qt/QML environments, where crypto is not available. Bug 1688015 was opened to figure out a less hacky way to do this.

    Returns string

    A randomly generated UUIDv4.

getMonotonicNow

  • getMonotonicNow(): number
  • A helper function to get the current amount of milliseconds passed since a given time origin.

    Returns number

    The number of milliseconds since the time origin.

isBoolean

  • isBoolean(v: unknown): v is boolean
  • Checks whether or not v is a boolean.

    Parameters

    • v: unknown

      The value to verify.

    Returns v is boolean

    A special Typescript value (which compiles down to a boolean) stating whether v is a boolean.

isInteger

  • isInteger(v: unknown): v is number
  • Checks whether or not v is an integer.

    Parameters

    • v: unknown

      The value to verify.

    Returns v is number

    A special Typescript value (which compiles down to a boolean) stating whether v is a number.

isJSONValue

  • Verifies if a given value is a valid JSONValue.

    Parameters

    • v: unknown

      The value to verify

    Returns v is JSONValue

    A special Typescript value (which compiles down to a boolean) stating whether v is a valid JSONValue.

isNumber

  • isNumber(v: unknown): v is number
  • Checks whether or not v is a number.

    Parameters

    • v: unknown

      The value to verify.

    Returns v is number

    A special Typescript value (which compiles down to a boolean) stating whether v is a number.

isObject

  • isObject(v: unknown): v is Record<string | number | symbol, unknown>
  • Checks whether or not v is a simple data object.

    Parameters

    • v: unknown

      The value to verify.

    Returns v is Record<string | number | symbol, unknown>

    A special Typescript value (which compiles down to a boolean) stating whether v is a valid data object.

isString

  • isString(v: unknown): v is string
  • Checks whether or not v is a string.

    Parameters

    • v: unknown

      The value to verify.

    Returns v is string

    A special Typescript value (which compiles down to a boolean) stating whether v is a string.

isUndefined

  • isUndefined(v: unknown): v is undefined
  • Checks whether or not v is undefined.

    Parameters

    • v: unknown

      The value to verify.

    Returns v is undefined

    A special Typescript value (which compiles down to a boolean) stating whether v is undefined.

sanitizeApplicationId

  • sanitizeApplicationId(applicationId: string): string
  • Generates a pipeline-friendly string that replaces non alphanumeric characters with dashes.

    Parameters

    • applicationId: string

      The application if to sanitize.

    Returns string

    The sanitized applicaiton id.

testOnly

  • testOnly(logTag?: string): (_target: unknown, propertyKey: string, descriptor: TypedPropertyDescriptor<TestFunction>) => TypedPropertyDescriptor<TestFunction>
  • Decorator factory that will only allow a function to be called when Glean is in testing mode.

    Parameters

    • logTag: string = LOG_TAG

      The log tag of the current module.

    Returns (_target: unknown, propertyKey: string, descriptor: TypedPropertyDescriptor<TestFunction>) => TypedPropertyDescriptor<TestFunction>

    A decorator function.

      • (_target: unknown, propertyKey: string, descriptor: TypedPropertyDescriptor<TestFunction>): TypedPropertyDescriptor<TestFunction>
      • Parameters

        • _target: unknown
        • propertyKey: string
        • descriptor: TypedPropertyDescriptor<TestFunction>

        Returns TypedPropertyDescriptor<TestFunction>

truncateStringAtBoundaryWithError

  • truncateStringAtBoundaryWithError(metric: MetricType, value: string, length: number): Promise<string>
  • Truncates a string to a given max length.

    If the string required truncation, records an error through the error reporting mechanism.

    Parameters

    • metric: MetricType

      The metric to record an error to, if necessary,

    • value: string

      The string to truncate.

    • length: number

      The lenght to truncate to.

    Returns Promise<string>

    A string with at most length bytes.

validateHeader

  • validateHeader(v: string): boolean
  • Validates whether or not a given value is an acceptable HTTP header for outgoing pings.

    Parameters

    • v: string

      The value to validate.

    Returns boolean

    Whether or not the given value is a valid HTTP header value.

validateURL

  • validateURL(v: string): boolean
  • Check that a given string is a valid URL.

    Parameters

    • v: string

      The string to validate.

    Returns boolean

    Whether or not the given string is a valid url.

Generated using TypeDoc