Class TimeoutRunner<T>

TimeoutRunner for running tasks (promises) with a timeout

Please use xaa.timeout or xaa.runTimeout APIs instead.

Type Parameters

  • T

Constructors

  • constructor

    Type Parameters

    • T

    Parameters

    • maxMs: number

      number of milliseconds to allow tasks to run

    • rejectMsg: string

      message to reject with when timeout triggers

    • options: TimeoutRunnerOptions

      TimeoutRunnerOptions

    Returns TimeoutRunner<T>

Properties

ThePromise: PromiseConstructor

Promise constructor

TimeoutError: typeof TimeoutError

TimeoutError constructor

defer: Defer<T>

message to reject with when timeout triggers

error?: Error

the error if running failed

maxMs: number

number of milliseconds to allow tasks to run

rejectMsg: string

message to reject with if operation timed out

result?: T | T[]

the result from running tasks

timeout: Timeout

setTimeout handle

Methods

  • Cancel the operation and reject with msg

    Parameters

    • msg: string = "xaa TimeoutRunner operation cancelled"

      cancel message

    Returns void

  • Explicitly clear the setTimeout handle

    Returns void

  • check if runner has failed with error

    Returns boolean

    has error flag

  • check if runner has finished with result

    Returns boolean

    has result flag

  • Check if runner is done

    Returns boolean

    is done flag

  • Run tasks

    Type Parameters

    • U extends Tasks<T<T>> | Task<T>

    Parameters

    • tasks: U

      Promise or function that returns Promise, or array of them.

    Returns Promise<T | T[]>

    Promise to wait for tasks to complete, or timeout error.