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

Const Entities

Entities: any = require('html-entities').AllHtmlEntities

Const IsBinaryFile

IsBinaryFile: any = require("isbinaryfile")

Const MIME

MIME: any = require('mime')

Let 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.

asBuffer

  • asBuffer(val: any, enc?: string): Buffer
  • Returns data as buffer.

    Parameters

    • val: any

      The input value.

    • Optional enc: string

    Returns Buffer

    The output value.

cleanupString

  • cleanupString(str: any, allowedChars?: any, replaceWith?: any): string
  • Cleans up a string.

    Parameters

    • str: any

      The string to cleanup.

    • Default value allowedChars: any = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"

      The allowed chars.

    • Default value replaceWith: any = ""

      The expression to use to replace non-allowed chars.

    Returns string

    The cleanup string.

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.

detectMimeByFilename

  • detectMimeByFilename(file: string, defValue?: any): string
  • Tries to detect the MIME type of a file.

    Parameters

    • file: string

      The Filename.

    • Default value defValue: any = "application/octet-stream"

      The default value.

    Returns string

    The MIME type.

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.

format

  • format(formatStr: any, ...args: any[]): string
  • Formats a string.

    Parameters

    • formatStr: any

      The value that represents the format string.

    • Rest ...args: any[]

    Returns string

    The formated string.

formatArray

  • formatArray(formatStr: any, args: any[]): string
  • Formats a string.

    Parameters

    • formatStr: any

      The value that represents the format string.

    • args: any[]

    Returns string

    The formated string.

getBase64ContentFromObjects

  • getBase64ContentFromObjects(key: string, objs: Object | Object[], compressed?: boolean): Buffer
  • Returns Base64 stored content that is stored in object(s).

    Parameters

    • key: string

      The key with the data.

    • objs: Object | Object[]

      The object(s).

    • Default value compressed: boolean = false

      Is data compressed or not.

    Returns Buffer

    The data (if found).

getHeaderValue

  • getHeaderValue(headers: any, key: string, defaultValue?: any): string
  • Tries to return a value from a "header" object.

    Parameters

    • headers: any

      The object with the header values.

    • key: string

      The key.

    • Optional defaultValue: any

    Returns string

    The value from the object.

getStateRepository

  • getStateRepository(memento: vscode.Memento, varName?: string): StateRepository
  • Returns the state repository item for a memento.

    Parameters

    • memento: vscode.Memento

      The memento.

    • Default value varName: string = rapi_contracts.VAR_STATE

    Returns StateRepository

    The item.

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).

isBinaryContent

  • isBinaryContent(data: Buffer): PromiseLike<boolean>
  • Checks if data is binary or text content.

    Parameters

    • data: Buffer

      The data to check.

    Returns PromiseLike<boolean>

    The promise.

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.

loadModuleSync

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

    Type parameters

    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): PromiseLike<ChildProcess>
  • Opens a target.

    Parameters

    • target: string

      The target to open.

    • Optional opts: OpenOptions

    Returns PromiseLike<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.

readHttpBodyAsJSON

  • readHttpBodyAsJSON<T>(msg: IncomingMessage, encoding?: string): PromiseLike<T>
  • Reads the content of the HTTP request body and returns it as parsed object.

    Type parameters

    • T

    Parameters

    • msg: IncomingMessage

      The HTTP message with the body.

    • Optional encoding: string

      The custom text encoding to use.

    Returns PromiseLike<T>

    The promise.

readHttpBodyAsString

  • readHttpBodyAsString(msg: IncomingMessage, encoding?: string): PromiseLike<string>
  • Reads the content of the HTTP request body and returns it as string.

    Parameters

    • msg: IncomingMessage

      The HTTP message with the body.

    • Optional encoding: string

      The custom text encoding to use.

    Returns PromiseLike<string>

    The promise.

removeDocuments

replaceAllStrings

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

    Parameters

    • str: string

      The input string.

    • searchValue: string

      The value to search for.

    • replaceValue: string

      The value to replace 'searchValue' with.

    Returns string

    The output string.

requireModule

  • requireModule(id: string): any
  • Loads a module from the extension context.

    Parameters

    • id: string

      The ID / path of the module.

    Returns any

    The loaded module.

setContentOfTextEditor

  • setContentOfTextEditor(editor: vscode.TextEditor, value: string): PromiseLike<vscode.TextDocument>
  • Sets the content of a text editor.

    Parameters

    • editor: vscode.TextEditor

      The text editor.

    • value: string

      The new value.

    Returns PromiseLike<vscode.TextDocument>

textDocumentToObject

  • textDocumentToObject(doc: vscode.TextDocument, user: User): PromiseLike<Object | false>
  • Converts a text document to a result object.

    Parameters

    • doc: vscode.TextDocument

      The document to convert.

    • user: User

      The user that wants to access the document.

    Returns PromiseLike<Object | false>

    The promise.

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.

toRelativePath

  • toRelativePath(path: string, baseDir?: string): string | false
  • Tries to convert a file path to a relative path.

    Parameters

    • path: string

      The path to convert.

    • Optional baseDir: string

    Returns string | false

    The relative path or (false) if not possible.

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.

toValidatorSafe

  • toValidatorSafe<T>(validator: rapi_contracts.Validator<T>): rapi_contracts.Validator<T>
  • Keeps sure to return a "validator" that is NOT (null) or (undefined).

    Type parameters

    • T

    Parameters

    • validator: rapi_contracts.Validator<T>

      The input value.

    Returns rapi_contracts.Validator<T>

    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