Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Util

A collection of static utility functions, available at {@link Muxy.Util}.

example

const a = 'a string'; Muxy.Util.forceType(a, 'string');

Hierarchy

  • Util

Index

Properties

Static Optional overrideEnvironment

overrideEnvironment: Environment

Accessors

Static Environments

  • get Environments(): object

Methods

Static consolePrint

  • consolePrint prints each line of text with optional global settings and per-line console flags.

    NOTE: Twitch's CSP enforcement disallows printing to console. This function will not print anything to the console if it is running in production mode.

    since

    1.0.0

    example

    consolePrint('Hello World'); Hello World

    consolePrint('This is a box', { boxed: true }); ┌───────────────┐ | This is a box | └───────────────┘

    Parameters

    • lines: string[] | string

      A single string to output, or an array of lines of text. If lines is an array, each line will appear on its own line. If lines is a single string, it will be split on '\n'.

    • Default value options: ConsolePrintOptions = {}

      An object containing global options.

    Returns void

Static currentEnvironment

  • currentEnvironment(overrideWindow?: object): Environment
  • currentEnvironment uses the hostname and available info to determine in what environment the SDK is running. Possible values are available in Util.Environments.

    since

    1.0.0

    Parameters

    • Optional overrideWindow: object

    Returns Environment

    Returns a string representation of the current execution environment.

Static errorPromise

  • errorPromise(err: string): Promise<string>
  • Wraps a string error response in an (immediately rejected) promise.

    since

    1.0.0

    Parameters

    • err: string

      A string error that the promise will reject.

    Returns Promise<string>

    Immediately rejects the returned Promise.

Static Private eventPatternMatch

  • eventPatternMatch(input: string, pattern: string): boolean
  • Matches an input event name with a pattern. An event name is a : delimited list of terms, while a pattern is a : delimited list of terms, with an optional * instead of a term. '*' will match any term.

    since

    1.0.0

    Parameters

    • input: string

      An input event name, : delimited. Allowed characters are alpha-numeric and _

    • pattern: string

      A pattern to match against, : delimited. Allowed characters are alpha-numeric and _ and *

    Returns boolean

    Returns true if the pattern matches the input, false otherwise.

Static forceType

  • forceType(value: any, type: string): void
  • Takes a variable and a Javascript Type identifier and throws a TypeError if the variable's type is not in the provided type list. If the type check passes, the function returns without error. As a convenience, the type may also be an array of types.

    Acceptable types: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

    since

    1.0.0

    throws

    {TypeError} Throws if typeof value is not in the type list.

    Parameters

    • value: any

      Any JavaScript variable.

    • type: string

      A single type string, or an array of multiple types.

    Returns void

Static getTwitchEnvironment

  • Returns information about the current extension environment on twitch

    Returns TwitchEnvironment

Generated using TypeDoc