Options
All
  • Public
  • Public/Protected
  • All
Menu

PromiseMap is a key-value store where the values are Promises. It allows for inspection of the state of owned Promises - whether pending, fulfilled, or rejected - as well as the ability to resolve or reject owned Promises that are pending.

Type parameters

  • K

  • V

Hierarchy

  • PromiseMap

Index

Constructors

constructor

  • new PromiseMap(timeout?: undefined | number): PromiseMap
  • Parameters

    • Optional timeout: undefined | number

      The duration, in milliseconds, to wait before deleting settled Promises.

    Returns PromiseMap

    An empty PromiseMap.

Methods

clear

  • clear(): number

delete

  • delete(key: K): boolean
  • Parameters

    • key: K

      The key of the Promise to delete.

    Returns boolean

    True if key and the matching Promise were in the owned set.

get

  • get(key: K): Promise<V>
  • If key is not in the owned set, a new Promise will be created.

    Parameters

    • key: K

      The key of the Promise to get.

    Returns Promise<V>

    The matching Promise to the key.

has

  • has(key: K): boolean
  • Parameters

    • key: K

      The key to check for membership in the owned set.

    Returns boolean

    True if this contains the requested key.

isFulfilled

  • isFulfilled(key: K): boolean
  • Parameters

    • key: K

      The key of the Promise whose status is to be queried.

    Returns boolean

    True if the key is in the owned set and the matching Promise is fulfilled.

isPending

  • isPending(key: K): boolean
  • Parameters

    • key: K

      The key of the Promise whose status is to be queried.

    Returns boolean

    True if the key is in the owned set and the matching Promise is pending.

isRejected

  • isRejected(key: K): boolean
  • Parameters

    • key: K

      The key of the Promise whose status is to be queried.

    Returns boolean

    True if the key is in the owned set and the matching Promise is rejected.

reject

  • reject(key: K, reason?: any): boolean
  • Parameters

    • key: K

      The key of the Promise to be rejected. Must be pending or not in the owned set.

    • Optional reason: any

      The reason to reject the Promise with.

    Returns boolean

    True if a new Promise was inserted.

rejectAll

  • rejectAll(reason?: any): number
  • Rejects all pending Promises that are not following another Promise.

    Parameters

    • Optional reason: any

      The reason to reject any pending Promises with.

    Returns number

    The number of rejected Promises.

resolve

  • resolve(key: K, value: V | PromiseLike<V>): boolean
  • The matching Promise to key will remain pending until value resolves. If value is a Promise-like type, the corresponding Promise will follow value. If not, the owned Promise will be fulfilled.

    Parameters

    • key: K

      The key of the Promise to be settled. Must be pending or not in the owned set.

    • value: V | PromiseLike<V>

      The value to settle the Promise to.

    Returns boolean

    True if a new Promise was inserted.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc