Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "common"

module

Contains common utility functions for Promise.

Index

Functions

delay

  • Gets a Promise that resolves after the specified time of delay.

    see

    yielded

    todo

    make this function also works in nodejs.

    Parameters

    • milliseconds: number

      non-negative time in milliseconds to wait before the returned Promise resolves.

    • Optional cancellationToken: ICancellationToken

      a token used to cancel the returned Promise.

    Returns Promise<void>

fromCancelled

  • fromCancelled<T>(): Promise<T>

fromRejected

  • fromRejected<T>(reason: any): Promise<T>
  • Gets a rejected Promise. This function behaves the same as Promise.reject.

    Type parameters

    • T

    Parameters

    • reason: any

      the rejection reason, or the Error causing the rejection.

    Returns Promise<T>

fromResolved

  • fromResolved<T>(result: T | PromiseLike<T>): Promise<T>
  • Gets a resolved Promise. This function behaves the same as Promise.resolve.

    Type parameters

    • T

    Parameters

    • result: T | PromiseLike<T>

      the result of the resolved Promise.

    Returns Promise<T>

yielded

  • yielded(): PromiseLike<void>
  • Returns a PromiseLike instance that, when used with await expression, asynchronously yields back to the code below. The instance returned behaves like the returned value of Promise.resolve().

    Note: The major difference between yielded() and delay(0), is that delay will resolve the returned Promise in a setTimeout callback, even if the delay time is 0. This will cause Promise returned by delay be resolved in marcoTask queue on some execution engine.

    see

    delay

    Returns PromiseLike<void>

Generated using TypeDoc