MindMap/frontend/node_modules/immediate
lixinran 5b73857835 Initial commit: AI思维导图生成器项目
- 基于Django + Vue.js的智能思维导图生成和管理系统
- 支持AI驱动的文档分析和可视化思维导图创建
- 包含完整的前后端代码和文档
2025-09-04 13:47:42 +08:00
..
dist Initial commit: AI思维导图生成器项目 2025-09-04 13:47:42 +08:00
lib Initial commit: AI思维导图生成器项目 2025-09-04 13:47:42 +08:00
LICENSE.txt Initial commit: AI思维导图生成器项目 2025-09-04 13:47:42 +08:00
README.md Initial commit: AI思维导图生成器项目 2025-09-04 13:47:42 +08:00
package.json Initial commit: AI思维导图生成器项目 2025-09-04 13:47:42 +08:00

README.md

immediate Build Status

npm install immediate --save

then

var immediate = require("immediate");

immediate(function () {
  // this will run soon
});

immediate(function (arg1, arg2) {
  // get your args like in iojs
}, thing1, thing2);

Introduction

immediate is a microtask library, decended from NobleJS's setImmediate, but including ideas from Cujo's When and RSVP.

immediate takes the tricks from setImmedate and RSVP and combines them with the schedualer inspired (vaugly) by whens.

Note versions 2.6.5 and earlier were strictly speaking a 'macrotask' library not a microtask one, see this for the difference, if you need a macrotask library, I got you covered.

Several new features were added in versions 3.1.0 and 3.2.0 to maintain parity with process.nextTick, but the 3.0.x series is still being kept up to date if you just need the small barebones version.

The Tricks

process.nextTick

Note that we check for actual Node.js environments, not emulated ones like those produced by browserify or similar.

MutationObserver

This is what RSVP uses, it's very fast, details on MDN.

MessageChannel

Unfortunately, postMessage has completely different semantics inside web workers, and so cannot be used there. So we turn to MessageChannel, which has worse browser support, but does work inside a web worker.

<script> onreadystatechange

For our last trick, we pull something out to make things fast in Internet Explorer versions 6 through 8: namely, creating a <script> element and firing our calls in its onreadystatechange event. This does execute in a future turn of the event loop, and is also faster than setTimeout(…, 0), so hey, why not?

Tricks we don't use

setImmediate

We avoid this process.nextTick in node is better suited to our needs and in Internet Explorer 10 there is a broken version of setImmediate we avoid using this.

In Node.js, do

npm install immediate

then

var immediate = require("immediate");

Reference and Reading