Options
All
  • Public
  • Public/Protected
  • All
Menu
     

Module TLS

A collection formatting functions

Index

Functions

Args

  • Args(args: arguments, from?: number): any[]
  • Pulls Array of Function arguments

    Parameters

    • args: arguments

      The Function arguments object

    • Optional from: number

      A Number to start the Array at

    Returns any[]

    An Array of Function arguments

Cnt

  • Cnt(items: any): number
  • Gets the number of properties in an Object

    Parameters

    • items: any

      An Object to count

    Returns number

    The number of properties in the Object

DT

  • DT(): string
  • Formats the current Date to a String

    Returns string

    The String-formatted Date

Insert

  • Insert(options: Object): string
  • Insert a String value if said value is truthy

    Parameters

    • options: Object

    Returns string

Hug

  • Hug(...args: args): string
  • I'll get back to you on this one.....

    Parameters

    • Rest ...args: args

    Returns string

    The formatted String?

Fill

  • Fill(val: object, def: object): object
  • Performs a deep-merge on two Objects (great for default options)

    Parameters

    • val: object

      An intial Object

      • [key: string]: any
    • def: object

      An Object of default values or mixins

      • [key: string]: any

    Returns object

    The fully merged Object

    • [key: string]: any

Format

  • Format(template: string, ...items: any): string
  • Performs a sprintf-style String formattng given a template and input items

    Parameters

    • template: string

      The string template

    • Rest ...items: any

      The items to places in the template

    Returns string

    A sprintf-formatted String

Strip

  • Strip(str: string, what: string): string
  • Strips a character or set of characters from a given String

    Parameters

    • str: string

      The String toe strip

    • what: string

      The character(s) to strip

    Returns string

    The String, minus the character(s) given

Trunc

  • Trunc(str: string, len: number): string
  • Truncates a String

    Parameters

    • str: string

      The String to truncate

    • len: number

      The maxium lenth of the String

    Returns string

    The truncated String

Tree

  • Tree(list: any[], others: string): any
  • Creates a tree Object out of a multi-dimensional Array

    Parameters

    • list: any[]

      A multi-dimensional Array

    • others: string

      A property name for single-items

    Returns any

    The tree Object

Path

  • Path(paths: string[], query: any): string
  • Formats a URI Path with Query parameters

    Parameters

    • paths: string[]

      An Array of Path

    • query: any

      An Object literal of Query parameters

    Returns string

    The formatted URI

IsIPLng

  • IsIPLng(long: string | number): boolean
  • Tests if the value is an IP Long Number

    Parameters

    • long: string | number

      The (hopefully) IP Long Number

    Returns boolean

IsIPStr

  • IsIPStr(ip: string): boolean
  • Tests if the value is a validly formatted IP Address

    Parameters

    • ip: string

      The (hopefully) IP Address (#.#.#.#)

    Returns boolean

Lng2IP

  • Lng2IP(value: string | number): string
  • Converts a IP Long Number into an IP Address. If the IP Long Number is not a String, it returns the same value

    Parameters

    • value: string | number

      The IP Long Number

    Returns string

    An IP Address (#.#.#.#)

IP2Lng

  • IP2Lng(value: string): number
  • Converts an IP Address to an IP Long Number

    Parameters

    • value: string

      An IP Address (#.#.#.#)

    Returns number

    The IP Long Number

Dec2Mac

  • Dec2Mac(dec: string): string
  • Converts a MAC Decimal String into a MAC Address

    Parameters

    • dec: string

      The MAC Decimal String

    Returns string

    A MAC Address (4F:12:CC:5D:D8:90)

Mac2Dec

  • Mac2Dec(mac: string): number
  • Converts an MAC Address to a MAC Decimal String

    Parameters

    • mac: string

      A MAC Address (4F:12:CC:5D:D8:90)

    Returns number

    The MAC Decimal String

Coalesce

  • Coalesce(val: string | number, none?: string, add?: string, insert?: string): string | number
  • Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to falsy.

    Parameters

    • val: string | number

      The value to coalesce

    • Optional none: string

      The string to use if the value is null

    • Optional add: string

      A string to append to the value

    • Optional insert: string

      A sprintf template that the value will be placed into

    Returns string | number

    The first truthy expression

Concat

  • Concat(...args: string | number): string
  • Concantenates a set of String|Number arguments (with NO delimiter)

    Parameters

    • Rest ...args: string | number

      A set of arguments to concatenate

    Returns string

    The concatenate String

ConcatD

  • ConcatD(delim: string, strings: (string | number)[]): string
  • Concantenates a set of delimited String|Number arguments

    Parameters

    • delim: string

      A set of characters to delimit the Strings|Numbers by

    • strings: (string | number)[]

      An Array of Strings|Numbers to concatenate

    Returns string

    The concatenate String

Clean

  • Clean(val: string, conds: any[]): string
  • "Cleans" a String given a set of Patterns & Replacements

    Parameters

    • val: string

      The String to "clean"

    • conds: any[]

      An Array of Find & Replace values to "clean" the String with

    Returns string

    The "clean" String

Positive

  • Positive(val: number, limit: number): number
  • Ensures a Number value is always above a given limit

    Parameters

    • val: number

      The Number value

    • limit: number

      The limit that this Number must exceed

    Returns number

    The original Number value, or the limit+1

Negative

  • Negative(val: number, limit: number): number
  • Ensures a Number value is always below a given limit

    Parameters

    • val: number

      The Number value

    • limit: number

      The limit that this Number must subceed

    Returns number

    The original Number value, or the limit-1

Compact

  • Compact(list: any[]): any[]
  • Removes all falsy elements from an Array

    Parameters

    • list: any[]

      A set of items to be compacted

    Returns any[]

    The compacted Array

RGX

  • RGX(pattern: string, fillIn: string | number | (string | number)[], options: string): RegExp
  • Creates a RegExp object for templating

    Parameters

    • pattern: string

      The template String

    • fillIn: string | number | (string | number)[]

      The key or set of keys for the template

    • options: string

      A String of RegExp modifiers

    Returns RegExp

    The template RegExp object