Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/helpers"

Index

Variables

MergeDeep

MergeDeep: any = require('merge-deep')

Functions

asArray

  • asArray<T>(val: T | T[], removeEmpty?: boolean): T[]
  • Converts an input value to an array.

    Type parameters

    • T

    Parameters

    • val: T | T[]

      The input value.

    • Default value removeEmpty: boolean = true

    Returns T[]

    The value as array.

compareValues

  • compareValues<T>(x: T, y: T): number
  • Compares two values for sort operations.

    Type parameters

    • T

    Parameters

    • x: T

      The left value.

    • y: T

      The right value.

    Returns number

    The comparer value.

compareValuesBy

  • compareValuesBy<T, U>(x: T, y: T, selector: function): number
  • Compares two values for sort operations by using a selector.

    Type parameters

    • T

    • U

    Parameters

    • x: T

      The left value.

    • y: T

      The right value.

    • selector: function

      The selector to use.

        • (item: T): U
        • Parameters

          • item: T

          Returns U

    Returns number

    The comparer value.

distinctArray

  • distinctArray<T>(arr: T[]): T[]
  • Removes duplicate entries from an array.

    Type parameters

    • T

    Parameters

    • arr: T[]

      The input array.

    Returns T[]

    The distincted array.

distinctArrayBy

  • distinctArrayBy<T, U>(arr: T[], selector: function): T[]
  • Removes duplicate entries from an array by using a selector.

    Type parameters

    • T

    • U

    Parameters

    • arr: T[]

      The input array.

    • selector: function

      The selector.

        • (item: T): U
        • Parameters

          • item: T

          Returns U

    Returns T[]

    The distincted array.

exists

  • exists(path: FS.PathLike): Promise<boolean>
  • Promise version of 'FS.exists()' function.

    Parameters

    • path: FS.PathLike

      The path.

    Returns Promise<boolean>

    The promise that indicates if item exists or not.

glob

  • glob(pattern: string, options?: Glob.IOptions): Promise<string[]>
  • Promise version of 'Glob()' function.

    Parameters

    • pattern: string

      The pattern.

    • Optional options: Glob.IOptions

    Returns Promise<string[]>

    The promise with the matches.

globSync

  • globSync(pattern: string, options?: Glob.IOptions): string[]
  • s. 'Glob.sync()'

    Parameters

    • pattern: string

      The pattern.

    • Optional options: Glob.IOptions

    Returns string[]

    The matches.

isBool

  • isBool(val: any): boolean
  • Checks if a value is a boolean.

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is boolean.

isEmptyString

  • isEmptyString(val: any): boolean
  • Checks if the string representation of a value is an empty string or contains whitespaces only.

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is empty string or not.

isFunc

  • isFunc<TFunc>(val: any): boolean
  • Checks if a value is a function.

    Type parameters

    • TFunc: Function

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is function.

isNullOrUndefined

  • isNullOrUndefined(val: any): boolean
  • Checks if a value is (null) or (undefined).

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is (null) or (undefined).

isNumber

  • isNumber(val: any): boolean
  • Checks if a value is a number.

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is number.

isObj

  • isObj<TObj>(val: any): boolean
  • Checks if a value is an object.

    Type parameters

    • TObj: Object

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is object.

isString

  • isString(val: any): boolean
  • Checks if a value is a string.

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is string.

isSymbol

  • isSymbol<TSymbol>(val: any): boolean
  • Checks if a value is a symbol.

    Type parameters

    • TSymbol: Symbol

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is symbol.

normalizeString

  • normalizeString(val: any): string
  • Normalizes a value to a string for comparison.

    Parameters

    • val: any

      The value to normalize.

    Returns string

    The normalized value.

pushMany

  • pushMany<T>(arr: T[], items: T[]): void
  • Pushes a list of items to an array.

    Type parameters

    • T

    Parameters

    • arr: T[]

      The array to push to.

    • items: T[]

      The items to push.

    Returns void

readFile

  • readFile(path: FS.PathLike | number): Promise<Buffer>
  • Promise version of 'FS.readFile()' function.

    Parameters

    • path: FS.PathLike | number

      The path or descriptor to the file.

    Returns Promise<Buffer>

    The promise with the read data.

replaceAll

  • replaceAll(val: any, searchFor: any, replaceWith: any): string
  • Handles a value as string and replaces all sub strings with another string.

    Parameters

    • val: any

      The input value.

    • searchFor: any

      The value to search for.

    • replaceWith: any

      The value to replace 'searchFor' with.

    Returns string

    The new value.

toBooleanSafe

  • toBooleanSafe(val: any, defaultValue?: any): boolean
  • Converts a value to a boolean.

    Parameters

    • val: any

      The value to convert.

    • Default value defaultValue: any = false

    Returns boolean

    The converted value.

toStringSafe

  • toStringSafe(val: any, defaultValue?: any): string
  • Converts a value to a string.

    Parameters

    • val: any

      The value to convert.

    • Default value defaultValue: any = ""

    Returns string

    The converted value.

write

  • write(msg: any, stream?: WritableStream): void
  • Writes a message to a stream.

    Parameters

    • msg: any

      The message to write.

    • Optional stream: WritableStream

    Returns void

writeFile

  • writeFile(path: FS.PathLike | number, data: any, encoding?: string): Promise<void>
  • Promise version of 'FS.writeFile()' function.

    Parameters

    • path: FS.PathLike | number

      The path or descriptor to the file.

    • data: any

      The data to write.

    • Optional encoding: string

    Returns Promise<void>

    The promise with the read data.

write_err

  • write_err(msg: any): void
  • Writes a message to stderr.

    Parameters

    • msg: any

      The message to write.

    Returns void

write_err_ln

  • write_err_ln(msg?: any): void
  • Writes an optional message to stderr and appends a new line.

    Parameters

    • Optional msg: any

    Returns void

write_ln

  • write_ln(msg?: any, stream?: WritableStream): void
  • Writes an optional message to a stream and appends a new line.

    Parameters

    • Optional msg: any
    • Optional stream: WritableStream

    Returns void

Generated using TypeDoc