Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "helpers"

Index

Type aliases

SimpleCompletedAction

SimpleCompletedAction: function

Describes a simple 'completed' action.

param

The occurred error.

param

The result.

Type declaration

    • (err?: any, result?: TResult): void
    • Parameters

      • Optional err: any
      • Optional result: TResult

      Returns void

Variables

nextHtmlDocId

nextHtmlDocId: number = -1

Functions

asArray

  • asArray<T>(val: T | T[]): T[]
  • Returns a value as array.

    Type parameters

    • T

    Parameters

    • val: T | T[]

      The value.

    Returns T[]

    The value as array.

cloneObject

  • cloneObject<T>(val: T): T
  • Clones an object / value deep.

    Type parameters

    • T

    Parameters

    • val: T

      The value / object to clone.

    Returns T

    The cloned value / object.

compareValues

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

    Type parameters

    • T

    Parameters

    • x: T

      The left value.

    • y: T

      The right value.

    Returns number

    The "sort value".

createSimplePromiseCompletedAction

  • createSimplePromiseCompletedAction<TResult>(resolve: function, reject?: function): SimpleCompletedAction<TResult>
  • Creates a simple 'completed' callback for a promise.

    Type parameters

    • TResult

    Parameters

    • resolve: function

      The 'succeeded' callback.

        • (value?: TResult | PromiseLike<TResult>): void
        • Parameters

          • Optional value: TResult | PromiseLike<TResult>

          Returns void

    • Optional reject: function

      The 'error' callback.

        • (reason: any): void
        • Parameters

          • reason: any

          Returns void

    Returns SimpleCompletedAction<TResult>

    The created action.

distinctArray

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

    Type parameters

    • T

    Parameters

    • arr: T[]

      The input array.

    Returns T[]

    The filtered 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 to use.

        • (item: T): U
        • Parameters

          • item: T

          Returns U

    Returns T[]

    The filtered array.

getUrlParam

  • getUrlParam(params: Object, name: string): string
  • Returns the value from a "parameter" object.

    Parameters

    • params: Object

      The object.

    • name: string

      The name of the parameter.

    Returns string

    The value of the parameter (if found).

hash

  • hash(algo: string, data: string | Buffer, asBuffer?: boolean): string | Buffer
  • Hashes data.

    Parameters

    • algo: string

      The algorithm to use.

    • data: string | Buffer
    • Default value asBuffer: boolean = false

    Returns string | Buffer

isEmptyString

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

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is empty or not.

isNullOrUndefined

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

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is (null)/(undefined) or not.

loadModule

  • loadModule<TModule>(file: string, useCache?: boolean): TModule
  • Loads a module.

    Type parameters

    • TModule

    Parameters

    • file: string

      The path of the module's file.

    • Default value useCache: boolean = false

      Use cache or not.

    Returns TModule

    The loaded module.

log

  • log(msg: any): void
  • Logs a message.

    Parameters

    • msg: any

      The message to log.

    Returns void

normalizeString

  • normalizeString(val: any, normalizer?: function): string
  • Normalizes a value as string so that is comparable.

    Parameters

    • val: any

      The value to convert.

    • Optional normalizer: function
        • (str: string): string
        • Parameters

          • str: string

          Returns string

    Returns string

    The normalized value.

open

  • open(target: string, opts?: OpenOptions): Promise<ChildProcess>
  • Opens a target.

    Parameters

    • target: string

      The target to open.

    • Optional opts: OpenOptions

    Returns Promise<ChildProcess>

openHtmlDocument

  • openHtmlDocument(storage: Document[], html: string, title?: string, id?: any): Promise<any>
  • Opens a HTML document in a new tab for a document storage.

    Parameters

    • storage: Document[]

      The storage to open for.

    • html: string

      The HTML document (source code).

    • Optional title: string
    • Optional id: any

    Returns Promise<any>

    The promise.

readHttpBody

  • readHttpBody(msg: IncomingMessage): Promise<Buffer>
  • Reads the content of the HTTP request body.

    Parameters

    • msg: IncomingMessage

      The HTTP message with the body.

    Returns Promise<Buffer>

    The promise.

removeDocuments

replaceAllStrings

  • replaceAllStrings(str: any, searchValue: any, replaceValue: any): any
  • Replaces all occurrences of a string.

    Parameters

    • str: any

      The input string.

    • searchValue: any

      The value to search for.

    • replaceValue: any

      The value to replace 'searchValue' with.

    Returns any

    The output string.

sortCommands

  • Sorts a list of commands.

    Parameters

    • pkgs: ScriptCommand[]

      The input list.

    • Optional nameProvider: sc_contracts.ValueProvider<string>

    Returns ScriptCommand[]

    The sorted list.

toArray

  • toArray<T>(arr: ArrayLike<T>, normalize?: boolean): T[]
  • Returns an array like object as new array.

    Type parameters

    • T

    Parameters

    • arr: ArrayLike<T>

      The input object.

    • Default value normalize: boolean = true

    Returns T[]

    The input object as array.

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

      The value to return if 'val' is (null) or (undefined).

    Returns boolean

    The converted value.

toStringSafe

  • toStringSafe(str: any, defValue?: any): string
  • Converts a value to a string that is NOT (null) or (undefined).

    Parameters

    • str: any

      The input value.

    • Default value defValue: any = ""

      The default value.

    Returns string

    The output value.

tryDispose

  • tryDispose(obj: vscode.Disposable): boolean
  • Tries to dispose an object.

    Parameters

    • obj: vscode.Disposable

      The object to dispose.

    Returns boolean

    Operation was successful or not.

uriParamsToObject

  • uriParamsToObject(uri: vscode.Uri): Object
  • Extracts the query parameters of an URI to an object.

    Parameters

    • uri: vscode.Uri

      The URI.

    Returns Object

    The parameters of the URI as object.

Generated using TypeDoc