Skip to content

Resolve a promise with specified data after an amount of time

License

Notifications You must be signed in to change notification settings

Nicholaiii/p-after

Repository files navigation

p-after

Build Status JavaScript Style Guide

Resolve a promise with specified data after an amount of time

Useful if you want to return data after some time, for example, if you want to sequence data at varying rates.

Usage

const after = require('p-after')
(async () => {
  const result = await after(1000, 'OK')
  // After one second, the promise resolves with 'OK'. 
})

API

pAfter(when, what)

when

Type: number

The amount of time to delay returning the data.

what

Type: any

The data to return after delay.

Related

  • delay - Delay a promise a specified amount of time
  • p-min-delay - Delay an existing promise a minimum amount of time
  • p-immediate - Returns a promise resolved in the next event loop - think setImmediate()
  • p-timeout - Timeout a promise after a specified amount of time
  • More…

About

Resolve a promise with specified data after an amount of time

Resources

License

Stars

Watchers

Forks

Packages

No packages published