Options
All
  • Public
  • Public/Protected
  • All
Menu

Package promises

@typed/promises

Helpful functions for working with promises

Index

Type aliases

Functions

Type aliases

Deferred

Deferred<A>: [Promise<A>, Arity1<A, void>, Arity1<Error, void>]

An imperative promise

Type parameters

  • A

Functions

Const ap

  • ap<A, B>(fn: Promise<Arity1<A, B>>, value: Promise<A>): Promise<B>
  • Apply a fn contained in a promise to the value of a promise

    Type parameters

    • A

    • B

    Parameters

    • fn: Promise<Arity1<A, B>>

      :: Promise (a -> b)

    • value: Promise<A>

      :: Promise a

    Returns Promise<B>

    :: Promise b

Const chain

  • chain<A, B>(fn: Arity1<A, Promise<B>>, promise: Promise<A>): Promise<B>
  • Chain together multiple promises

    Type parameters

    • A

    • B

    Parameters

    • fn: Arity1<A, Promise<B>>

      :: a -> Promise b

    • promise: Promise<A>

      :: Promise a

    Returns Promise<B>

    :: Promise b

Const createDeferred

Const delay

  • delay(ms: number): Promise<void>
  • Creates a promise that waits a given number of milliseconds.

    Parameters

    • ms: number

      :: number

    Returns Promise<void>

    :: Promise void

Const map

  • map<A, B>(fn: Arity1<A, B>, promise: Promise<A>): Promise<B>
  • Map over a promise value

    Type parameters

    • A

    • B

    Parameters

    • fn: Arity1<A, B>

      :: (a -> b)

    • promise: Promise<A>

      :: Promise a

    Returns Promise<B>

    :: Promise b

Generated using TypeDoc