This package has been deprecated

Author message:

Use setTimeout from 'node:timers/promises', it is a drop-in replacement

p-after
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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…

Package Sidebar

Install

npm i p-after

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

3.58 kB

Total Files

5

Last publish

Collaborators

  • nicholai