throw new Error('setTimeout has not been defined');
function defaultClearTimeout() {
throw new Error('clearTimeout has not been defined');
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
cachedSetTimeout = defaultSetTimout;
cachedSetTimeout = defaultSetTimout;
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
cachedClearTimeout = defaultClearTimeout;
cachedClearTimeout = defaultClearTimeout;
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
return setTimeout(fun, 0);
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
return cachedSetTimeout(fun, 0);
return cachedSetTimeout.call(null, fun, 0);
return cachedSetTimeout.call(this, fun, 0);
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
return clearTimeout(marker);
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
return cachedClearTimeout(marker);
return cachedClearTimeout.call(null, marker);
return cachedClearTimeout.call(this, marker);
function cleanUpNextTick() {
if (!draining || !currentQueue) {
if (currentQueue.length) {
queue = currentQueue.concat(queue);
var timeout = runTimeout(cleanUpNextTick);
while (++queueIndex < len) {
currentQueue[queueIndex].run();
runClearTimeout(timeout);
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
function Item(fun, array) {
Item.prototype.run = function () {
this.fun.apply(null, this.array);
process.title = 'browser';
process.addListener = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) {
process.binding = function (name) {
throw new Error('process.binding is not supported');
process.cwd = function () {
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
process.umask = function () {
function (require, module, exports) {
(function (setImmediate) {
var setTimeoutFunc = setTimeout;
function bind(fn, thisArg) {
fn.apply(thisArg, arguments);
if (typeof this !== 'object')
throw new TypeError('Promises must be constructed via new');
if (typeof fn !== 'function')
throw new TypeError('not a function');
function handle(self, deferred) {
while (self._state === 3) {
self._deferreds.push(deferred);
Promise._immediateFn(function () {
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
reject(deferred.promise, e);
resolve(deferred.promise, ret);
function resolve(self, newValue) {
throw new TypeError('A promise cannot be resolved with itself.');
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
var then = newValue.then;
if (newValue instanceof Promise) {
} else if (typeof then === 'function') {
doResolve(bind(then, newValue), self);
function reject(self, newValue) {
if (self._state === 2 && self._deferreds.length === 0) {
Promise._immediateFn(function () {
Promise._unhandledRejectionFn(self._value);
for (var i = 0, len = self._deferreds.length; i < len; i++) {
handle(self, self._deferreds[i]);
function Handler(onFulfilled, onRejected, promise) {
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
function doResolve(fn, self) {
Promise.prototype['catch'] = function (onRejected) {
return this.then(null, onRejected);
Promise.prototype.then = function (onFulfilled, onRejected) {
var prom = new this.constructor(noop);
handle(this, new Handler(onFulfilled, onRejected, prom));
Promise.all = function (arr) {
var args = Array.prototype.slice.call(arr);
return new Promise(function (resolve, reject) {
var remaining = args.length;
if (val && (typeof val === 'object' || typeof val === 'function')) {
if (typeof then === 'function') {
then.call(val, function (val) {
for (var i = 0; i < args.length; i++) {
Promise.resolve = function (value) {
if (value && typeof value === 'object' && value.constructor === Promise) {
return new Promise(function (resolve) {
Promise.reject = function (value) {
return new Promise(function (resolve, reject) {
Promise.race = function (values) {
return new Promise(function (resolve, reject) {
for (var i = 0, len = values.length; i < len; i++) {
values[i].then(resolve, reject);
Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
if (typeof console !== 'undefined' && console) {
console.warn('Possible Unhandled Promise Rejection:', err);
Promise._setImmediateFn = function _setImmediateFn(fn) {
Promise._immediateFn = fn;
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
Promise._unhandledRejectionFn = fn;
if (typeof module !== 'undefined' && module.exports) {
module.exports = Promise;
} else if (!root.Promise) {
}.call(this, require('timers').setImmediate));
function (require, module, exports) {
(function (setImmediate, clearImmediate) {
var nextTick = require('process/browser.js').nextTick;
var apply = Function.prototype.apply;
var slice = Array.prototype.slice;
exports.setTimeout = function () {
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
exports.setInterval = function () {
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
exports.clearTimeout = exports.clearInterval = function (timeout) {
function Timeout(id, clearFn) {
Timeout.prototype.unref = Timeout.prototype.ref = function () {
Timeout.prototype.close = function () {
this._clearFn.call(window, this._id);
exports.enroll = function (item, msecs) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = msecs;
exports.unenroll = function (item) {
clearTimeout(item._idleTimeoutId);
exports._unrefActive = exports.active = function (item) {
clearTimeout(item._idleTimeoutId);
var msecs = item._idleTimeout;
item._idleTimeoutId = setTimeout(function onTimeout() {
exports.setImmediate = typeof setImmediate === 'function' ? setImmediate : function (fn) {
var id = nextImmediateId++;
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
nextTick(function onNextTick() {
exports.clearImmediate(id);
exports.clearImmediate = typeof clearImmediate === 'function' ? clearImmediate : function (id) {
}.call(this, require('timers').setImmediate, require('timers').clearImmediate));
function (require, module, exports) {
var promisePolyfill = require('promise-polyfill');
var Global = function () {
if (typeof window !== 'undefined') {
return Function('return this;')();
module.exports = { boltExport: Global.Promise || promisePolyfill };
{ 'promise-polyfill': 2 }
}(undefined, exports$1, module, undefined));
var Promise = module.exports.boltExport;
var nu = function (baseFn) {
var data = Option.none();
return nu(function (nCallback) {
var get = function (nCallback) {
callbacks.push(nCallback);
var isReady = function () {
var run = function (cbs) {
var call = function (cb) {
domGlobals.setTimeout(function () {
var pure = function (a) {
return nu(function (callback) {
var errorReporter = function (err) {
domGlobals.setTimeout(function () {