1.0.2 • Published 4 years ago

@appnroll/delay-response v1.0.2

Weekly downloads
224
License
MIT
Repository
github
Last release
4 years ago

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"
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago