08-27-周三_17-09-29
This commit is contained in:
20
node_modules/asap/LICENSE.md
generated
vendored
Normal file
20
node_modules/asap/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
Copyright 2009–2013 Contributors. All rights reserved.
|
||||
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.
|
||||
|
81
node_modules/asap/README.md
generated
vendored
Normal file
81
node_modules/asap/README.md
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
# ASAP
|
||||
|
||||
This `asap` CommonJS package contains a single `asap` module that
|
||||
exports a single `asap` function that executes a function **as soon as
|
||||
possible**.
|
||||
|
||||
```javascript
|
||||
asap(function () {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
More formally, ASAP provides a fast event queue that will execute tasks
|
||||
until it is empty before yielding to the JavaScript engine's underlying
|
||||
event-loop. When the event queue becomes non-empty, ASAP schedules a
|
||||
flush event, preferring for that event to occur before the JavaScript
|
||||
engine has an opportunity to perform IO tasks or rendering, thus making
|
||||
the first task and subsequent tasks semantically indistinguishable.
|
||||
ASAP uses a variety of techniques to preserve this invariant on
|
||||
different versions of browsers and NodeJS.
|
||||
|
||||
By design, ASAP can starve the event loop on the theory that, if there
|
||||
is enough work to be done synchronously, albeit in separate events, long
|
||||
enough to starve input or output, it is a strong indicator that the
|
||||
program needs to push back on scheduling more work.
|
||||
|
||||
Take care. ASAP can sustain infinite recursive calls indefinitely
|
||||
without warning. This is behaviorally equivalent to an infinite loop.
|
||||
It will not halt from a stack overflow, but it *will* chew through
|
||||
memory (which is an oddity I cannot explain at this time). Just as with
|
||||
infinite loops, you can monitor a Node process for this behavior with a
|
||||
heart-beat signal. As with infinite loops, a very small amount of
|
||||
caution goes a long way to avoiding problems.
|
||||
|
||||
```javascript
|
||||
function loop() {
|
||||
asap(loop);
|
||||
}
|
||||
loop();
|
||||
```
|
||||
|
||||
ASAP is distinct from `setImmediate` in that it does not suffer the
|
||||
overhead of returning a handle and being possible to cancel. For a
|
||||
`setImmediate` shim, consider [setImmediate][].
|
||||
|
||||
[setImmediate]: https://github.com/noblejs/setimmediate
|
||||
|
||||
If a task throws an exception, it will not interrupt the flushing of
|
||||
high-priority tasks. The exception will be postponed to a later,
|
||||
low-priority event to avoid slow-downs, when the underlying JavaScript
|
||||
engine will treat it as it does any unhandled exception.
|
||||
|
||||
## Heritage
|
||||
|
||||
ASAP has been factored out of the [Q][] asynchronous promise library.
|
||||
It originally had a naïve implementation in terms of `setTimeout`, but
|
||||
[Malte Ubl][NonBlocking] provided an insight that `postMessage` might be
|
||||
useful for creating a high-priority, no-delay event dispatch hack.
|
||||
Since then, Internet Explorer proposed and implemented `setImmediate`.
|
||||
Robert Kratić began contributing to Q by measuring the performance of
|
||||
the internal implementation of `asap`, paying particular attention to
|
||||
error recovery. Domenic, Robert, and I collectively settled on the
|
||||
current strategy of unrolling the high-priority event queue internally
|
||||
regardless of what strategy we used to dispatch the potentially
|
||||
lower-priority flush event. Domenic went on to make ASAP cooperate with
|
||||
NodeJS domains.
|
||||
|
||||
[Q]: https://github.com/kriskowal/q
|
||||
[NonBlocking]: http://www.nonblocking.io/2011/06/windownexttick.html
|
||||
|
||||
For further reading, Nicholas Zakas provided a thorough article on [The
|
||||
Case for setImmediate][NCZ].
|
||||
|
||||
[NCZ]: http://www.nczonline.net/blog/2013/07/09/the-case-for-setimmediate/
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2009-2013 by Contributors
|
||||
MIT License (enclosed)
|
||||
|
113
node_modules/asap/asap.js
generated
vendored
Normal file
113
node_modules/asap/asap.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
// Use the fastest possible means to execute a task in a future turn
|
||||
// of the event loop.
|
||||
|
||||
// linked list of tasks (single, with head node)
|
||||
var head = {task: void 0, next: null};
|
||||
var tail = head;
|
||||
var flushing = false;
|
||||
var requestFlush = void 0;
|
||||
var isNodeJS = false;
|
||||
|
||||
function flush() {
|
||||
/* jshint loopfunc: true */
|
||||
|
||||
while (head.next) {
|
||||
head = head.next;
|
||||
var task = head.task;
|
||||
head.task = void 0;
|
||||
var domain = head.domain;
|
||||
|
||||
if (domain) {
|
||||
head.domain = void 0;
|
||||
domain.enter();
|
||||
}
|
||||
|
||||
try {
|
||||
task();
|
||||
|
||||
} catch (e) {
|
||||
if (isNodeJS) {
|
||||
// In node, uncaught exceptions are considered fatal errors.
|
||||
// Re-throw them synchronously to interrupt flushing!
|
||||
|
||||
// Ensure continuation if the uncaught exception is suppressed
|
||||
// listening "uncaughtException" events (as domains does).
|
||||
// Continue in next event to avoid tick recursion.
|
||||
if (domain) {
|
||||
domain.exit();
|
||||
}
|
||||
setTimeout(flush, 0);
|
||||
if (domain) {
|
||||
domain.enter();
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
||||
} else {
|
||||
// In browsers, uncaught exceptions are not fatal.
|
||||
// Re-throw them asynchronously to avoid slow-downs.
|
||||
setTimeout(function() {
|
||||
throw e;
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (domain) {
|
||||
domain.exit();
|
||||
}
|
||||
}
|
||||
|
||||
flushing = false;
|
||||
}
|
||||
|
||||
if (typeof process !== "undefined" && process.nextTick) {
|
||||
// Node.js before 0.9. Note that some fake-Node environments, like the
|
||||
// Mocha test runner, introduce a `process` global without a `nextTick`.
|
||||
isNodeJS = true;
|
||||
|
||||
requestFlush = function () {
|
||||
process.nextTick(flush);
|
||||
};
|
||||
|
||||
} else if (typeof setImmediate === "function") {
|
||||
// In IE10, Node.js 0.9+, or https://github.com/NobleJS/setImmediate
|
||||
if (typeof window !== "undefined") {
|
||||
requestFlush = setImmediate.bind(window, flush);
|
||||
} else {
|
||||
requestFlush = function () {
|
||||
setImmediate(flush);
|
||||
};
|
||||
}
|
||||
|
||||
} else if (typeof MessageChannel !== "undefined") {
|
||||
// modern browsers
|
||||
// http://www.nonblocking.io/2011/06/windownexttick.html
|
||||
var channel = new MessageChannel();
|
||||
channel.port1.onmessage = flush;
|
||||
requestFlush = function () {
|
||||
channel.port2.postMessage(0);
|
||||
};
|
||||
|
||||
} else {
|
||||
// old browsers
|
||||
requestFlush = function () {
|
||||
setTimeout(flush, 0);
|
||||
};
|
||||
}
|
||||
|
||||
function asap(task) {
|
||||
tail = tail.next = {
|
||||
task: task,
|
||||
domain: isNodeJS && process.domain,
|
||||
next: null
|
||||
};
|
||||
|
||||
if (!flushing) {
|
||||
flushing = true;
|
||||
requestFlush();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = asap;
|
||||
|
72
node_modules/asap/package.json
generated
vendored
Normal file
72
node_modules/asap/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"name": "asap",
|
||||
"raw": "asap@~1.0.0",
|
||||
"rawSpec": "~1.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.0 <1.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"F:\\tmp\\gitbook\\node_modules\\promise"
|
||||
]
|
||||
],
|
||||
"_from": "asap@>=1.0.0 <1.1.0",
|
||||
"_id": "asap@1.0.0",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/asap",
|
||||
"_npmUser": {
|
||||
"email": "kris.kowal@cixar.com",
|
||||
"name": "kriskowal"
|
||||
},
|
||||
"_npmVersion": "1.2.15",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "asap",
|
||||
"raw": "asap@~1.0.0",
|
||||
"rawSpec": "~1.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.0 <1.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/promise"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/asap/-/asap-1.0.0.tgz",
|
||||
"_shasum": "b2a45da5fdfa20b0496fc3768cc27c12fa916a7d",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "asap@~1.0.0",
|
||||
"_where": "F:\\tmp\\gitbook\\node_modules\\promise",
|
||||
"dependencies": {},
|
||||
"description": "High-priority task queue for Node.js and browsers",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "b2a45da5fdfa20b0496fc3768cc27c12fa916a7d",
|
||||
"tarball": "https://registry.npmjs.org/asap/-/asap-1.0.0.tgz"
|
||||
},
|
||||
"keywords": [
|
||||
"event",
|
||||
"task",
|
||||
"queue"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/kriskowal/asap/raw/master/LICENSE.md"
|
||||
}
|
||||
],
|
||||
"main": "asap",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "kris.kowal@cixar.com",
|
||||
"name": "kriskowal"
|
||||
}
|
||||
],
|
||||
"name": "asap",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"version": "1.0.0"
|
||||
}
|
Reference in New Issue
Block a user