Options
All
  • Public
  • Public/Protected
  • All
Menu

The class which contains commonly used functions by the library. These functions and variables exist in a class so they may be overridden if desired.

Hierarchy

  • Functions

Index

Methods

Static coalesce

  • coalesce(a: any, b: any, c?: any): any
  • Returns the first argument which is defined.

    Functions.coalesce(3, 4);                // 3
    Functions.coalesce(undefined, 4);        // 4
    Functions.coalesce(null, 4);             // null
    Functions.coalesce(void 0, void 0, 5);   // 5
    see

    Functions.isDefined

    Parameters

    • a: any

      The first argument to look at.

    • b: any

      The second argument to look at.

    • Optional c: any

    Returns any

    The first defined argument.

Static extend

  • extend<T>(target: T, from: T): T
  • Copies values from from object and sets them to the target object.

    Type parameters

    • T

    Parameters

    • target: T

      The object to set values to.

    • from: T

      The object to copy value references from.

    Returns T

    The reference to target.

Static isArray

  • isArray<T>(input: any): boolean
  • Determines whether the given input is an array.

    Type parameters

    • T

    Parameters

    • input: any

      The variable to test.

    Returns boolean

    true if the variable is an array, otherwise false.

Static isArrayEquals

  • isArrayEquals(x: any[], y: any[]): boolean
  • Determines whether the two arrays given are stricly equivalent. If the arrays are not the same length or contain the same values in the same order then false is returned.

    Parameters

    • x: any[]

      The first array to test.

    • y: any[]

      The second array to test.

    Returns boolean

    true if they have the same exact values, otherwise false.

Static isDefined

  • isDefined<T>(input: T | undefined): boolean
  • Determines whether the given input is defined.

    Type parameters

    • T

    Parameters

    • input: T | undefined

      The variable to test.

    Returns boolean

    true if the variable is defined, otherwise false.

Static isFrequencyValueEquals

  • isFrequencyValueEquals(input: any): boolean
  • Determines whether the given input appears to be a valid FrequencyValueEquals.

    Functions.isFrequencyValueEquals({});    // false
    Functions.isFrequencyValueEquals([]);    // false
    Functions.isFrequencyValueEquals([1]);   // false
    Functions.isFrequencyValueEquals(null);  // false
    Functions.isFrequencyValueEquals(0);     // false

    Parameters

    • input: any

      The variable to test.

    Returns boolean

    true if the variable appears to be a FrequencyValueOneOf, otherwise false.

Static isFrequencyValueEvery

  • isFrequencyValueEvery(input: any): boolean
  • Determines whether the given input appears to be a valid FrequencyValueEvery.

    Functions.isFrequencyValueEvery({});                   // false
    Functions.isFrequencyValueEvery([]);                   // false
    Functions.isFrequencyValueEvery([1]);                  // false
    Functions.isFrequencyValueEvery(null);                 // false
    Functions.isFrequencyValueEvery({every:2});            // true
    Functions.isFrequencyValueEvery({offset:1});           // false
    Functions.isFrequencyValueEvery({every:2, offset:1});  // true

    Parameters

    • input: any

      The variable to test.

    Returns boolean

    true if the variable appears to be a FrequencyValueEvery, otherwise false.

Static isFrequencyValueOneOf

  • isFrequencyValueOneOf(input: any): boolean
  • Determines whether the given input appears to be a valid FrequencyValueOneOf.

    Functions.isFrequencyValueOneOf({});    // false
    Functions.isFrequencyValueOneOf([]);    // false
    Functions.isFrequencyValueOneOf([1]);   // true
    Functions.isFrequencyValueOneOf(null);  // false

    Parameters

    • input: any

      The variable to test.

    Returns boolean

    true if the variable appears to be a FrequencyValueOneOf, otherwise false.

Static isNumber

  • isNumber(input: any): boolean
  • Determines whether the given input is a finite number (a number which is not infinite or not the result of a divide-by-zero operation).

    Parameters

    • input: any

      The variable to test.

    Returns boolean

    true if the variable is a finite number, otherwise false.

Static isObject

  • isObject<T>(input: any): boolean
  • Determines whether the given input is an object and NOT an array.

    Type parameters

    • T: object

    Parameters

    • input: any

      The variable to test.

    Returns boolean

    true if the variable is a plain object, otherwise false.

Static isString

  • isString(input: any): boolean
  • Determines whether the given input is a string.

    Parameters

    • input: any

      The variable to test.

    Returns boolean

    true if the variable is a string, otherwise false.

Static isValue

  • isValue<T>(input: T | undefined | null): boolean
  • Determines whether the given input is defined and not null.

    Type parameters

    • T

    Parameters

    • input: T | undefined | null

      The variable to test.

    Returns boolean

    true if the variable is defined and not null, otherwise false.

Static pad

  • pad(x: string, length: number, padding: string, before: boolean): string
  • Pads the string x up to length characters with the given padding optionally placing the padding before x.

    Functions.pad('hey', 5, '_', false);   // 'hey__'
    Functions.pad('hey', 5, '_', true);    // '__hey'
    Functions.pad('heyman', 5, '_', true); // 'heyman'

    Parameters

    • x: string

      The string to pad.

    • length: number

      The length to pad to.

    • padding: string

      The string to pad with.

    • before: boolean

      If the padding should go before the string to pad.

    Returns string

    The padded string if any padding needed be added.

Static padNumber

  • padNumber(x: number, length: number, first?: number): string
  • Pads the number x up to length digits where the padding is 0 and it goes before x. This function will only return the first length characters of the padding string representation of the number but can return an alternative number of first characters.

    Functions.padNumber(29, 3);      // '029'
    Functions.padNumber(29, 3, 2);   // '02'
    Functions.padNumber(9573, 3);    // '957'

    Parameters

    • x: number

      The number to pad with zeros in the beginning.

    • length: number

      The number of digits the number should be padded to.

    • Default value first: number = length

      The number of digits to return from the start of the string.

    Returns string

    A padded number.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc