Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WorkerOutput

This class allow you to abstract the output for your program

You can sned output, ask for input and depending if you are in terminal It will show progress in the terminal, or send it via WebSockets or store it in a DB or in a logfile

Hierarchy

  • EventEmitter
    • WorkerOutput

Properties

currentProgress: string
groups: string[] = []
inputs: object

Type declaration

  • [key: string]: WorkerInputEmitter
interactive: boolean = false
progresses: object

Type declaration

progressesStack: string[] = []
title: string
defaultMaxListeners: number

Methods

  • addListener(event: string | symbol, listener: function): this
  • closeGroup(): void
  • emit(event: string | symbol, ...args: any[]): boolean
  • eventNames(): Array<string | symbol>
  • getMaxListeners(): number
  • incrementProgress(inc?: number, uid?: string): void
  • listenerCount(type: string | symbol): number
  • listeners(event: string | symbol): Function[]
  • logWithContext(level: WorkerLogLevel, context: any, ...args: any[]): void
  • off(event: string | symbol, listener: function): this
  • on(event: string | symbol, listener: function): this
  • once(event: string | symbol, listener: function): this
  • openGroup(name?: string): void
  • prependListener(event: string | symbol, listener: function): this
  • prependOnceListener(event: string | symbol, listener: function): this
  • rawListeners(event: string | symbol): Function[]
  • removeAllListeners(event?: string | symbol): this
  • removeListener(event: string | symbol, listener: function): this
  • requestInput(title: string, type?: WorkerInputType, regexp?: (string | RegExp)[], waitFor?: boolean, timeout?: number): Promise<string>
  • Request a user input

    Parameters

    • title: string

      of the input

    • Default value type: WorkerInputType = WorkerInputType.STRING
    • Default value regexp: (string | RegExp)[] = [/.*/]

      to validate the input

    • Default value waitFor: boolean = true

      call waitFor method

    • Default value timeout: number = 0

      before giving up on input

      Return the input request uuid if no waitFor or the input value Reject with "Request input timmeout" if timeout

    Returns Promise<string>

  • returnInput(uuid: string, value: string): void
  • Send the result of an input To be used by the listeners

    Parameters

    • uuid: string

      of input

    • value: string

      entered by user

    Returns void

  • setInteractive(interactive: boolean): void
  • setMaxListeners(n: number): this
  • setTitle(title: string): void
  • startProgress(uid: string, total: number, title?: string): void
  • updateProgress(current: number, uid?: string, title?: string): void
  • Update a progress indicator

    Parameters

    • current: number

      value

    • Default value uid: string = undefined

      id of the progress or default one

    • Default value title: string = undefined

      update title as well

    Returns void

  • waitForInput(uuid: string): Promise<string>
  • listenerCount(emitter: EventEmitter, event: string | symbol): number

Generated using TypeDoc