delay-promises
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Delayed Promise

Returns a Promise which can be resolved or rejected at any time.

Helpful when testing what happens between when a promise is created and when it completes.

Usage

// create a promise
let delayedPromise = createDelayedPromise()
 
// use the promise like normal
delayedPromise.then((value) => {
    console.log(value)
}).catch((reason) => {
    console.log(reason)
})
 
// then resolve the promise when you want
delayedPromise.resolve({some: 'value'})
 
// or you can reject it
delayedPromise.reject('rejecting the promise')

Typescript Support

delayed-promise is written in typescript so you don't have to install any type definitions!

let delayedPromise = createDelayedPromise<string>()
 
delayedPromise.then((value: string) => {
    console.log(value)
})
 
delayedPromise.resolve('promise resolved!')

Dependents (0)

Package Sidebar

Install

npm i delay-promises

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

5.58 kB

Total Files

8

Last publish

Collaborators

  • alanmshelly