75 lines
2.8 KiB
JavaScript
75 lines
2.8 KiB
JavaScript
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.immediate = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
||
|
(function (global){
|
||
|
'use strict';
|
||
|
var Mutation = global.MutationObserver || global.WebKitMutationObserver;
|
||
|
|
||
|
var scheduleDrain;
|
||
|
|
||
|
{
|
||
|
if (Mutation) {
|
||
|
var called = 0;
|
||
|
var observer = new Mutation(nextTick);
|
||
|
var element = global.document.createTextNode('');
|
||
|
observer.observe(element, {
|
||
|
characterData: true
|
||
|
});
|
||
|
scheduleDrain = function () {
|
||
|
element.data = (called = ++called % 2);
|
||
|
};
|
||
|
} else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
|
||
|
var channel = new global.MessageChannel();
|
||
|
channel.port1.onmessage = nextTick;
|
||
|
scheduleDrain = function () {
|
||
|
channel.port2.postMessage(0);
|
||
|
};
|
||
|
} else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
|
||
|
scheduleDrain = function () {
|
||
|
|
||
|
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
|
||
|
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
|
||
|
var scriptEl = global.document.createElement('script');
|
||
|
scriptEl.onreadystatechange = function () {
|
||
|
nextTick();
|
||
|
|
||
|
scriptEl.onreadystatechange = null;
|
||
|
scriptEl.parentNode.removeChild(scriptEl);
|
||
|
scriptEl = null;
|
||
|
};
|
||
|
global.document.documentElement.appendChild(scriptEl);
|
||
|
};
|
||
|
} else {
|
||
|
scheduleDrain = function () {
|
||
|
setTimeout(nextTick, 0);
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var draining;
|
||
|
var queue = [];
|
||
|
//named nextTick for less confusing stack traces
|
||
|
function nextTick() {
|
||
|
draining = true;
|
||
|
var i, oldQueue;
|
||
|
var len = queue.length;
|
||
|
while (len) {
|
||
|
oldQueue = queue;
|
||
|
queue = [];
|
||
|
i = -1;
|
||
|
while (++i < len) {
|
||
|
oldQueue[i]();
|
||
|
}
|
||
|
len = queue.length;
|
||
|
}
|
||
|
draining = false;
|
||
|
}
|
||
|
|
||
|
module.exports = immediate;
|
||
|
function immediate(task) {
|
||
|
if (queue.push(task) === 1 && !draining) {
|
||
|
scheduleDrain();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
|
},{}]},{},[1])(1)
|
||
|
});
|