Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Util

Hierarchy

  • Util

Index

Properties

Static ALPHA_NUM_STR

ALPHA_NUM_STR: string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

Methods

Static IsObject

  • IsObject(obj: any): obj is Object
  • IsObject gets if a object is actually an object add not null or an array.

    Parameters

    • obj: any

      Any value to test

    Returns obj is Object

    if obj is an object and not an array, returns true; Otherwise, false

Static clone

  • clone<T>(instance: T): T
  • Clones a class with a default constructor

    see

    [[Util.DeepCopy]]

    Type parameters

    • T: {}

    Parameters

    • instance: T

      Instance of class with default constructor

    Returns T

    cloned copy of class.

Static Private createInstance

  • createInstance<T>(t: {}): T

Static deepCopy

  • deepCopy<T>(target: T): T

Static deepMerge

  • deepMerge<T>(target: T, ...sources: any[]): any
  • Merges sources into target and returns target.

    Type parameters

    • T: object

    Parameters

    • target: T

      The target to merge all sources into

    • Rest ...sources: any[]

      The sources to merge into target

      target will be overwritten. To return a new object make the target {}

      const merged = Util.DeepMerge(myTargetObj, sourceObj1, sourceObj2);
      // myTargetObj will be be equal to merged ( same object )

      or

      const merged = Util.DeepMerge({}, myTargetObj, sourceObj1, sourceObj2);

    Returns any

Static deepMergeGeneric

  • deepMergeGeneric<T, U>(target: T, ...sources: U[]): any
  • Merges sources into target and returns target. This method is the same as DeepMerge with the excption sources must be of the same type

    Type parameters

    • T: object

    • U: object

    Parameters

    • target: T

      The target to merge all sources into

    • Rest ...sources: U[]

      The sources to merge into target

      target will be overwritten. To return a new object make the target {}

      const merged = Util.DeepMergeGeneric(myTargetObj, sourceObj1, sourceObj2);
      // myTargetObj will be be equal to merged ( same object )

      or

      const merged = Util.DeepMergeGeneric({}, myTargetObj, sourceObj1, sourceObj2);

    Returns any

Static encoding

  • Gets an encoding from an input string

    Parameters

    • encoding: string

      the encoding such as ascii, utf8 to return as BufferEncoding

      If no valid match is made the utf8 will be returned. node fs file system requires a fixed string for encoding option. This menthod ensure that a valid option is returned.

    Returns BufferEncoding

Static escapeRegex

  • escapeRegex(str: string): string
  • Escapes a string for use in a regular expression

    Parameters

    • str: string

      String to escape

    Returns string

Static genAlphNumStr

  • genAlphNumStr(len: number): string
  • Generates a random alpha Numeric string

    Parameters

    • len: number

      the length of the string to generate

    Returns string

Static genAlphStr

  • genAlphStr(len: number): string
  • Generates a random alpha string

    Parameters

    • len: number

      the length of the string to generate

    Returns string

Static isEmptyOrWhiteSpace

  • isEmptyOrWhiteSpace(str: string): boolean
  • Test if a string is only white space. Multi-line string are okay to use with this method.

    Parameters

    • str: string

      string to test.

    Returns boolean

    true if str is empty or whitespace: Otherwise, false

Static isFunction

  • isFunction(obj: any): boolean
  • Test if an object is a function

    Parameters

    • obj: any

      Object to test

    Returns boolean

    true if obj is a function; Otherwise, false

Static keyValueToString

  • keyValueToString<T>(data: T, joiner?: string): string
  • Builds a string of key value pairs for an object

    Type parameters

    • T: object

    Parameters

    • data: T

      Any object that has key value pairs

    • Default value joiner: string = "; "

      The seperator between each key value pair

    Returns string

Static mergeDefaults

  • mergeDefaults<T, U>(defaults: U, ...opt: T[]): U
  • Merges two or more objects and return a new object of the same type.

    Type parameters

    • T: object

    • U: object

    Parameters

    • defaults: U

      The object that contains any key/values to replace default values

    • Rest ...opt: T[]

      The object(s) to merge with defaults

    Returns U

    an object that containg options key/values and any missing key/values that are in defaults,

    The order of the objects are passed into opt matters. Object passed in eariler will be have any properties overwritten by objects passed in laster with the same key names.

Static parseEnumLnEndOpt

  • parseEnumLnEndOpt(value: string | number, anyCase?: boolean): lnEndOpt
  • Parses a value to enum of lnEndOpt

    Parameters

    • value: string | number

      The string or number to convert into enum

    • Default value anyCase: boolean = true

      If true will match an enum value of any case; Otherwise, case must match.

    Returns lnEndOpt

    The value converted into lnEndOpt

Static parseEnumSplitByOpt

  • parseEnumSplitByOpt(value: string | number, anyCase?: boolean): splitByOpt
  • Parses a value to enum of splitByOpt

    Parameters

    • value: string | number

      The string or number to convert into enum

    • Default value anyCase: boolean = true

      If true will match an enum value of any case; Otherwise, case must match.

    Returns splitByOpt

    The value converted into splitByOpt

Static randomStr

  • randomStr(len: number, arr: string): string
  • Generates a random string

    Parameters

    • len: number

      the length of the string to generate

    • arr: string

      string of characters use to generate the the random string.

    Returns string

    A random string the length of len.

Generated using TypeDoc