pax_global_header 0000666 0000000 0000000 00000000064 12765376760 0014535 g ustar 00root root 0000000 0000000 52 comment=f1ccbfdf09cb93aadf77c4aa749ea554503b9234
setImmediate-1.0.5/ 0000775 0000000 0000000 00000000000 12765376760 0014152 5 ustar 00root root 0000000 0000000 setImmediate-1.0.5/.gitignore 0000664 0000000 0000000 00000000036 12765376760 0016141 0 ustar 00root root 0000000 0000000 /node_modules/
/npm-debug.log
setImmediate-1.0.5/.jshintrc 0000664 0000000 0000000 00000000630 12765376760 0015776 0 ustar 00root root 0000000 0000000 {
"camelcase": true,
"curly": true,
"eqeqeq": true,
"evil": true,
"globalstrict": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
"node": true,
"quotmark": "double",
"trailing": true,
"undef": true,
"unused": true,
"white": true,
"globals": {
"MessageChannel": false,
"self": false
}
}
setImmediate-1.0.5/LICENSE.txt 0000664 0000000 0000000 00000002117 12765376760 0015776 0 ustar 00root root 0000000 0000000 Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
setImmediate-1.0.5/README.md 0000664 0000000 0000000 00000012553 12765376760 0015437 0 ustar 00root root 0000000 0000000 # setImmediate.js
**A YuzuJS production**
## Introduction
**setImmediate.js** is a highly cross-browser implementation of the `setImmediate` and `clearImmediate` APIs, [proposed][spec] by Microsoft to the Web Performance Working Group. `setImmediate` allows scripts to yield to the browser, executing a given operation asynchronously, in a manner that is typically more efficient and consumes less power than the usual `setTimeout(..., 0)` pattern.
setImmediate.js runs at “full speed” in the following browsers and environments, using various clever tricks:
* Internet Explorer 6+
* Firefox 3+
* WebKit
* Opera 9.5+
* Node.js
* Web workers in browsers that support `MessageChannel`, which I can't find solid info on.
In all other browsers we fall back to using `setTimeout`, so it's always safe to use.
## Macrotasks and Microtasks
The `setImmediate` API, as specified, gives you access to the environment's [task queue][], sometimes known as its "macrotask" queue. This is crucially different from the [microtask queue][] used by web features such as `MutationObserver`, language features such as promises and `Object.observe`, and Node.js features such as `process.nextTick`. Each go-around of the macrotask queue yields back to the event loop once all queued tasks have been processed, even if the macrotask itself queued more macrotasks. Whereas, the microtask queue will continue executing any queued microtasks until it is exhausted.
In practice, what this means is that if you call `setImmediate` inside of another task queued with `setImmediate`, you will yield back to the event loop and any I/O or rendering tasks that need to take place between those calls, instead of executing the queued task as soon as possible.
If you are looking specifically to yield as part of a render loop, consider using [`requestAnimationFrame`][raf]; if you are looking solely for the control-flow ordering effects, use a microtask solution such as [asap][].
## The Tricks
### `process.nextTick`
In Node.js versions below 0.9, `setImmediate` is not available, but [`process.nextTick`][nextTick] is—and in those versions, `process.nextTick` uses macrotask semantics. So, we use it to shim support for a global `setImmediate`.
In Node.js 0.9 and above, `process.nextTick` moved to microtask semantics, but `setImmediate` was introduced with macrotask semantics, so there's no need to polyfill anything.
Note that we check for *actual* Node.js environments, not emulated ones like those produced by browserify or similar. Such emulated environments often already include a `process.nextTick` shim that's not as browser-compatible as setImmediate.js.
### `postMessage`
In Firefox 3+, Internet Explorer 9+, all modern WebKit browsers, and Opera 9.5+, [`postMessage`][postMessage] is available and provides a good way to queue tasks on the event loop. It's quite the abuse, using a cross-document messaging protocol within the same document simply to get access to the event loop task queue, but until there are native implementations, this is the best option.
Note that Internet Explorer 8 includes a synchronous version of `postMessage`. We detect this, or any other such synchronous implementation, and fall back to another trick.
### `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.
### `