es6-promise
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -6,3 +6,3 @@ /*! | ||
* See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE | ||
* @version 2.0.1 | ||
* @version 2.1.0 | ||
*/ | ||
@@ -12,59 +12,48 @@ | ||
"use strict"; | ||
function $$utils$$objectOrFunction(x) { | ||
function lib$es6$promise$utils$$objectOrFunction(x) { | ||
return typeof x === 'function' || (typeof x === 'object' && x !== null); | ||
} | ||
function $$utils$$isFunction(x) { | ||
function lib$es6$promise$utils$$isFunction(x) { | ||
return typeof x === 'function'; | ||
} | ||
function $$utils$$isMaybeThenable(x) { | ||
function lib$es6$promise$utils$$isMaybeThenable(x) { | ||
return typeof x === 'object' && x !== null; | ||
} | ||
var $$utils$$_isArray; | ||
var lib$es6$promise$utils$$_isArray; | ||
if (!Array.isArray) { | ||
$$utils$$_isArray = function (x) { | ||
lib$es6$promise$utils$$_isArray = function (x) { | ||
return Object.prototype.toString.call(x) === '[object Array]'; | ||
}; | ||
} else { | ||
$$utils$$_isArray = Array.isArray; | ||
lib$es6$promise$utils$$_isArray = Array.isArray; | ||
} | ||
var $$utils$$isArray = $$utils$$_isArray; | ||
var $$utils$$now = Date.now || function() { return new Date().getTime(); }; | ||
function $$utils$$F() { } | ||
var $$utils$$o_create = (Object.create || function (o) { | ||
if (arguments.length > 1) { | ||
throw new Error('Second argument not supported'); | ||
} | ||
if (typeof o !== 'object') { | ||
throw new TypeError('Argument must be an object'); | ||
} | ||
$$utils$$F.prototype = o; | ||
return new $$utils$$F(); | ||
}); | ||
var $$asap$$len = 0; | ||
var $$asap$$default = function asap(callback, arg) { | ||
$$asap$$queue[$$asap$$len] = callback; | ||
$$asap$$queue[$$asap$$len + 1] = arg; | ||
$$asap$$len += 2; | ||
if ($$asap$$len === 2) { | ||
// If len is 1, that means that we need to schedule an async flush. | ||
var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray; | ||
var lib$es6$promise$asap$$len = 0; | ||
var lib$es6$promise$asap$$toString = {}.toString; | ||
var lib$es6$promise$asap$$vertxNext; | ||
function lib$es6$promise$asap$$asap(callback, arg) { | ||
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback; | ||
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg; | ||
lib$es6$promise$asap$$len += 2; | ||
if (lib$es6$promise$asap$$len === 2) { | ||
// If len is 2, that means that we need to schedule an async flush. | ||
// If additional callbacks are queued before the queue is flushed, they | ||
// will be processed by this flush that we are scheduling. | ||
$$asap$$scheduleFlush(); | ||
lib$es6$promise$asap$$scheduleFlush(); | ||
} | ||
}; | ||
} | ||
var $$asap$$browserGlobal = (typeof window !== 'undefined') ? window : {}; | ||
var $$asap$$BrowserMutationObserver = $$asap$$browserGlobal.MutationObserver || $$asap$$browserGlobal.WebKitMutationObserver; | ||
var lib$es6$promise$asap$$default = lib$es6$promise$asap$$asap; | ||
var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined; | ||
var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {}; | ||
var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver; | ||
var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; | ||
// test for web worker but not in IE10 | ||
var $$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && | ||
var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && | ||
typeof importScripts !== 'undefined' && | ||
@@ -74,11 +63,25 @@ typeof MessageChannel !== 'undefined'; | ||
// node | ||
function $$asap$$useNextTick() { | ||
function lib$es6$promise$asap$$useNextTick() { | ||
var nextTick = process.nextTick; | ||
// node version 0.10.x displays a deprecation warning when nextTick is used recursively | ||
// setImmediate should be used instead instead | ||
var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); | ||
if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { | ||
nextTick = setImmediate; | ||
} | ||
return function() { | ||
process.nextTick($$asap$$flush); | ||
nextTick(lib$es6$promise$asap$$flush); | ||
}; | ||
} | ||
function $$asap$$useMutationObserver() { | ||
// vertx | ||
function lib$es6$promise$asap$$useVertxTimer() { | ||
return function() { | ||
lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush); | ||
}; | ||
} | ||
function lib$es6$promise$asap$$useMutationObserver() { | ||
var iterations = 0; | ||
var observer = new $$asap$$BrowserMutationObserver($$asap$$flush); | ||
var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush); | ||
var node = document.createTextNode(''); | ||
@@ -93,5 +96,5 @@ observer.observe(node, { characterData: true }); | ||
// web worker | ||
function $$asap$$useMessageChannel() { | ||
function lib$es6$promise$asap$$useMessageChannel() { | ||
var channel = new MessageChannel(); | ||
channel.port1.onmessage = $$asap$$flush; | ||
channel.port1.onmessage = lib$es6$promise$asap$$flush; | ||
return function () { | ||
@@ -102,61 +105,74 @@ channel.port2.postMessage(0); | ||
function $$asap$$useSetTimeout() { | ||
function lib$es6$promise$asap$$useSetTimeout() { | ||
return function() { | ||
setTimeout($$asap$$flush, 1); | ||
setTimeout(lib$es6$promise$asap$$flush, 1); | ||
}; | ||
} | ||
var $$asap$$queue = new Array(1000); | ||
var lib$es6$promise$asap$$queue = new Array(1000); | ||
function lib$es6$promise$asap$$flush() { | ||
for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) { | ||
var callback = lib$es6$promise$asap$$queue[i]; | ||
var arg = lib$es6$promise$asap$$queue[i+1]; | ||
function $$asap$$flush() { | ||
for (var i = 0; i < $$asap$$len; i+=2) { | ||
var callback = $$asap$$queue[i]; | ||
var arg = $$asap$$queue[i+1]; | ||
callback(arg); | ||
$$asap$$queue[i] = undefined; | ||
$$asap$$queue[i+1] = undefined; | ||
lib$es6$promise$asap$$queue[i] = undefined; | ||
lib$es6$promise$asap$$queue[i+1] = undefined; | ||
} | ||
$$asap$$len = 0; | ||
lib$es6$promise$asap$$len = 0; | ||
} | ||
var $$asap$$scheduleFlush; | ||
function lib$es6$promise$asap$$attemptVertex() { | ||
try { | ||
var r = require; | ||
var vertx = r('vertx'); | ||
lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext; | ||
return lib$es6$promise$asap$$useVertxTimer(); | ||
} catch(e) { | ||
return lib$es6$promise$asap$$useSetTimeout(); | ||
} | ||
} | ||
var lib$es6$promise$asap$$scheduleFlush; | ||
// Decide what async method to use to triggering processing of queued callbacks: | ||
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { | ||
$$asap$$scheduleFlush = $$asap$$useNextTick(); | ||
} else if ($$asap$$BrowserMutationObserver) { | ||
$$asap$$scheduleFlush = $$asap$$useMutationObserver(); | ||
} else if ($$asap$$isWorker) { | ||
$$asap$$scheduleFlush = $$asap$$useMessageChannel(); | ||
if (lib$es6$promise$asap$$isNode) { | ||
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick(); | ||
} else if (lib$es6$promise$asap$$BrowserMutationObserver) { | ||
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver(); | ||
} else if (lib$es6$promise$asap$$isWorker) { | ||
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel(); | ||
} else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') { | ||
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertex(); | ||
} else { | ||
$$asap$$scheduleFlush = $$asap$$useSetTimeout(); | ||
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout(); | ||
} | ||
function $$$internal$$noop() {} | ||
var $$$internal$$PENDING = void 0; | ||
var $$$internal$$FULFILLED = 1; | ||
var $$$internal$$REJECTED = 2; | ||
var $$$internal$$GET_THEN_ERROR = new $$$internal$$ErrorObject(); | ||
function lib$es6$promise$$internal$$noop() {} | ||
function $$$internal$$selfFullfillment() { | ||
var lib$es6$promise$$internal$$PENDING = void 0; | ||
var lib$es6$promise$$internal$$FULFILLED = 1; | ||
var lib$es6$promise$$internal$$REJECTED = 2; | ||
var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject(); | ||
function lib$es6$promise$$internal$$selfFullfillment() { | ||
return new TypeError("You cannot resolve a promise with itself"); | ||
} | ||
function $$$internal$$cannotReturnOwn() { | ||
return new TypeError('A promises callback cannot return that same promise.') | ||
function lib$es6$promise$$internal$$cannotReturnOwn() { | ||
return new TypeError('A promises callback cannot return that same promise.'); | ||
} | ||
function $$$internal$$getThen(promise) { | ||
function lib$es6$promise$$internal$$getThen(promise) { | ||
try { | ||
return promise.then; | ||
} catch(error) { | ||
$$$internal$$GET_THEN_ERROR.error = error; | ||
return $$$internal$$GET_THEN_ERROR; | ||
lib$es6$promise$$internal$$GET_THEN_ERROR.error = error; | ||
return lib$es6$promise$$internal$$GET_THEN_ERROR; | ||
} | ||
} | ||
function $$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) { | ||
function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) { | ||
try { | ||
@@ -169,12 +185,12 @@ then.call(value, fulfillmentHandler, rejectionHandler); | ||
function $$$internal$$handleForeignThenable(promise, thenable, then) { | ||
$$asap$$default(function(promise) { | ||
function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) { | ||
lib$es6$promise$asap$$default(function(promise) { | ||
var sealed = false; | ||
var error = $$$internal$$tryThen(then, thenable, function(value) { | ||
var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) { | ||
if (sealed) { return; } | ||
sealed = true; | ||
if (thenable !== value) { | ||
$$$internal$$resolve(promise, value); | ||
lib$es6$promise$$internal$$resolve(promise, value); | ||
} else { | ||
$$$internal$$fulfill(promise, value); | ||
lib$es6$promise$$internal$$fulfill(promise, value); | ||
} | ||
@@ -185,3 +201,3 @@ }, function(reason) { | ||
$$$internal$$reject(promise, reason); | ||
lib$es6$promise$$internal$$reject(promise, reason); | ||
}, 'Settle: ' + (promise._label || ' unknown promise')); | ||
@@ -191,3 +207,3 @@ | ||
sealed = true; | ||
$$$internal$$reject(promise, error); | ||
lib$es6$promise$$internal$$reject(promise, error); | ||
} | ||
@@ -197,12 +213,12 @@ }, promise); | ||
function $$$internal$$handleOwnThenable(promise, thenable) { | ||
if (thenable._state === $$$internal$$FULFILLED) { | ||
$$$internal$$fulfill(promise, thenable._result); | ||
} else if (promise._state === $$$internal$$REJECTED) { | ||
$$$internal$$reject(promise, thenable._result); | ||
function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) { | ||
if (thenable._state === lib$es6$promise$$internal$$FULFILLED) { | ||
lib$es6$promise$$internal$$fulfill(promise, thenable._result); | ||
} else if (promise._state === lib$es6$promise$$internal$$REJECTED) { | ||
lib$es6$promise$$internal$$reject(promise, thenable._result); | ||
} else { | ||
$$$internal$$subscribe(thenable, undefined, function(value) { | ||
$$$internal$$resolve(promise, value); | ||
lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) { | ||
lib$es6$promise$$internal$$resolve(promise, value); | ||
}, function(reason) { | ||
$$$internal$$reject(promise, reason); | ||
lib$es6$promise$$internal$$reject(promise, reason); | ||
}); | ||
@@ -212,16 +228,16 @@ } | ||
function $$$internal$$handleMaybeThenable(promise, maybeThenable) { | ||
function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) { | ||
if (maybeThenable.constructor === promise.constructor) { | ||
$$$internal$$handleOwnThenable(promise, maybeThenable); | ||
lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable); | ||
} else { | ||
var then = $$$internal$$getThen(maybeThenable); | ||
var then = lib$es6$promise$$internal$$getThen(maybeThenable); | ||
if (then === $$$internal$$GET_THEN_ERROR) { | ||
$$$internal$$reject(promise, $$$internal$$GET_THEN_ERROR.error); | ||
if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) { | ||
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error); | ||
} else if (then === undefined) { | ||
$$$internal$$fulfill(promise, maybeThenable); | ||
} else if ($$utils$$isFunction(then)) { | ||
$$$internal$$handleForeignThenable(promise, maybeThenable, then); | ||
lib$es6$promise$$internal$$fulfill(promise, maybeThenable); | ||
} else if (lib$es6$promise$utils$$isFunction(then)) { | ||
lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then); | ||
} else { | ||
$$$internal$$fulfill(promise, maybeThenable); | ||
lib$es6$promise$$internal$$fulfill(promise, maybeThenable); | ||
} | ||
@@ -231,13 +247,13 @@ } | ||
function $$$internal$$resolve(promise, value) { | ||
function lib$es6$promise$$internal$$resolve(promise, value) { | ||
if (promise === value) { | ||
$$$internal$$reject(promise, $$$internal$$selfFullfillment()); | ||
} else if ($$utils$$objectOrFunction(value)) { | ||
$$$internal$$handleMaybeThenable(promise, value); | ||
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFullfillment()); | ||
} else if (lib$es6$promise$utils$$objectOrFunction(value)) { | ||
lib$es6$promise$$internal$$handleMaybeThenable(promise, value); | ||
} else { | ||
$$$internal$$fulfill(promise, value); | ||
lib$es6$promise$$internal$$fulfill(promise, value); | ||
} | ||
} | ||
function $$$internal$$publishRejection(promise) { | ||
function lib$es6$promise$$internal$$publishRejection(promise) { | ||
if (promise._onerror) { | ||
@@ -247,26 +263,25 @@ promise._onerror(promise._result); | ||
$$$internal$$publish(promise); | ||
lib$es6$promise$$internal$$publish(promise); | ||
} | ||
function $$$internal$$fulfill(promise, value) { | ||
if (promise._state !== $$$internal$$PENDING) { return; } | ||
function lib$es6$promise$$internal$$fulfill(promise, value) { | ||
if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } | ||
promise._result = value; | ||
promise._state = $$$internal$$FULFILLED; | ||
promise._state = lib$es6$promise$$internal$$FULFILLED; | ||
if (promise._subscribers.length === 0) { | ||
} else { | ||
$$asap$$default($$$internal$$publish, promise); | ||
if (promise._subscribers.length !== 0) { | ||
lib$es6$promise$asap$$default(lib$es6$promise$$internal$$publish, promise); | ||
} | ||
} | ||
function $$$internal$$reject(promise, reason) { | ||
if (promise._state !== $$$internal$$PENDING) { return; } | ||
promise._state = $$$internal$$REJECTED; | ||
function lib$es6$promise$$internal$$reject(promise, reason) { | ||
if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } | ||
promise._state = lib$es6$promise$$internal$$REJECTED; | ||
promise._result = reason; | ||
$$asap$$default($$$internal$$publishRejection, promise); | ||
lib$es6$promise$asap$$default(lib$es6$promise$$internal$$publishRejection, promise); | ||
} | ||
function $$$internal$$subscribe(parent, child, onFulfillment, onRejection) { | ||
function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) { | ||
var subscribers = parent._subscribers; | ||
@@ -278,11 +293,11 @@ var length = subscribers.length; | ||
subscribers[length] = child; | ||
subscribers[length + $$$internal$$FULFILLED] = onFulfillment; | ||
subscribers[length + $$$internal$$REJECTED] = onRejection; | ||
subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment; | ||
subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection; | ||
if (length === 0 && parent._state) { | ||
$$asap$$default($$$internal$$publish, parent); | ||
lib$es6$promise$asap$$default(lib$es6$promise$$internal$$publish, parent); | ||
} | ||
} | ||
function $$$internal$$publish(promise) { | ||
function lib$es6$promise$$internal$$publish(promise) { | ||
var subscribers = promise._subscribers; | ||
@@ -300,3 +315,3 @@ var settled = promise._state; | ||
if (child) { | ||
$$$internal$$invokeCallback(settled, child, callback, detail); | ||
lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail); | ||
} else { | ||
@@ -310,25 +325,25 @@ callback(detail); | ||
function $$$internal$$ErrorObject() { | ||
function lib$es6$promise$$internal$$ErrorObject() { | ||
this.error = null; | ||
} | ||
var $$$internal$$TRY_CATCH_ERROR = new $$$internal$$ErrorObject(); | ||
var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject(); | ||
function $$$internal$$tryCatch(callback, detail) { | ||
function lib$es6$promise$$internal$$tryCatch(callback, detail) { | ||
try { | ||
return callback(detail); | ||
} catch(e) { | ||
$$$internal$$TRY_CATCH_ERROR.error = e; | ||
return $$$internal$$TRY_CATCH_ERROR; | ||
lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e; | ||
return lib$es6$promise$$internal$$TRY_CATCH_ERROR; | ||
} | ||
} | ||
function $$$internal$$invokeCallback(settled, promise, callback, detail) { | ||
var hasCallback = $$utils$$isFunction(callback), | ||
function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) { | ||
var hasCallback = lib$es6$promise$utils$$isFunction(callback), | ||
value, error, succeeded, failed; | ||
if (hasCallback) { | ||
value = $$$internal$$tryCatch(callback, detail); | ||
value = lib$es6$promise$$internal$$tryCatch(callback, detail); | ||
if (value === $$$internal$$TRY_CATCH_ERROR) { | ||
if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) { | ||
failed = true; | ||
@@ -342,3 +357,3 @@ error = value.error; | ||
if (promise === value) { | ||
$$$internal$$reject(promise, $$$internal$$cannotReturnOwn()); | ||
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn()); | ||
return; | ||
@@ -352,150 +367,137 @@ } | ||
if (promise._state !== $$$internal$$PENDING) { | ||
if (promise._state !== lib$es6$promise$$internal$$PENDING) { | ||
// noop | ||
} else if (hasCallback && succeeded) { | ||
$$$internal$$resolve(promise, value); | ||
lib$es6$promise$$internal$$resolve(promise, value); | ||
} else if (failed) { | ||
$$$internal$$reject(promise, error); | ||
} else if (settled === $$$internal$$FULFILLED) { | ||
$$$internal$$fulfill(promise, value); | ||
} else if (settled === $$$internal$$REJECTED) { | ||
$$$internal$$reject(promise, value); | ||
lib$es6$promise$$internal$$reject(promise, error); | ||
} else if (settled === lib$es6$promise$$internal$$FULFILLED) { | ||
lib$es6$promise$$internal$$fulfill(promise, value); | ||
} else if (settled === lib$es6$promise$$internal$$REJECTED) { | ||
lib$es6$promise$$internal$$reject(promise, value); | ||
} | ||
} | ||
function $$$internal$$initializePromise(promise, resolver) { | ||
function lib$es6$promise$$internal$$initializePromise(promise, resolver) { | ||
try { | ||
resolver(function resolvePromise(value){ | ||
$$$internal$$resolve(promise, value); | ||
lib$es6$promise$$internal$$resolve(promise, value); | ||
}, function rejectPromise(reason) { | ||
$$$internal$$reject(promise, reason); | ||
lib$es6$promise$$internal$$reject(promise, reason); | ||
}); | ||
} catch(e) { | ||
$$$internal$$reject(promise, e); | ||
lib$es6$promise$$internal$$reject(promise, e); | ||
} | ||
} | ||
function $$$enumerator$$makeSettledResult(state, position, value) { | ||
if (state === $$$internal$$FULFILLED) { | ||
return { | ||
state: 'fulfilled', | ||
value: value | ||
}; | ||
} else { | ||
return { | ||
state: 'rejected', | ||
reason: value | ||
}; | ||
} | ||
} | ||
function lib$es6$promise$enumerator$$Enumerator(Constructor, input) { | ||
var enumerator = this; | ||
function $$$enumerator$$Enumerator(Constructor, input, abortOnReject, label) { | ||
this._instanceConstructor = Constructor; | ||
this.promise = new Constructor($$$internal$$noop, label); | ||
this._abortOnReject = abortOnReject; | ||
enumerator._instanceConstructor = Constructor; | ||
enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop); | ||
if (this._validateInput(input)) { | ||
this._input = input; | ||
this.length = input.length; | ||
this._remaining = input.length; | ||
if (enumerator._validateInput(input)) { | ||
enumerator._input = input; | ||
enumerator.length = input.length; | ||
enumerator._remaining = input.length; | ||
this._init(); | ||
enumerator._init(); | ||
if (this.length === 0) { | ||
$$$internal$$fulfill(this.promise, this._result); | ||
if (enumerator.length === 0) { | ||
lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result); | ||
} else { | ||
this.length = this.length || 0; | ||
this._enumerate(); | ||
if (this._remaining === 0) { | ||
$$$internal$$fulfill(this.promise, this._result); | ||
enumerator.length = enumerator.length || 0; | ||
enumerator._enumerate(); | ||
if (enumerator._remaining === 0) { | ||
lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result); | ||
} | ||
} | ||
} else { | ||
$$$internal$$reject(this.promise, this._validationError()); | ||
lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError()); | ||
} | ||
} | ||
$$$enumerator$$Enumerator.prototype._validateInput = function(input) { | ||
return $$utils$$isArray(input); | ||
lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function(input) { | ||
return lib$es6$promise$utils$$isArray(input); | ||
}; | ||
$$$enumerator$$Enumerator.prototype._validationError = function() { | ||
lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() { | ||
return new Error('Array Methods must be provided an Array'); | ||
}; | ||
$$$enumerator$$Enumerator.prototype._init = function() { | ||
lib$es6$promise$enumerator$$Enumerator.prototype._init = function() { | ||
this._result = new Array(this.length); | ||
}; | ||
var $$$enumerator$$default = $$$enumerator$$Enumerator; | ||
var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator; | ||
$$$enumerator$$Enumerator.prototype._enumerate = function() { | ||
var length = this.length; | ||
var promise = this.promise; | ||
var input = this._input; | ||
lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() { | ||
var enumerator = this; | ||
for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) { | ||
this._eachEntry(input[i], i); | ||
var length = enumerator.length; | ||
var promise = enumerator.promise; | ||
var input = enumerator._input; | ||
for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { | ||
enumerator._eachEntry(input[i], i); | ||
} | ||
}; | ||
$$$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) { | ||
var c = this._instanceConstructor; | ||
if ($$utils$$isMaybeThenable(entry)) { | ||
if (entry.constructor === c && entry._state !== $$$internal$$PENDING) { | ||
lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) { | ||
var enumerator = this; | ||
var c = enumerator._instanceConstructor; | ||
if (lib$es6$promise$utils$$isMaybeThenable(entry)) { | ||
if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) { | ||
entry._onerror = null; | ||
this._settledAt(entry._state, i, entry._result); | ||
enumerator._settledAt(entry._state, i, entry._result); | ||
} else { | ||
this._willSettleAt(c.resolve(entry), i); | ||
enumerator._willSettleAt(c.resolve(entry), i); | ||
} | ||
} else { | ||
this._remaining--; | ||
this._result[i] = this._makeResult($$$internal$$FULFILLED, i, entry); | ||
enumerator._remaining--; | ||
enumerator._result[i] = entry; | ||
} | ||
}; | ||
$$$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) { | ||
var promise = this.promise; | ||
lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) { | ||
var enumerator = this; | ||
var promise = enumerator.promise; | ||
if (promise._state === $$$internal$$PENDING) { | ||
this._remaining--; | ||
if (promise._state === lib$es6$promise$$internal$$PENDING) { | ||
enumerator._remaining--; | ||
if (this._abortOnReject && state === $$$internal$$REJECTED) { | ||
$$$internal$$reject(promise, value); | ||
if (state === lib$es6$promise$$internal$$REJECTED) { | ||
lib$es6$promise$$internal$$reject(promise, value); | ||
} else { | ||
this._result[i] = this._makeResult(state, i, value); | ||
enumerator._result[i] = value; | ||
} | ||
} | ||
if (this._remaining === 0) { | ||
$$$internal$$fulfill(promise, this._result); | ||
if (enumerator._remaining === 0) { | ||
lib$es6$promise$$internal$$fulfill(promise, enumerator._result); | ||
} | ||
}; | ||
$$$enumerator$$Enumerator.prototype._makeResult = function(state, i, value) { | ||
return value; | ||
}; | ||
$$$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) { | ||
lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) { | ||
var enumerator = this; | ||
$$$internal$$subscribe(promise, undefined, function(value) { | ||
enumerator._settledAt($$$internal$$FULFILLED, i, value); | ||
lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) { | ||
enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value); | ||
}, function(reason) { | ||
enumerator._settledAt($$$internal$$REJECTED, i, reason); | ||
enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason); | ||
}); | ||
}; | ||
var $$promise$all$$default = function all(entries, label) { | ||
return new $$$enumerator$$default(this, entries, true /* abort on reject */, label).promise; | ||
}; | ||
var $$promise$race$$default = function race(entries, label) { | ||
function lib$es6$promise$promise$all$$all(entries) { | ||
return new lib$es6$promise$enumerator$$default(this, entries).promise; | ||
} | ||
var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all; | ||
function lib$es6$promise$promise$race$$race(entries) { | ||
/*jshint validthis:true */ | ||
var Constructor = this; | ||
var promise = new Constructor($$$internal$$noop, label); | ||
var promise = new Constructor(lib$es6$promise$$internal$$noop); | ||
if (!$$utils$$isArray(entries)) { | ||
$$$internal$$reject(promise, new TypeError('You must pass an array to race.')); | ||
if (!lib$es6$promise$utils$$isArray(entries)) { | ||
lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.')); | ||
return promise; | ||
@@ -507,17 +509,17 @@ } | ||
function onFulfillment(value) { | ||
$$$internal$$resolve(promise, value); | ||
lib$es6$promise$$internal$$resolve(promise, value); | ||
} | ||
function onRejection(reason) { | ||
$$$internal$$reject(promise, reason); | ||
lib$es6$promise$$internal$$reject(promise, reason); | ||
} | ||
for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) { | ||
$$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); | ||
for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { | ||
lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); | ||
} | ||
return promise; | ||
}; | ||
var $$promise$resolve$$default = function resolve(object, label) { | ||
} | ||
var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race; | ||
function lib$es6$promise$promise$resolve$$resolve(object) { | ||
/*jshint validthis:true */ | ||
@@ -530,27 +532,27 @@ var Constructor = this; | ||
var promise = new Constructor($$$internal$$noop, label); | ||
$$$internal$$resolve(promise, object); | ||
var promise = new Constructor(lib$es6$promise$$internal$$noop); | ||
lib$es6$promise$$internal$$resolve(promise, object); | ||
return promise; | ||
}; | ||
var $$promise$reject$$default = function reject(reason, label) { | ||
} | ||
var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve; | ||
function lib$es6$promise$promise$reject$$reject(reason) { | ||
/*jshint validthis:true */ | ||
var Constructor = this; | ||
var promise = new Constructor($$$internal$$noop, label); | ||
$$$internal$$reject(promise, reason); | ||
var promise = new Constructor(lib$es6$promise$$internal$$noop); | ||
lib$es6$promise$$internal$$reject(promise, reason); | ||
return promise; | ||
}; | ||
} | ||
var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject; | ||
var $$es6$promise$promise$$counter = 0; | ||
var lib$es6$promise$promise$$counter = 0; | ||
function $$es6$promise$promise$$needsResolver() { | ||
function lib$es6$promise$promise$$needsResolver() { | ||
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); | ||
} | ||
function $$es6$promise$promise$$needsNew() { | ||
function lib$es6$promise$promise$$needsNew() { | ||
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); | ||
} | ||
var $$es6$promise$promise$$default = $$es6$promise$promise$$Promise; | ||
var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise; | ||
/** | ||
@@ -659,4 +661,4 @@ Promise objects represent the eventual result of an asynchronous operation. The | ||
*/ | ||
function $$es6$promise$promise$$Promise(resolver) { | ||
this._id = $$es6$promise$promise$$counter++; | ||
function lib$es6$promise$promise$$Promise(resolver) { | ||
this._id = lib$es6$promise$promise$$counter++; | ||
this._state = undefined; | ||
@@ -666,22 +668,22 @@ this._result = undefined; | ||
if ($$$internal$$noop !== resolver) { | ||
if (!$$utils$$isFunction(resolver)) { | ||
$$es6$promise$promise$$needsResolver(); | ||
if (lib$es6$promise$$internal$$noop !== resolver) { | ||
if (!lib$es6$promise$utils$$isFunction(resolver)) { | ||
lib$es6$promise$promise$$needsResolver(); | ||
} | ||
if (!(this instanceof $$es6$promise$promise$$Promise)) { | ||
$$es6$promise$promise$$needsNew(); | ||
if (!(this instanceof lib$es6$promise$promise$$Promise)) { | ||
lib$es6$promise$promise$$needsNew(); | ||
} | ||
$$$internal$$initializePromise(this, resolver); | ||
lib$es6$promise$$internal$$initializePromise(this, resolver); | ||
} | ||
} | ||
$$es6$promise$promise$$Promise.all = $$promise$all$$default; | ||
$$es6$promise$promise$$Promise.race = $$promise$race$$default; | ||
$$es6$promise$promise$$Promise.resolve = $$promise$resolve$$default; | ||
$$es6$promise$promise$$Promise.reject = $$promise$reject$$default; | ||
lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default; | ||
lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default; | ||
lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default; | ||
lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default; | ||
$$es6$promise$promise$$Promise.prototype = { | ||
constructor: $$es6$promise$promise$$Promise, | ||
lib$es6$promise$promise$$Promise.prototype = { | ||
constructor: lib$es6$promise$promise$$Promise, | ||
@@ -885,7 +887,7 @@ /** | ||
if (state === $$$internal$$FULFILLED && !onFulfillment || state === $$$internal$$REJECTED && !onRejection) { | ||
if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) { | ||
return this; | ||
} | ||
var child = new this.constructor($$$internal$$noop); | ||
var child = new this.constructor(lib$es6$promise$$internal$$noop); | ||
var result = parent._result; | ||
@@ -895,7 +897,7 @@ | ||
var callback = arguments[state - 1]; | ||
$$asap$$default(function(){ | ||
$$$internal$$invokeCallback(state, child, callback, result); | ||
lib$es6$promise$asap$$default(function(){ | ||
lib$es6$promise$$internal$$invokeCallback(state, child, callback, result); | ||
}); | ||
} else { | ||
$$$internal$$subscribe(parent, child, onFulfillment, onRejection); | ||
lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection); | ||
} | ||
@@ -937,38 +939,30 @@ | ||
}; | ||
var $$es6$promise$polyfill$$default = function polyfill() { | ||
function lib$es6$promise$polyfill$$polyfill() { | ||
var local; | ||
if (typeof global !== 'undefined') { | ||
local = global; | ||
} else if (typeof window !== 'undefined' && window.document) { | ||
local = window; | ||
local = global; | ||
} else if (typeof self !== 'undefined') { | ||
local = self; | ||
} else { | ||
local = self; | ||
try { | ||
local = Function('return this')(); | ||
} catch (e) { | ||
throw new Error('polyfill failed because global object is unavailable in this environment'); | ||
} | ||
} | ||
var es6PromiseSupport = | ||
"Promise" in local && | ||
// Some of these methods are missing from | ||
// Firefox/Chrome experimental implementations | ||
"resolve" in local.Promise && | ||
"reject" in local.Promise && | ||
"all" in local.Promise && | ||
"race" in local.Promise && | ||
// Older version of the spec had a resolver object | ||
// as the arg rather than a function | ||
(function() { | ||
var resolve; | ||
new local.Promise(function(r) { resolve = r; }); | ||
return $$utils$$isFunction(resolve); | ||
}()); | ||
var P = local.Promise; | ||
if (!es6PromiseSupport) { | ||
local.Promise = $$es6$promise$promise$$default; | ||
if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { | ||
return; | ||
} | ||
}; | ||
var es6$promise$umd$$ES6Promise = { | ||
'Promise': $$es6$promise$promise$$default, | ||
'polyfill': $$es6$promise$polyfill$$default | ||
local.Promise = lib$es6$promise$promise$$default; | ||
} | ||
var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; | ||
var lib$es6$promise$umd$$ES6Promise = { | ||
'Promise': lib$es6$promise$promise$$default, | ||
'polyfill': lib$es6$promise$polyfill$$default | ||
}; | ||
@@ -978,8 +972,11 @@ | ||
if (typeof define === 'function' && define['amd']) { | ||
define(function() { return es6$promise$umd$$ES6Promise; }); | ||
define(function() { return lib$es6$promise$umd$$ES6Promise; }); | ||
} else if (typeof module !== 'undefined' && module['exports']) { | ||
module['exports'] = es6$promise$umd$$ES6Promise; | ||
module['exports'] = lib$es6$promise$umd$$ES6Promise; | ||
} else if (typeof this !== 'undefined') { | ||
this['ES6Promise'] = es6$promise$umd$$ES6Promise; | ||
this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; | ||
} | ||
}).call(this); | ||
lib$es6$promise$polyfill$$default(); | ||
}).call(this); | ||
@@ -6,14 +6,5 @@ /*! | ||
* See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE | ||
* @version 2.0.1 | ||
* @version 2.1.0 | ||
*/ | ||
(function(){function r(a,b){n[l]=a;n[l+1]=b;l+=2;2===l&&A()}function s(a){return"function"===typeof a}function F(){return function(){process.nextTick(t)}}function G(){var a=0,b=new B(t),c=document.createTextNode("");b.observe(c,{characterData:!0});return function(){c.data=a=++a%2}}function H(){var a=new MessageChannel;a.port1.onmessage=t;return function(){a.port2.postMessage(0)}}function I(){return function(){setTimeout(t,1)}}function t(){for(var a=0;a<l;a+=2)(0,n[a])(n[a+1]),n[a]=void 0,n[a+1]=void 0; | ||
l=0}function p(){}function J(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function K(a,b,c){r(function(a){var e=!1,f=J(c,b,function(c){e||(e=!0,b!==c?q(a,c):m(a,c))},function(b){e||(e=!0,g(a,b))});!e&&f&&(e=!0,g(a,f))},a)}function L(a,b){1===b.a?m(a,b.b):2===a.a?g(a,b.b):u(b,void 0,function(b){q(a,b)},function(b){g(a,b)})}function q(a,b){if(a===b)g(a,new TypeError("You cannot resolve a promise with itself"));else if("function"===typeof b||"object"===typeof b&&null!==b)if(b.constructor===a.constructor)L(a, | ||
b);else{var c;try{c=b.then}catch(d){v.error=d,c=v}c===v?g(a,v.error):void 0===c?m(a,b):s(c)?K(a,b,c):m(a,b)}else m(a,b)}function M(a){a.f&&a.f(a.b);x(a)}function m(a,b){void 0===a.a&&(a.b=b,a.a=1,0!==a.e.length&&r(x,a))}function g(a,b){void 0===a.a&&(a.a=2,a.b=b,r(M,a))}function u(a,b,c,d){var e=a.e,f=e.length;a.f=null;e[f]=b;e[f+1]=c;e[f+2]=d;0===f&&a.a&&r(x,a)}function x(a){var b=a.e,c=a.a;if(0!==b.length){for(var d,e,f=a.b,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?C(c,d,e,f):e(f);a.e.length=0}}function D(){this.error= | ||
null}function C(a,b,c,d){var e=s(c),f,k,h,l;if(e){try{f=c(d)}catch(n){y.error=n,f=y}f===y?(l=!0,k=f.error,f=null):h=!0;if(b===f){g(b,new TypeError("A promises callback cannot return that same promise."));return}}else f=d,h=!0;void 0===b.a&&(e&&h?q(b,f):l?g(b,k):1===a?m(b,f):2===a&&g(b,f))}function N(a,b){try{b(function(b){q(a,b)},function(b){g(a,b)})}catch(c){g(a,c)}}function k(a,b,c,d){this.n=a;this.c=new a(p,d);this.i=c;this.o(b)?(this.m=b,this.d=this.length=b.length,this.l(),0===this.length?m(this.c, | ||
this.b):(this.length=this.length||0,this.k(),0===this.d&&m(this.c,this.b))):g(this.c,this.p())}function h(a){O++;this.b=this.a=void 0;this.e=[];if(p!==a){if(!s(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof h))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");N(this,a)}}var E=Array.isArray?Array.isArray:function(a){return"[object Array]"=== | ||
Object.prototype.toString.call(a)},l=0,w="undefined"!==typeof window?window:{},B=w.MutationObserver||w.WebKitMutationObserver,w="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel,n=Array(1E3),A;A="undefined"!==typeof process&&"[object process]"==={}.toString.call(process)?F():B?G():w?H():I();var v=new D,y=new D;k.prototype.o=function(a){return E(a)};k.prototype.p=function(){return Error("Array Methods must be provided an Array")};k.prototype.l= | ||
function(){this.b=Array(this.length)};k.prototype.k=function(){for(var a=this.length,b=this.c,c=this.m,d=0;void 0===b.a&&d<a;d++)this.j(c[d],d)};k.prototype.j=function(a,b){var c=this.n;"object"===typeof a&&null!==a?a.constructor===c&&void 0!==a.a?(a.f=null,this.g(a.a,b,a.b)):this.q(c.resolve(a),b):(this.d--,this.b[b]=this.h(a))};k.prototype.g=function(a,b,c){var d=this.c;void 0===d.a&&(this.d--,this.i&&2===a?g(d,c):this.b[b]=this.h(c));0===this.d&&m(d,this.b)};k.prototype.h=function(a){return a}; | ||
k.prototype.q=function(a,b){var c=this;u(a,void 0,function(a){c.g(1,b,a)},function(a){c.g(2,b,a)})};var O=0;h.all=function(a,b){return(new k(this,a,!0,b)).c};h.race=function(a,b){function c(a){q(e,a)}function d(a){g(e,a)}var e=new this(p,b);if(!E(a))return (g(e,new TypeError("You must pass an array to race.")), e);for(var f=a.length,h=0;void 0===e.a&&h<f;h++)u(this.resolve(a[h]),void 0,c,d);return e};h.resolve=function(a,b){if(a&&"object"===typeof a&&a.constructor===this)return a;var c=new this(p,b); | ||
q(c,a);return c};h.reject=function(a,b){var c=new this(p,b);g(c,a);return c};h.prototype={constructor:h,then:function(a,b){var c=this.a;if(1===c&&!a||2===c&&!b)return this;var d=new this.constructor(p),e=this.b;if(c){var f=arguments[c-1];r(function(){C(c,d,f,e)})}else u(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}};var z={Promise:h,polyfill:function(){var a;a="undefined"!==typeof global?global:"undefined"!==typeof window&&window.document?window:self;"Promise"in a&&"resolve"in | ||
a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;new a.Promise(function(a){b=a});return s(b)}()||(a.Promise=h)}};"function"===typeof define&&define.amd?define(function(){return z}):"undefined"!==typeof module&&module.exports?module.exports=z:"undefined"!==typeof this&&(this.ES6Promise=z)}).call(this); | ||
(function(){"use strict";function lib$es6$promise$utils$$objectOrFunction(x){return typeof x==="function"||typeof x==="object"&&x!==null}function lib$es6$promise$utils$$isFunction(x){return typeof x==="function"}function lib$es6$promise$utils$$isMaybeThenable(x){return typeof x==="object"&&x!==null}var lib$es6$promise$utils$$_isArray;if(!Array.isArray){lib$es6$promise$utils$$_isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}}else{lib$es6$promise$utils$$_isArray=Array.isArray}var lib$es6$promise$utils$$isArray=lib$es6$promise$utils$$_isArray;var lib$es6$promise$asap$$len=0;var lib$es6$promise$asap$$toString={}.toString;var lib$es6$promise$asap$$vertxNext;function lib$es6$promise$asap$$asap(callback,arg){lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len]=callback;lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len+1]=arg;lib$es6$promise$asap$$len+=2;if(lib$es6$promise$asap$$len===2){lib$es6$promise$asap$$scheduleFlush()}}var lib$es6$promise$asap$$default=lib$es6$promise$asap$$asap;var lib$es6$promise$asap$$browserWindow=typeof window!=="undefined"?window:undefined;var lib$es6$promise$asap$$browserGlobal=lib$es6$promise$asap$$browserWindow||{};var lib$es6$promise$asap$$BrowserMutationObserver=lib$es6$promise$asap$$browserGlobal.MutationObserver||lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;var lib$es6$promise$asap$$isNode=typeof process!=="undefined"&&{}.toString.call(process)==="[object process]";var lib$es6$promise$asap$$isWorker=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function lib$es6$promise$asap$$useNextTick(){var nextTick=process.nextTick;var version=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);if(Array.isArray(version)&&version[1]==="0"&&version[2]==="10"){nextTick=setImmediate}return function(){nextTick(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useVertxTimer(){return function(){lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useMutationObserver(){var iterations=0;var observer=new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);var node=document.createTextNode("");observer.observe(node,{characterData:true});return function(){node.data=iterations=++iterations%2}}function lib$es6$promise$asap$$useMessageChannel(){var channel=new MessageChannel;channel.port1.onmessage=lib$es6$promise$asap$$flush;return function(){channel.port2.postMessage(0)}}function lib$es6$promise$asap$$useSetTimeout(){return function(){setTimeout(lib$es6$promise$asap$$flush,1)}}var lib$es6$promise$asap$$queue=new Array(1e3);function lib$es6$promise$asap$$flush(){for(var i=0;i<lib$es6$promise$asap$$len;i+=2){var callback=lib$es6$promise$asap$$queue[i];var arg=lib$es6$promise$asap$$queue[i+1];callback(arg);lib$es6$promise$asap$$queue[i]=undefined;lib$es6$promise$asap$$queue[i+1]=undefined}lib$es6$promise$asap$$len=0}function lib$es6$promise$asap$$attemptVertex(){try{var r=require;var vertx=r("vertx");lib$es6$promise$asap$$vertxNext=vertx.runOnLoop||vertx.runOnContext;return lib$es6$promise$asap$$useVertxTimer()}catch(e){return lib$es6$promise$asap$$useSetTimeout()}}var lib$es6$promise$asap$$scheduleFlush;if(lib$es6$promise$asap$$isNode){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useNextTick()}else if(lib$es6$promise$asap$$BrowserMutationObserver){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useMutationObserver()}else if(lib$es6$promise$asap$$isWorker){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useMessageChannel()}else if(lib$es6$promise$asap$$browserWindow===undefined&&typeof require==="function"){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$attemptVertex()}else{lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useSetTimeout()}function lib$es6$promise$$internal$$noop(){}var lib$es6$promise$$internal$$PENDING=void 0;var lib$es6$promise$$internal$$FULFILLED=1;var lib$es6$promise$$internal$$REJECTED=2;var lib$es6$promise$$internal$$GET_THEN_ERROR=new lib$es6$promise$$internal$$ErrorObject;function lib$es6$promise$$internal$$selfFullfillment(){return new TypeError("You cannot resolve a promise with itself")}function lib$es6$promise$$internal$$cannotReturnOwn(){return new TypeError("A promises callback cannot return that same promise.")}function lib$es6$promise$$internal$$getThen(promise){try{return promise.then}catch(error){lib$es6$promise$$internal$$GET_THEN_ERROR.error=error;return lib$es6$promise$$internal$$GET_THEN_ERROR}}function lib$es6$promise$$internal$$tryThen(then,value,fulfillmentHandler,rejectionHandler){try{then.call(value,fulfillmentHandler,rejectionHandler)}catch(e){return e}}function lib$es6$promise$$internal$$handleForeignThenable(promise,thenable,then){lib$es6$promise$asap$$default(function(promise){var sealed=false;var error=lib$es6$promise$$internal$$tryThen(then,thenable,function(value){if(sealed){return}sealed=true;if(thenable!==value){lib$es6$promise$$internal$$resolve(promise,value)}else{lib$es6$promise$$internal$$fulfill(promise,value)}},function(reason){if(sealed){return}sealed=true;lib$es6$promise$$internal$$reject(promise,reason)},"Settle: "+(promise._label||" unknown promise"));if(!sealed&&error){sealed=true;lib$es6$promise$$internal$$reject(promise,error)}},promise)}function lib$es6$promise$$internal$$handleOwnThenable(promise,thenable){if(thenable._state===lib$es6$promise$$internal$$FULFILLED){lib$es6$promise$$internal$$fulfill(promise,thenable._result)}else if(promise._state===lib$es6$promise$$internal$$REJECTED){lib$es6$promise$$internal$$reject(promise,thenable._result)}else{lib$es6$promise$$internal$$subscribe(thenable,undefined,function(value){lib$es6$promise$$internal$$resolve(promise,value)},function(reason){lib$es6$promise$$internal$$reject(promise,reason)})}}function lib$es6$promise$$internal$$handleMaybeThenable(promise,maybeThenable){if(maybeThenable.constructor===promise.constructor){lib$es6$promise$$internal$$handleOwnThenable(promise,maybeThenable)}else{var then=lib$es6$promise$$internal$$getThen(maybeThenable);if(then===lib$es6$promise$$internal$$GET_THEN_ERROR){lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$GET_THEN_ERROR.error)}else if(then===undefined){lib$es6$promise$$internal$$fulfill(promise,maybeThenable)}else if(lib$es6$promise$utils$$isFunction(then)){lib$es6$promise$$internal$$handleForeignThenable(promise,maybeThenable,then)}else{lib$es6$promise$$internal$$fulfill(promise,maybeThenable)}}}function lib$es6$promise$$internal$$resolve(promise,value){if(promise===value){lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$selfFullfillment())}else if(lib$es6$promise$utils$$objectOrFunction(value)){lib$es6$promise$$internal$$handleMaybeThenable(promise,value)}else{lib$es6$promise$$internal$$fulfill(promise,value)}}function lib$es6$promise$$internal$$publishRejection(promise){if(promise._onerror){promise._onerror(promise._result)}lib$es6$promise$$internal$$publish(promise)}function lib$es6$promise$$internal$$fulfill(promise,value){if(promise._state!==lib$es6$promise$$internal$$PENDING){return}promise._result=value;promise._state=lib$es6$promise$$internal$$FULFILLED;if(promise._subscribers.length!==0){lib$es6$promise$asap$$default(lib$es6$promise$$internal$$publish,promise)}}function lib$es6$promise$$internal$$reject(promise,reason){if(promise._state!==lib$es6$promise$$internal$$PENDING){return}promise._state=lib$es6$promise$$internal$$REJECTED;promise._result=reason;lib$es6$promise$asap$$default(lib$es6$promise$$internal$$publishRejection,promise)}function lib$es6$promise$$internal$$subscribe(parent,child,onFulfillment,onRejection){var subscribers=parent._subscribers;var length=subscribers.length;parent._onerror=null;subscribers[length]=child;subscribers[length+lib$es6$promise$$internal$$FULFILLED]=onFulfillment;subscribers[length+lib$es6$promise$$internal$$REJECTED]=onRejection;if(length===0&&parent._state){lib$es6$promise$asap$$default(lib$es6$promise$$internal$$publish,parent)}}function lib$es6$promise$$internal$$publish(promise){var subscribers=promise._subscribers;var settled=promise._state;if(subscribers.length===0){return}var child,callback,detail=promise._result;for(var i=0;i<subscribers.length;i+=3){child=subscribers[i];callback=subscribers[i+settled];if(child){lib$es6$promise$$internal$$invokeCallback(settled,child,callback,detail)}else{callback(detail)}}promise._subscribers.length=0}function lib$es6$promise$$internal$$ErrorObject(){this.error=null}var lib$es6$promise$$internal$$TRY_CATCH_ERROR=new lib$es6$promise$$internal$$ErrorObject;function lib$es6$promise$$internal$$tryCatch(callback,detail){try{return callback(detail)}catch(e){lib$es6$promise$$internal$$TRY_CATCH_ERROR.error=e;return lib$es6$promise$$internal$$TRY_CATCH_ERROR}}function lib$es6$promise$$internal$$invokeCallback(settled,promise,callback,detail){var hasCallback=lib$es6$promise$utils$$isFunction(callback),value,error,succeeded,failed;if(hasCallback){value=lib$es6$promise$$internal$$tryCatch(callback,detail);if(value===lib$es6$promise$$internal$$TRY_CATCH_ERROR){failed=true;error=value.error;value=null}else{succeeded=true}if(promise===value){lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$cannotReturnOwn());return}}else{value=detail;succeeded=true}if(promise._state!==lib$es6$promise$$internal$$PENDING){}else if(hasCallback&&succeeded){lib$es6$promise$$internal$$resolve(promise,value)}else if(failed){lib$es6$promise$$internal$$reject(promise,error)}else if(settled===lib$es6$promise$$internal$$FULFILLED){lib$es6$promise$$internal$$fulfill(promise,value)}else if(settled===lib$es6$promise$$internal$$REJECTED){lib$es6$promise$$internal$$reject(promise,value)}}function lib$es6$promise$$internal$$initializePromise(promise,resolver){try{resolver(function resolvePromise(value){lib$es6$promise$$internal$$resolve(promise,value)},function rejectPromise(reason){lib$es6$promise$$internal$$reject(promise,reason)})}catch(e){lib$es6$promise$$internal$$reject(promise,e)}}function lib$es6$promise$enumerator$$Enumerator(Constructor,input){var enumerator=this;enumerator._instanceConstructor=Constructor;enumerator.promise=new Constructor(lib$es6$promise$$internal$$noop);if(enumerator._validateInput(input)){enumerator._input=input;enumerator.length=input.length;enumerator._remaining=input.length;enumerator._init();if(enumerator.length===0){lib$es6$promise$$internal$$fulfill(enumerator.promise,enumerator._result)}else{enumerator.length=enumerator.length||0;enumerator._enumerate();if(enumerator._remaining===0){lib$es6$promise$$internal$$fulfill(enumerator.promise,enumerator._result)}}}else{lib$es6$promise$$internal$$reject(enumerator.promise,enumerator._validationError())}}lib$es6$promise$enumerator$$Enumerator.prototype._validateInput=function(input){return lib$es6$promise$utils$$isArray(input)};lib$es6$promise$enumerator$$Enumerator.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")};lib$es6$promise$enumerator$$Enumerator.prototype._init=function(){this._result=new Array(this.length)};var lib$es6$promise$enumerator$$default=lib$es6$promise$enumerator$$Enumerator;lib$es6$promise$enumerator$$Enumerator.prototype._enumerate=function(){var enumerator=this;var length=enumerator.length;var promise=enumerator.promise;var input=enumerator._input;for(var i=0;promise._state===lib$es6$promise$$internal$$PENDING&&i<length;i++){enumerator._eachEntry(input[i],i)}};lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry=function(entry,i){var enumerator=this;var c=enumerator._instanceConstructor;if(lib$es6$promise$utils$$isMaybeThenable(entry)){if(entry.constructor===c&&entry._state!==lib$es6$promise$$internal$$PENDING){entry._onerror=null;enumerator._settledAt(entry._state,i,entry._result)}else{enumerator._willSettleAt(c.resolve(entry),i)}}else{enumerator._remaining--;enumerator._result[i]=entry}};lib$es6$promise$enumerator$$Enumerator.prototype._settledAt=function(state,i,value){var enumerator=this;var promise=enumerator.promise;if(promise._state===lib$es6$promise$$internal$$PENDING){enumerator._remaining--;if(state===lib$es6$promise$$internal$$REJECTED){lib$es6$promise$$internal$$reject(promise,value)}else{enumerator._result[i]=value}}if(enumerator._remaining===0){lib$es6$promise$$internal$$fulfill(promise,enumerator._result)}};lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt=function(promise,i){var enumerator=this;lib$es6$promise$$internal$$subscribe(promise,undefined,function(value){enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED,i,value)},function(reason){enumerator._settledAt(lib$es6$promise$$internal$$REJECTED,i,reason)})};function lib$es6$promise$promise$all$$all(entries){return new lib$es6$promise$enumerator$$default(this,entries).promise}var lib$es6$promise$promise$all$$default=lib$es6$promise$promise$all$$all;function lib$es6$promise$promise$race$$race(entries){var Constructor=this;var promise=new Constructor(lib$es6$promise$$internal$$noop);if(!lib$es6$promise$utils$$isArray(entries)){lib$es6$promise$$internal$$reject(promise,new TypeError("You must pass an array to race."));return promise}var length=entries.length;function onFulfillment(value){lib$es6$promise$$internal$$resolve(promise,value)}function onRejection(reason){lib$es6$promise$$internal$$reject(promise,reason)}for(var i=0;promise._state===lib$es6$promise$$internal$$PENDING&&i<length;i++){lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]),undefined,onFulfillment,onRejection)}return promise}var lib$es6$promise$promise$race$$default=lib$es6$promise$promise$race$$race;function lib$es6$promise$promise$resolve$$resolve(object){var Constructor=this;if(object&&typeof object==="object"&&object.constructor===Constructor){return object}var promise=new Constructor(lib$es6$promise$$internal$$noop);lib$es6$promise$$internal$$resolve(promise,object);return promise}var lib$es6$promise$promise$resolve$$default=lib$es6$promise$promise$resolve$$resolve;function lib$es6$promise$promise$reject$$reject(reason){var Constructor=this;var promise=new Constructor(lib$es6$promise$$internal$$noop);lib$es6$promise$$internal$$reject(promise,reason);return promise}var lib$es6$promise$promise$reject$$default=lib$es6$promise$promise$reject$$reject;var lib$es6$promise$promise$$counter=0;function lib$es6$promise$promise$$needsResolver(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function lib$es6$promise$promise$$needsNew(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var lib$es6$promise$promise$$default=lib$es6$promise$promise$$Promise;function lib$es6$promise$promise$$Promise(resolver){this._id=lib$es6$promise$promise$$counter++;this._state=undefined;this._result=undefined;this._subscribers=[];if(lib$es6$promise$$internal$$noop!==resolver){if(!lib$es6$promise$utils$$isFunction(resolver)){lib$es6$promise$promise$$needsResolver()}if(!(this instanceof lib$es6$promise$promise$$Promise)){lib$es6$promise$promise$$needsNew()}lib$es6$promise$$internal$$initializePromise(this,resolver)}}lib$es6$promise$promise$$Promise.all=lib$es6$promise$promise$all$$default;lib$es6$promise$promise$$Promise.race=lib$es6$promise$promise$race$$default;lib$es6$promise$promise$$Promise.resolve=lib$es6$promise$promise$resolve$$default;lib$es6$promise$promise$$Promise.reject=lib$es6$promise$promise$reject$$default;lib$es6$promise$promise$$Promise.prototype={constructor:lib$es6$promise$promise$$Promise,then:function(onFulfillment,onRejection){var parent=this;var state=parent._state;if(state===lib$es6$promise$$internal$$FULFILLED&&!onFulfillment||state===lib$es6$promise$$internal$$REJECTED&&!onRejection){return this}var child=new this.constructor(lib$es6$promise$$internal$$noop);var result=parent._result;if(state){var callback=arguments[state-1];lib$es6$promise$asap$$default(function(){lib$es6$promise$$internal$$invokeCallback(state,child,callback,result)})}else{lib$es6$promise$$internal$$subscribe(parent,child,onFulfillment,onRejection)}return child},"catch":function(onRejection){return this.then(null,onRejection)}};function lib$es6$promise$polyfill$$polyfill(){var local;if(typeof global!=="undefined"){local=global}else if(typeof self!=="undefined"){local=self}else{try{local=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}}var P=local.Promise;if(P&&Object.prototype.toString.call(P.resolve())==="[object Promise]"&&!P.cast){return}local.Promise=lib$es6$promise$promise$$default}var lib$es6$promise$polyfill$$default=lib$es6$promise$polyfill$$polyfill;var lib$es6$promise$umd$$ES6Promise={Promise:lib$es6$promise$promise$$default,polyfill:lib$es6$promise$polyfill$$default};if(typeof define==="function"&&define["amd"]){define(function(){return lib$es6$promise$umd$$ES6Promise})}else if(typeof module!=="undefined"&&module["exports"]){module["exports"]=lib$es6$promise$umd$$ES6Promise}else if(typeof this!=="undefined"){this["ES6Promise"]=lib$es6$promise$umd$$ES6Promise}lib$es6$promise$polyfill$$default()}).call(this); |
@@ -17,1 +17,3 @@ import Promise from './es6-promise/promise'; | ||
} | ||
polyfill(); |
@@ -21,3 +21,3 @@ import { | ||
function cannotReturnOwn() { | ||
return new TypeError('A promises callback cannot return that same promise.') | ||
return new TypeError('A promises callback cannot return that same promise.'); | ||
} | ||
@@ -123,4 +123,3 @@ | ||
if (promise._subscribers.length === 0) { | ||
} else { | ||
if (promise._subscribers.length !== 0) { | ||
asap(publish, promise); | ||
@@ -127,0 +126,0 @@ } |
var len = 0; | ||
var toString = {}.toString; | ||
var vertxNext; | ||
export default function asap(callback, arg) { | ||
@@ -8,3 +9,3 @@ queue[len] = callback; | ||
if (len === 2) { | ||
// If len is 1, that means that we need to schedule an async flush. | ||
// If len is 2, that means that we need to schedule an async flush. | ||
// If additional callbacks are queued before the queue is flushed, they | ||
@@ -16,4 +17,6 @@ // will be processed by this flush that we are scheduling. | ||
var browserGlobal = (typeof window !== 'undefined') ? window : {}; | ||
var browserWindow = (typeof window !== 'undefined') ? window : undefined; | ||
var browserGlobal = browserWindow || {}; | ||
var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; | ||
var isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; | ||
@@ -27,7 +30,21 @@ // test for web worker but not in IE10 | ||
function useNextTick() { | ||
var nextTick = process.nextTick; | ||
// node version 0.10.x displays a deprecation warning when nextTick is used recursively | ||
// setImmediate should be used instead instead | ||
var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); | ||
if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { | ||
nextTick = setImmediate; | ||
} | ||
return function() { | ||
process.nextTick(flush); | ||
nextTick(flush); | ||
}; | ||
} | ||
// vertx | ||
function useVertxTimer() { | ||
return function() { | ||
vertxNext(flush); | ||
}; | ||
} | ||
function useMutationObserver() { | ||
@@ -74,6 +91,16 @@ var iterations = 0; | ||
function attemptVertex() { | ||
try { | ||
var r = require; | ||
var vertx = r('vertx'); | ||
vertxNext = vertx.runOnLoop || vertx.runOnContext; | ||
return useVertxTimer(); | ||
} catch(e) { | ||
return useSetTimeout(); | ||
} | ||
} | ||
var scheduleFlush; | ||
// Decide what async method to use to triggering processing of queued callbacks: | ||
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { | ||
if (isNode) { | ||
scheduleFlush = useNextTick(); | ||
@@ -84,4 +111,6 @@ } else if (BrowserMutationObserver) { | ||
scheduleFlush = useMessageChannel(); | ||
} else if (browserWindow === undefined && typeof require === 'function') { | ||
scheduleFlush = attemptVertex(); | ||
} else { | ||
scheduleFlush = useSetTimeout(); | ||
} |
@@ -16,39 +16,26 @@ import { | ||
export function makeSettledResult(state, position, value) { | ||
if (state === FULFILLED) { | ||
return { | ||
state: 'fulfilled', | ||
value: value | ||
}; | ||
} else { | ||
return { | ||
state: 'rejected', | ||
reason: value | ||
}; | ||
} | ||
} | ||
function Enumerator(Constructor, input) { | ||
var enumerator = this; | ||
function Enumerator(Constructor, input, abortOnReject, label) { | ||
this._instanceConstructor = Constructor; | ||
this.promise = new Constructor(noop, label); | ||
this._abortOnReject = abortOnReject; | ||
enumerator._instanceConstructor = Constructor; | ||
enumerator.promise = new Constructor(noop); | ||
if (this._validateInput(input)) { | ||
this._input = input; | ||
this.length = input.length; | ||
this._remaining = input.length; | ||
if (enumerator._validateInput(input)) { | ||
enumerator._input = input; | ||
enumerator.length = input.length; | ||
enumerator._remaining = input.length; | ||
this._init(); | ||
enumerator._init(); | ||
if (this.length === 0) { | ||
fulfill(this.promise, this._result); | ||
if (enumerator.length === 0) { | ||
fulfill(enumerator.promise, enumerator._result); | ||
} else { | ||
this.length = this.length || 0; | ||
this._enumerate(); | ||
if (this._remaining === 0) { | ||
fulfill(this.promise, this._result); | ||
enumerator.length = enumerator.length || 0; | ||
enumerator._enumerate(); | ||
if (enumerator._remaining === 0) { | ||
fulfill(enumerator.promise, enumerator._result); | ||
} | ||
} | ||
} else { | ||
reject(this.promise, this._validationError()); | ||
reject(enumerator.promise, enumerator._validationError()); | ||
} | ||
@@ -72,8 +59,10 @@ } | ||
Enumerator.prototype._enumerate = function() { | ||
var length = this.length; | ||
var promise = this.promise; | ||
var input = this._input; | ||
var enumerator = this; | ||
var length = enumerator.length; | ||
var promise = enumerator.promise; | ||
var input = enumerator._input; | ||
for (var i = 0; promise._state === PENDING && i < length; i++) { | ||
this._eachEntry(input[i], i); | ||
enumerator._eachEntry(input[i], i); | ||
} | ||
@@ -83,13 +72,15 @@ }; | ||
Enumerator.prototype._eachEntry = function(entry, i) { | ||
var c = this._instanceConstructor; | ||
var enumerator = this; | ||
var c = enumerator._instanceConstructor; | ||
if (isMaybeThenable(entry)) { | ||
if (entry.constructor === c && entry._state !== PENDING) { | ||
entry._onerror = null; | ||
this._settledAt(entry._state, i, entry._result); | ||
enumerator._settledAt(entry._state, i, entry._result); | ||
} else { | ||
this._willSettleAt(c.resolve(entry), i); | ||
enumerator._willSettleAt(c.resolve(entry), i); | ||
} | ||
} else { | ||
this._remaining--; | ||
this._result[i] = this._makeResult(FULFILLED, i, entry); | ||
enumerator._remaining--; | ||
enumerator._result[i] = entry; | ||
} | ||
@@ -99,23 +90,20 @@ }; | ||
Enumerator.prototype._settledAt = function(state, i, value) { | ||
var promise = this.promise; | ||
var enumerator = this; | ||
var promise = enumerator.promise; | ||
if (promise._state === PENDING) { | ||
this._remaining--; | ||
enumerator._remaining--; | ||
if (this._abortOnReject && state === REJECTED) { | ||
if (state === REJECTED) { | ||
reject(promise, value); | ||
} else { | ||
this._result[i] = this._makeResult(state, i, value); | ||
enumerator._result[i] = value; | ||
} | ||
} | ||
if (this._remaining === 0) { | ||
fulfill(promise, this._result); | ||
if (enumerator._remaining === 0) { | ||
fulfill(promise, enumerator._result); | ||
} | ||
}; | ||
Enumerator.prototype._makeResult = function(state, i, value) { | ||
return value; | ||
}; | ||
Enumerator.prototype._willSettleAt = function(promise, i) { | ||
@@ -122,0 +110,0 @@ var enumerator = this; |
/*global self*/ | ||
import { default as RSVPPromise } from "./promise"; | ||
import { isFunction } from "./utils"; | ||
import Promise from './promise'; | ||
@@ -9,28 +8,20 @@ export default function polyfill() { | ||
if (typeof global !== 'undefined') { | ||
local = global; | ||
} else if (typeof window !== 'undefined' && window.document) { | ||
local = window; | ||
local = global; | ||
} else if (typeof self !== 'undefined') { | ||
local = self; | ||
} else { | ||
local = self; | ||
try { | ||
local = Function('return this')(); | ||
} catch (e) { | ||
throw new Error('polyfill failed because global object is unavailable in this environment'); | ||
} | ||
} | ||
var es6PromiseSupport = | ||
"Promise" in local && | ||
// Some of these methods are missing from | ||
// Firefox/Chrome experimental implementations | ||
"resolve" in local.Promise && | ||
"reject" in local.Promise && | ||
"all" in local.Promise && | ||
"race" in local.Promise && | ||
// Older version of the spec had a resolver object | ||
// as the arg rather than a function | ||
(function() { | ||
var resolve; | ||
new local.Promise(function(r) { resolve = r; }); | ||
return isFunction(resolve); | ||
}()); | ||
var P = local.Promise; | ||
if (!es6PromiseSupport) { | ||
local.Promise = RSVPPromise; | ||
if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { | ||
return; | ||
} | ||
local.Promise = Promise; | ||
} |
import { | ||
isFunction, | ||
now | ||
isFunction | ||
} from './utils'; | ||
@@ -5,0 +4,0 @@ |
@@ -50,4 +50,4 @@ import Enumerator from '../enumerator'; | ||
*/ | ||
export default function all(entries, label) { | ||
return new Enumerator(this, entries, true /* abort on reject */, label).promise; | ||
export default function all(entries) { | ||
return new Enumerator(this, entries).promise; | ||
} |
@@ -74,3 +74,2 @@ import { | ||
@param {Array} promises array of promises to observe | ||
@param {String} label optional string for describing the promise returned. | ||
Useful for tooling. | ||
@@ -80,7 +79,7 @@ @return {Promise} a promise which settles in the same way as the first passed | ||
*/ | ||
export default function race(entries, label) { | ||
export default function race(entries) { | ||
/*jshint validthis:true */ | ||
var Constructor = this; | ||
var promise = new Constructor(noop, label); | ||
var promise = new Constructor(noop); | ||
@@ -87,0 +86,0 @@ if (!isArray(entries)) { |
@@ -37,12 +37,11 @@ import { | ||
@param {Any} reason value that the returned promise will be rejected with. | ||
@param {String} label optional string for identifying the returned promise. | ||
Useful for tooling. | ||
@return {Promise} a promise rejected with the given `reason`. | ||
*/ | ||
export default function reject(reason, label) { | ||
export default function reject(reason) { | ||
/*jshint validthis:true */ | ||
var Constructor = this; | ||
var promise = new Constructor(noop, label); | ||
var promise = new Constructor(noop); | ||
_reject(promise, reason); | ||
return promise; | ||
} |
@@ -33,3 +33,2 @@ import { | ||
@param {Any} value value that the returned promise will be resolved with | ||
@param {String} label optional string for identifying the returned promise. | ||
Useful for tooling. | ||
@@ -39,3 +38,3 @@ @return {Promise} a promise that will become fulfilled with the given | ||
*/ | ||
export default function resolve(object, label) { | ||
export default function resolve(object) { | ||
/*jshint validthis:true */ | ||
@@ -48,5 +47,5 @@ var Constructor = this; | ||
var promise = new Constructor(noop, label); | ||
var promise = new Constructor(noop); | ||
_resolve(promise, object); | ||
return promise; | ||
} |
@@ -23,18 +23,1 @@ export function objectOrFunction(x) { | ||
export var isArray = _isArray; | ||
// Date.now is not available in browsers < IE9 | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility | ||
export var now = Date.now || function() { return new Date().getTime(); }; | ||
function F() { } | ||
export var o_create = (Object.create || function (o) { | ||
if (arguments.length > 1) { | ||
throw new Error('Second argument not supported'); | ||
} | ||
if (typeof o !== 'object') { | ||
throw new TypeError('Argument must be an object'); | ||
} | ||
F.prototype = o; | ||
return new F(); | ||
}); |
{ | ||
"name": "es6-promise", | ||
"namespace": "es6-promise", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "A lightweight library that provides tools for organizing asynchronous code", | ||
@@ -10,34 +10,34 @@ "main": "dist/es6-promise.js", | ||
}, | ||
"files": [ | ||
"dist", | ||
"lib" | ||
], | ||
"devDependencies": { | ||
"bower": "^1.3.9", | ||
"brfs": "0.0.8", | ||
"broccoli-closure-compiler": "^0.2.0", | ||
"broccoli-compile-modules": "eventualbuddha/broccoli-compile-modules", | ||
"broccoli-concat": "0.0.7", | ||
"broccoli-es3-safe-recast": "0.0.8", | ||
"broccoli-file-mover": "^0.4.0", | ||
"broccoli-es6-module-transpiler": "^0.5.0", | ||
"broccoli-jshint": "^0.5.1", | ||
"broccoli-merge-trees": "^0.1.4", | ||
"broccoli-static-compiler": "^0.1.4", | ||
"broccoli-string-replace": "0.0.1", | ||
"browserify": "^4.2.0", | ||
"ember-cli": "0.0.40", | ||
"broccoli-replace": "^0.2.0", | ||
"broccoli-stew": "0.0.6", | ||
"broccoli-uglify-js": "^0.1.3", | ||
"broccoli-watchify": "^0.2.0", | ||
"ember-cli": "^0.2.2", | ||
"ember-publisher": "0.0.7", | ||
"es6-module-transpiler-amd-formatter": "0.0.1", | ||
"express": "^4.5.0", | ||
"jshint": "~0.9.1", | ||
"mkdirp": "^0.5.0", | ||
"git-repo-version": "0.0.2", | ||
"json3": "^3.3.2", | ||
"minimatch": "^2.0.1", | ||
"mocha": "^1.20.1", | ||
"promises-aplus-tests": "git://github.com/stefanpenner/promises-tests.git", | ||
"release-it": "0.0.10", | ||
"testem": "^0.6.17", | ||
"json3": "^3.3.2" | ||
"promises-aplus-tests-phantom": "^2.1.0-revise", | ||
"release-it": "0.0.10" | ||
}, | ||
"scripts": { | ||
"test": "testem ci -R dot", | ||
"test-server": "testem", | ||
"build": "ember build", | ||
"start": "ember s", | ||
"test": "ember test", | ||
"test:server": "ember test --server", | ||
"test:node": "ember build && mocha ./dist/test/browserify", | ||
"lint": "jshint lib", | ||
"prepublish": "ember build --environment production", | ||
"aplus": "browserify test/main.js", | ||
"build-all": "ember build --environment production && browserify ./test/main.js -o tmp/test-bundle.js", | ||
"dry-run-release": "ember build --environment production && release-it --dry-run --non-interactive" | ||
@@ -57,3 +57,6 @@ }, | ||
"author": "Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"spm": { | ||
"main": "dist/es6-promise.js" | ||
} | ||
} |
@@ -9,4 +9,3 @@ # ES6-Promise (subset of [rsvp.js](https://github.com/tildeio/rsvp.js)) | ||
* [es6-promise](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.js) | ||
* [es6-promise-min](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.min.js) (~2.2k gzipped) | ||
* [es6-promise](https://raw.githubusercontent.com/jakearchibald/es6-promise/master/dist/es6-promise.js) | ||
@@ -59,2 +58,5 @@ ## Node.js | ||
* `npm run build-all && npm test` - Run Mocha tests through Node and PhantomJS. | ||
* `npm run build` to build | ||
* `npm test` to run tests | ||
* `npm start` to run a build watcher, and webserver to test | ||
* `npm run test:server` for a testem test runner and watching builder |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
689828
18
18348
61
25
3
19
9