Socket
Socket
Sign inDemoInstall

set-immediate-shim

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    set-immediate-shim

Simple setImmediate shim


Version published
Weekly downloads
1.6M
increased by3.06%
Maintainers
1
Install size
2.89 kB
Created
Weekly downloads
 

Package description

What is set-immediate-shim?

The set-immediate-shim package provides a cross-environment implementation of `setImmediate`, a method for scheduling tasks to be executed after the current event loop tick. This is particularly useful in environments where `setImmediate` is not natively supported, such as in certain browsers or older versions of Node.js. The package ensures that developers can use `setImmediate` functionality consistently across different platforms.

What are set-immediate-shim's main functionalities?

Scheduling tasks

This feature allows you to schedule tasks to be executed after the current event loop tick. It's useful for deferring execution without resorting to `setTimeout(fn, 0)`, which can have different behaviors across environments.

require('set-immediate-shim');

setImmediate(() => {
  console.log('This runs after the current event loop tick.');
});

Other packages similar to set-immediate-shim

Readme

Source

set-immediate-shim

Simple setImmediate ponyfill

Note: This shim is quite inefficient.

Install

npm install set-immediate-shim

Usage

import setImmediateShim from 'set-immediate-shim';

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

console.log('1');

//=> 1
//=> 2
  • p-immediate - Returns a promise resolved in the next event loop - think setImmediate()

Keywords

FAQs

Last updated on 12 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc