Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Promise<T>

Type parameters

  • T

Hierarchy

  • Promise

Index

Properties

Methods

Properties

__@toStringTag

__@toStringTag: "Promise"

Methods

catch

  • catch(onrejected?: function | undefined | null): Promise<T>
  • catch<TResult>(onrejected: function): Promise<T | TResult>
  • catch<TResult>(errorName: string, onrejected: function): Promise<T | TResult>
  • catch(errorName: string, onrejected: function): Promise<T>
  • catch<TResult, TError>(errorConstructor: object, onrejected: function): Promise<T | TResult>
  • catch<TError>(errorConstructor: object, onrejected: function): Promise<T>
  • Parameters

    • Optional onrejected: function | undefined | null

    Returns Promise<T>

  • Type parameters

    • TResult

    Parameters

    • onrejected: function
        • (reason: any): TResult | PromiseLike<TResult>
        • Parameters

          • reason: any

          Returns TResult | PromiseLike<TResult>

    Returns Promise<T | TResult>

  • Catch errors where error => error.name === errorName. Other errors will remain uncaught.

    Type parameters

    • TResult

    Parameters

    • errorName: string

      Name of the type of error to catch such as 'RangeError', 'TypeError', 'DatabaseClosedError', etc.

    • onrejected: function

      The callback to execute when the Promise is rejected.

        • (reason: Error): TResult | PromiseLike<TResult>
        • Parameters

          • reason: Error

          Returns TResult | PromiseLike<TResult>

    Returns Promise<T | TResult>

    A Promise for the completion of the callback.

  • Catch errors where error => error.name === errorName. Other errors will remain uncaught.

    Parameters

    • errorName: string

      Name of the type of error to catch such as 'RangeError', 'TypeError', 'DatabaseClosedError', etc.

    • onrejected: function

      The callback to execute when the Promise is rejected.

        • (reason: Error): T | PromiseLike<T>
        • Parameters

          • reason: Error

          Returns T | PromiseLike<T>

    Returns Promise<T>

    A Promise for the completion of the callback.

  • Catch errors where error => error instanceof errorConstructor. Other errors will remain uncaught.

    Type parameters

    • TResult

    • TError

    Parameters

    • errorConstructor: object

      Type of error to catch such as RangeError, TypeError, etc.

      • constructor: function
        • new __type(): TError
        • Returns TError

    • onrejected: function

      The callback to execute when the Promise is rejected.

        • (reason: TError): TResult | PromiseLike<TResult>
        • Parameters

          • reason: TError

          Returns TResult | PromiseLike<TResult>

    Returns Promise<T | TResult>

    A Promise for the completion of the callback.

  • Catch errors where error => error instanceof errorConstructor. Other errors will remain uncaught.

    Type parameters

    • TError

    Parameters

    • errorConstructor: object

      Type of error to catch such as RangeError, TypeError, etc.

      • constructor: function
        • new __type(): TError
        • Returns TError

    • onrejected: function

      The callback to execute when the Promise is rejected.

        • (reason: TError): T | PromiseLike<T>
        • Parameters

          • reason: TError

          Returns T | PromiseLike<T>

    Returns Promise<T>

    A Promise for the completion of the callback.

finally

  • finally(onFinally: function): Promise<T>
  • Attaches a callback to be executed when promise is settled no matter if it was rejected or resolved.

    Parameters

    • onFinally: function

      The callback to execute when promise is settled.

        • (): void
        • Returns void

    Returns Promise<T>

    A Promise for the completion of the callback.

then

  • then(onfulfilled?: function | undefined | null, onrejected?: function | undefined | null): Promise<T>
  • then<TResult>(onfulfilled: function | undefined | null, onrejected: function): Promise<T | TResult>
  • then<TResult>(onfulfilled: function, onrejected?: function | undefined | null): Promise<TResult>
  • then<TResult1, TResult2>(onfulfilled: function, onrejected: function): Promise<TResult1 | TResult2>
  • Parameters

    • Optional onfulfilled: function | undefined | null
    • Optional onrejected: function | undefined | null

    Returns Promise<T>

  • Type parameters

    • TResult

    Parameters

    • onfulfilled: function | undefined | null
    • onrejected: function
        • (reason: any): TResult | PromiseLike<TResult>
        • Parameters

          • reason: any

          Returns TResult | PromiseLike<TResult>

    Returns Promise<T | TResult>

  • Type parameters

    • TResult

    Parameters

    • onfulfilled: function
        • (value: T): TResult | PromiseLike<TResult>
        • Parameters

          • value: T

          Returns TResult | PromiseLike<TResult>

    • Optional onrejected: function | undefined | null

    Returns Promise<TResult>

  • Type parameters

    • TResult1

    • TResult2

    Parameters

    • onfulfilled: function
        • (value: T): TResult1 | PromiseLike<TResult1>
        • Parameters

          • value: T

          Returns TResult1 | PromiseLike<TResult1>

    • onrejected: function
        • (reason: any): TResult2 | PromiseLike<TResult2>
        • Parameters

          • reason: any

          Returns TResult2 | PromiseLike<TResult2>

    Returns Promise<TResult1 | TResult2>

timeout

  • timeout(milliseconds: number): Promise<T>
  • Apply a timeout limit for the promise. If timeout is reached before promise is settled, the returned promise will reject with an Error object where name='TimeoutError'.

    Parameters

    • milliseconds: number

      Number of milliseconds for the timeout.

    Returns Promise<T>

    A Promise that will resolve or reject identically to current Promise, but if timeout is reached, it will reject with TimeoutError.

Made by Horyus. Documentation generated by TypeDoc.