Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 682 Bytes

delay.md

File metadata and controls

27 lines (21 loc) · 682 Bytes

npu.delay

async function delay(
  ms: number,
  value?: Resolvable<any>
): Promise<any | undefined>

Returns a promise that will be resolved with value (or undefined) after given ms milliseconds. If value is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the value promise. If value is a rejected promise, the resulting promise will be rejected immediately.

Example

const npu = require('native-promise-util')

;(async () => {
  await npu.delay(500)
  console.log('500 ms passed')
  await npu.delay(500)
  console.log('another 500 ms passed')
})()