# set-immediate-shim

> Simple setImmediate shim

Latest version **4.0.0** (published 2025-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install set-immediate-shim
pnpm add set-immediate-shim
yarn add set-immediate-shim
bun add set-immediate-shim
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2025-09-13 |
| First published | 2014-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | setimmediate, immediate, settimeout, timeout, shim, polyfill, ponyfill, messagechannel |

## Links

- npm: https://www.npmjs.com/package/set-immediate-shim
- Repository: https://github.com/sindresorhus/set-immediate-shim
- Homepage: https://github.com/sindresorhus/set-immediate-shim#readme
- Issues: https://github.com/sindresorhus/set-immediate-shim/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/set-immediate-shim

## Recent versions

- 4.0.0 (latest) — 2025-09-13
- 3.1.0 — 2024-03-12
- 3.0.0 — 2024-03-12
- 2.0.0 — 2018-03-25
- 1.0.1 — 2015-03-12
- 1.0.0 — 2014-12-29

## README

# set-immediate-shim

> Simple [`setImmediate`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate) [ponyfill](https://ponyfill.com)

The shim uses the native `setImmediate` when available (Node.js), falls back to [`MessageChannel`](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel) for better performance in environments that support it (modern browsers, Deno), and uses `setTimeout` with zero delay as a last resort.

## Install

```sh
npm install set-immediate-shim
```

## Usage

```js
import setImmediateShim from 'set-immediate-shim';

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

console.log('1');

//=> 1
//=> 2
```

## Related

- [p-immediate](https://github.com/sindresorhus/p-immediate) - Returns a promise resolved in the next event loop - think `setImmediate()`

---
_Source: https://npm.io/package/set-immediate-shim · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
