Visitar URL original
GitHub - sindresorhus/set-immediate-shim: Simple `setImmediate` shim · GitHub
Skip to content

About

Simple `setImmediate` shim

Resources

Code of conduct

Contributing

Security policy

Stars

29 stars

Watchers

4 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

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()

About

Simple `setImmediate` shim

Resources

Code of conduct

Contributing

Security policy

Stars

29 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages