# immediate [![Build Status](https://travis-ci.org/calvinmetcalf/immediate.svg?branch=master)](https://travis-ci.org/calvinmetcalf/immediate) [![testling status](https://ci.testling.com/calvinmetcalf/immediate.png)](https://ci.testling.com/calvinmetcalf/immediate) ``` npm install immediate --save ``` then ```js 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, descended from [NobleJS's setImmediate](https://github.com/NobleJS/setImmediate), but including ideas from [Cujo's When](https://github.com/cujojs/when) and [RSVP][RSVP]. immediate takes the tricks from setImmediate and RSVP and combines them with the scheduler inspired (vaguely) by when's. Note versions 2.6.5 and earlier were strictly speaking a 'macrotask' library not a microtask one, [see this for the difference](https://github.com/YuzuJS/setImmediate#macrotasks-and-microtasks), if you need a macrotask library, [I got you covered](https://github.com/calvinmetcalf/macrotask). 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. ### `queueMicrotask` Function available in major browser these days which you can use to add a function into the microtask queue managed by V8. ### `MutationObserver` This is what [RSVP][RSVP] uses, it's very fast, details on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver). ### `MessageChannel` Unfortunately, `postMessage` has completely different semantics inside web workers, and so cannot be used there. So we turn to [`MessageChannel`][MessageChannel], which has worse browser support, but does work inside a web worker. ### `