Skip to content

Returns a promise resolved in the next event loop - think `setImmediate()`

License

Notifications You must be signed in to change notification settings

sindresorhus/p-immediate

Repository files navigation

p-immediate

Returns a promise resolved in the next event loop - think setImmediate()

Promises are by default resolved in a microtask (current event loop).

Install

$ npm install p-immediate

Usage

import pImmediate from 'p-immediate';

await pImmediate();

// Executed in the next event loop
console.log('🦄');

Related

  • delay - Delay a promise a specified amount of time
  • p-min-delay - Delay a promise a minimum amount of time
  • p-timeout - Timeout a promise after a specified amount of time
  • More…