npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

set-immediate-shim

4.0.0

@sindresorhus

npmHomeRepoSnykSocket
Downloads:86783561
$ npm install set-immediate-shim
DailyWeeklyMonthlyYearly

set-immediate-shim

Simple setImmediate ponyfill

The shim uses the native setImmediate when available (Node.js), falls back to MessageChannel for better performance in environments that support it (modern browsers, Deno), and uses setTimeout with zero delay as a last resort.

Install

npm install set-immediate-shim

Usage

import setImmediateShim from 'set-immediate-shim';

setImmediateShim(() => {
	console.log('2');
});

console.log('1');

//=> 1
//=> 2

Related

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