@appnroll/delay-response
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

App'n'roll

Delay response function

An async function that delays other async function to be resolved not earlier than after given time.

Install

npm install @appnroll/delay-response

# or

yarn add @appnroll/delay-response

Usage

await delayResponse(somePromise, timeInMsToResolve)

Example

const fakePromise = async () =>
  await new Promise((resolve) => {
    setTimeout(() => {
      resolve("resolved")
    }, 125)
  })

const data = await delayResponse(fakePromise, 1000)

// Console will log after 1s even though fakePromise was resolved in 125ms
console.log(data) // "resolved"

Readme

Keywords

Package Sidebar

Install

npm i @appnroll/delay-response

Weekly Downloads

121

Version

1.0.2

License

MIT

Unpacked Size

7.56 kB

Total Files

4

Last publish

Collaborators

  • michal.stasiuk
  • karszczak
  • igor.bezsmertnyi
  • warkocz