{"name":"immediate","description":"A polyfill for the setImmediate efficient script yielding API","version":"2.6.2","contributors":[{"name":"Domenic Denicola","email":"domenic@domenicdenicola.com","url":"http://domenicdenicola.com"},{"name":"Donavon West","email":"github@donavon.com","url":"http://donavon.com"},{"name":"Yaffle"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"}],"testling":{"files":"test/tests.js","browsers":["ie/7..latest","chrome/latest","firefox/latest","opera/11..latest","safari/latest","iphone/latest","ipad/latest","android-browser/latest"]},"license":"MIT","repository":{"type":"git","url":"git://github.com/calvinmetcalf/immediate.git"},"browser":{"./lib/nextTick.js":"./lib/fakeNextTick.js"},"bugs":{"url":"https://github.com/calvinmetcalf/immediate/issues"},"main":"lib/index.js","scripts":{"build":"npm run build-js && npm run uglify","uglify":"uglifyjs dist/immediate.js -mc > dist/immediate.min.js","build-js":"browserify -s immediate ./lib/index.js > dist/immediate.js","test":"jshint lib/*.js && node test/tests.js && browserify test/tests.js | testling"},"devDependencies":{"uglify-js":"^2.4.12","tape":"^2.10.2","jshint":"^2.4.4","testling":"^1.6.1","browserify":"^3.32.1"},"jam":{"main":"dist/immediate.js"},"homepage":"https://github.com/calvinmetcalf/immediate","_id":"immediate@2.6.2","dist":{"shasum":"989f85c2c6da4de2829bd204dfb938d5908015fd","tarball":"http://registry-npm.ywwl.com/immediate/download/immediate-2.6.2.tgz","integrity":"sha512-2uFaGV94n3SmSEge83bFzQuiN99kwL/eZkZuYMWgj+Iml/1vKOIyOs6w5rVowsbor7XnxM8C9Y8ytKTWiGN0mA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDF41AWTjwPY4mM0TVZrjjmnPhMFK8rNRkIQyOfuACDpAIhAP9hiYSBjVuZoGgoOyQZrCfqnnhClu4Gg0Y52p1Qj4yh"}],"size":6682,"noattachment":false,"key":"/immediate/-/immediate-2.6.2.tgz"},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"cwmma","email":"calvin.metcalf@gmail.com"},"maintainers":[{"name":"cwmma","email":"calvin.metcalf@gmail.com"}],"directories":{},"readme":"# immediate [![Build Status](https://travis-ci.org/calvinmetcalf/immediate.svg?branch=master)](https://travis-ci.org/calvinmetcalf/immediate)\n\n[![testling status](https://ci.testling.com/calvinmetcalf/immediate.png)](https://ci.testling.com/calvinmetcalf/immediate)\n\n```\nnpm install immediate --save\n```\n\nthen\n\n```js\nvar immediate = require(\"immediate\");\n\nimmediate(function () {\n  // this will run soon\n});\n\nimmediate(function (arg1, arg2) {\n  // get your args like in iojs\n}, thing1, thing2);\n```\n\n## Introduction\n\n**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].\n\nimmediate takes the tricks from setImmediate and RSVP and combines them with the scheduler inspired (vaguely) by when's.\n\nNote 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).\n\nSeveral new features were added in versions 3.1.0 and 3.2.0 to maintain parity with\nprocess.nextTick, but the 3.0.x series is still being kept up to date if you just need\nthe small barebones version\n\n## The Tricks\n\n### `process.nextTick`\n\nNote that we check for *actual* Node.js environments, not emulated ones like those produced by browserify or similar.\n\n### `queueMicrotask`\n\nFunction available in major browser these days which you can use to add a function into the microtask queue managed by V8.\n\n### `MutationObserver`\n\nThis is what [RSVP][RSVP] uses, it's very fast, details on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver).\n\n\n### `MessageChannel`\n\nUnfortunately, `postMessage` has completely different semantics inside web workers, and so cannot be used there. So we\nturn to [`MessageChannel`][MessageChannel], which has worse browser support, but does work inside a web worker.\n\n### `<script> onreadystatechange`\n\nFor our last trick, we pull something out to make things fast in Internet Explorer versions 6 through 8: namely,\ncreating a `<script>` element and firing our calls in its `onreadystatechange` event. This does execute in a future\nturn of the event loop, and is also faster than `setTimeout(…, 0)`, so hey, why not?\n\n## Tricks we don't use\n\n### `setImmediate`\nWe avoid using `setImmediate` because node's `process.nextTick` is better suited to our needs. Additionally, Internet Explorer 10's implementation of `setImmediate` is broken.\n\n\n## Reference and Reading\n\n * [Efficient Script Yielding W3C Editor's Draft][spec]\n * [W3C mailing list post introducing the specification][list-post]\n * [IE Test Drive demo][ie-demo]\n * [Introductory blog post by Nicholas C. Zakas][ncz]\n * I wrote a couple of blog posts on this, [part 1][my-blog-1] and [part 2][my-blog-2]\n\n[RSVP]: https://github.com/tildeio/rsvp.js\n[spec]: https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/setImmediate/Overview.html\n[list-post]: http://lists.w3.org/Archives/Public/public-web-perf/2011Jun/0100.html\n[ie-demo]: http://ie.microsoft.com/testdrive/Performance/setImmediateSorting/Default.html\n[ncz]: http://www.nczonline.net/blog/2011/09/19/script-yielding-with-setimmediate/\n[nextTick]: http://nodejs.org/docs/v0.8.16/api/process.html#process_process_nexttick_callback\n[postMessage]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#posting-messages\n[MessageChannel]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#channel-messaging\n[cross-browser-demo]: http://calvinmetcalf.github.io/setImmediate-shim-demo\n[my-blog-1]:http://calvinmetcalf.com/post/61672207151/setimmediate-etc\n[my-blog-2]:http://calvinmetcalf.com/post/61761231881/javascript-schedulers\n","publish_time":1394498115032,"_cnpm_publish_time":1394498115032,"dist-tags":{"latest":"3.3.0","lie":"3.0.5"}}