diff options
Diffstat (limited to 'deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.js')
1 files changed, 360 insertions, 382 deletions
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.js index 80d4645c34..b3724141a8 100644 --- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.js +++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.js @@ -3,7 +3,7 @@ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE - * @version v4.2.4+314e4831 + * @version 4.1.1 */ (function (global, factory) { @@ -21,9 +21,7 @@ function isFunction(x) { return typeof x === 'function'; } - - -var _isArray = void 0; +var _isArray = undefined; if (Array.isArray) { _isArray = Array.isArray; } else { @@ -35,8 +33,8 @@ if (Array.isArray) { var isArray = _isArray; var len = 0; -var vertxNext = void 0; -var customSchedulerFn = void 0; +var vertxNext = undefined; +var customSchedulerFn = undefined; var asap = function asap(callback, arg) { queue[len] = callback; @@ -65,7 +63,7 @@ function setAsap(asapFn) { var browserWindow = typeof window !== 'undefined' ? window : undefined; var browserGlobal = browserWindow || {}; var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; -var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; +var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; // test for web worker but not in IE10 var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; @@ -136,7 +134,8 @@ function flush() { function attemptVertx() { try { - var vertx = Function('return this')().require('vertx'); + var r = require; + var vertx = r('vertx'); vertxNext = vertx.runOnLoop || vertx.runOnContext; return useVertxTimer(); } catch (e) { @@ -144,7 +143,7 @@ function attemptVertx() { } } -var scheduleFlush = void 0; +var scheduleFlush = undefined; // Decide what async method to use to triggering processing of queued callbacks: if (isNode) { scheduleFlush = useNextTick(); @@ -159,6 +158,8 @@ if (isNode) { } function then(onFulfillment, onRejection) { + var _arguments = arguments; + var parent = this; var child = new this.constructor(noop); @@ -169,12 +170,13 @@ function then(onFulfillment, onRejection) { var _state = parent._state; - if (_state) { - var callback = arguments[_state - 1]; - asap(function () { - return invokeCallback(_state, child, callback, parent._result); - }); + (function () { + var callback = _arguments[_state - 1]; + asap(function () { + return invokeCallback(_state, child, callback, parent._result); + }); + })(); } else { subscribe(parent, child, onFulfillment, onRejection); } @@ -226,7 +228,7 @@ function resolve$1(object) { return promise; } -var PROMISE_ID = Math.random().toString(36).substring(2); +var PROMISE_ID = Math.random().toString(36).substring(16); function noop() {} @@ -234,7 +236,7 @@ var PENDING = void 0; var FULFILLED = 1; var REJECTED = 2; -var TRY_CATCH_ERROR = { error: null }; +var GET_THEN_ERROR = new ErrorObject(); function selfFulfillment() { return new TypeError("You cannot resolve a promise with itself"); @@ -248,8 +250,8 @@ function getThen(promise) { try { return promise.then; } catch (error) { - TRY_CATCH_ERROR.error = error; - return TRY_CATCH_ERROR; + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; } } @@ -308,9 +310,9 @@ function handleMaybeThenable(promise, maybeThenable, then$$1) { if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { handleOwnThenable(promise, maybeThenable); } else { - if (then$$1 === TRY_CATCH_ERROR) { - reject(promise, TRY_CATCH_ERROR.error); - TRY_CATCH_ERROR.error = null; + if (then$$1 === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + GET_THEN_ERROR.error = null; } else if (then$$1 === undefined) { fulfill(promise, maybeThenable); } else if (isFunction(then$$1)) { @@ -366,7 +368,6 @@ function subscribe(parent, child, onFulfillment, onRejection) { var _subscribers = parent._subscribers; var length = _subscribers.length; - parent._onerror = null; _subscribers[length] = child; @@ -386,8 +387,8 @@ function publish(promise) { return; } - var child = void 0, - callback = void 0, + var child = undefined, + callback = undefined, detail = promise._result; for (var i = 0; i < subscribers.length; i += 3) { @@ -404,6 +405,12 @@ function publish(promise) { promise._subscribers.length = 0; } +function ErrorObject() { + this.error = null; +} + +var TRY_CATCH_ERROR = new ErrorObject(); + function tryCatch(callback, detail) { try { return callback(detail); @@ -415,10 +422,10 @@ function tryCatch(callback, detail) { function invokeCallback(settled, promise, callback, detail) { var hasCallback = isFunction(callback), - value = void 0, - error = void 0, - succeeded = void 0, - failed = void 0; + value = undefined, + error = undefined, + succeeded = undefined, + failed = undefined; if (hasCallback) { value = tryCatch(callback, detail); @@ -443,14 +450,14 @@ function invokeCallback(settled, promise, callback, detail) { if (promise._state !== PENDING) { // noop } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } } function initializePromise(promise, resolver) { @@ -477,103 +484,97 @@ function makePromise(promise) { promise._subscribers = []; } -function validationError() { - return new Error('Array Methods must be provided an Array'); -} - -var Enumerator = function () { - function Enumerator(Constructor, input) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop); +function Enumerator$1(Constructor, input) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop); - if (!this.promise[PROMISE_ID]) { - makePromise(this.promise); - } + if (!this.promise[PROMISE_ID]) { + makePromise(this.promise); + } - if (isArray(input)) { - this.length = input.length; - this._remaining = input.length; + if (isArray(input)) { + this.length = input.length; + this._remaining = input.length; - this._result = new Array(this.length); + this._result = new Array(this.length); - if (this.length === 0) { + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(input); + if (this._remaining === 0) { fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(input); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } } - } else { - reject(this.promise, validationError()); } + } else { + reject(this.promise, validationError()); } +} - Enumerator.prototype._enumerate = function _enumerate(input) { - for (var i = 0; this._state === PENDING && i < input.length; i++) { - this._eachEntry(input[i], i); - } - }; +function validationError() { + return new Error('Array Methods must be provided an Array'); +} - Enumerator.prototype._eachEntry = function _eachEntry(entry, i) { - var c = this._instanceConstructor; - var resolve$$1 = c.resolve; +Enumerator$1.prototype._enumerate = function (input) { + for (var i = 0; this._state === PENDING && i < input.length; i++) { + this._eachEntry(input[i], i); + } +}; +Enumerator$1.prototype._eachEntry = function (entry, i) { + var c = this._instanceConstructor; + var resolve$$1 = c.resolve; - if (resolve$$1 === resolve$1) { - var _then = getThen(entry); + if (resolve$$1 === resolve$1) { + var _then = getThen(entry); - if (_then === then && entry._state !== PENDING) { - this._settledAt(entry._state, i, entry._result); - } else if (typeof _then !== 'function') { - this._remaining--; - this._result[i] = entry; - } else if (c === Promise$1) { - var promise = new c(noop); - handleMaybeThenable(promise, entry, _then); - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve$$1) { - return resolve$$1(entry); - }), i); - } + if (_then === then && entry._state !== PENDING) { + this._settledAt(entry._state, i, entry._result); + } else if (typeof _then !== 'function') { + this._remaining--; + this._result[i] = entry; + } else if (c === Promise$2) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, _then); + this._willSettleAt(promise, i); } else { - this._willSettleAt(resolve$$1(entry), i); + this._willSettleAt(new c(function (resolve$$1) { + return resolve$$1(entry); + }), i); } - }; - - Enumerator.prototype._settledAt = function _settledAt(state, i, value) { - var promise = this.promise; + } else { + this._willSettleAt(resolve$$1(entry), i); + } +}; +Enumerator$1.prototype._settledAt = function (state, i, value) { + var promise = this.promise; - if (promise._state === PENDING) { - this._remaining--; + if (promise._state === PENDING) { + this._remaining--; - if (state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = value; - } + if (state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = value; } + } - if (this._remaining === 0) { - fulfill(promise, this._result); - } - }; + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; - Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) { - var enumerator = this; +Enumerator$1.prototype._willSettleAt = function (promise, i) { + var enumerator = this; - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); - }; - - return Enumerator; -}(); + subscribe(promise, undefined, function (value) { + return enumerator._settledAt(FULFILLED, i, value); + }, function (reason) { + return enumerator._settledAt(REJECTED, i, reason); + }); +}; /** `Promise.all` accepts an array of promises, and returns a new promise which @@ -622,8 +623,8 @@ var Enumerator = function () { fulfilled, or rejected if any of them become rejected. @static */ -function all(entries) { - return new Enumerator(this, entries).promise; +function all$1(entries) { + return new Enumerator$1(this, entries).promise; } /** @@ -691,7 +692,7 @@ function all(entries) { @return {Promise} a promise which settles in the same way as the first passed promise to settle. */ -function race(entries) { +function race$1(entries) { /*jshint validthis:true */ var Constructor = this; @@ -858,322 +859,299 @@ function needsNew() { ``` @class Promise - @param {Function} resolver + @param {function} resolver Useful for tooling. @constructor */ +function Promise$2(resolver) { + this[PROMISE_ID] = nextId(); + this._result = this._state = undefined; + this._subscribers = []; + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise$2 ? initializePromise(this, resolver) : needsNew(); + } +} -var Promise$1 = function () { - function Promise(resolver) { - this[PROMISE_ID] = nextId(); - this._result = this._state = undefined; - this._subscribers = []; +Promise$2.all = all$1; +Promise$2.race = race$1; +Promise$2.resolve = resolve$1; +Promise$2.reject = reject$1; +Promise$2._setScheduler = setScheduler; +Promise$2._setAsap = setAsap; +Promise$2._asap = asap; - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); - } - } +Promise$2.prototype = { + constructor: Promise$2, /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - Chaining - -------- - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we're unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - Assimilation - ------------ - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - If the assimliated promise rejects, then the downstream promise will also reject. - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - Simple Example - -------------- - Synchronous Example - ```javascript - let result; - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - Errback Example - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + let result; + + try { + result = findResult(); // success - } - }); - ``` - Promise Example; - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - Advanced Example - -------------- - Synchronous Example - ```javascript - let author, books; - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - Errback Example - ```js - function foundBooks(books) { - } - function failure(reason) { - } - findAuthor(function(author, err){ - if (err) { - failure(err); + } catch(reason) { // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ // success - } - }); - ``` - Promise Example; - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. - @return {Promise} - */ + }, function(reason){ + // failure + }); + ``` - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ + Advanced Example + -------------- + Synchronous Example - Promise.prototype.catch = function _catch(onRejection) { - return this.then(null, onRejection); - }; + ```javascript + let author, books; - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` - Synchronous example: + Errback Example ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); - } - return new Author(); + + function foundBooks(books) { + } - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't affect the return value + function failure(reason) { + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); + } + // success + } + }); ``` - Asynchronous example: + Promise Example; - ```js - findAuthor().catch(function(reason){ - return findOtherAuther(); - }).finally(function(){ - // author was either found, or not + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong }); ``` - @method finally - @param {Function} callback + @method then + @param {Function} onFulfilled + @param {Function} onRejected + Useful for tooling. @return {Promise} */ + then: then, + /** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. - Promise.prototype.finally = function _finally(callback) { - var promise = this; - var constructor = promise.constructor; + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } - return promise.then(function (value) { - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - return constructor.resolve(callback()).then(function () { - throw reason; - }); - }); - }; + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } - return Promise; -}(); + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` -Promise$1.prototype.then = then; -Promise$1.all = all; -Promise$1.race = race; -Promise$1.resolve = resolve$1; -Promise$1.reject = reject$1; -Promise$1._setScheduler = setScheduler; -Promise$1._setAsap = setAsap; -Promise$1._asap = asap; + @method catch + @param {Function} onRejection + Useful for tooling. + @return {Promise} + */ + 'catch': function _catch(onRejection) { + return this.then(null, onRejection); + } +}; /*global self*/ -function polyfill() { - var local = void 0; +function polyfill$1() { + var local = undefined; - 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'); + 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; + var P = local.Promise; - if (P) { - var promiseToString = null; - try { - promiseToString = Object.prototype.toString.call(P.resolve()); - } catch (e) { - // silently ignored - } + if (P) { + var promiseToString = null; + try { + promiseToString = Object.prototype.toString.call(P.resolve()); + } catch (e) { + // silently ignored + } - if (promiseToString === '[object Promise]' && !P.cast) { - return; + if (promiseToString === '[object Promise]' && !P.cast) { + return; + } } - } - local.Promise = Promise$1; + local.Promise = Promise$2; } // Strange compat.. -Promise$1.polyfill = polyfill; -Promise$1.Promise = Promise$1; +Promise$2.polyfill = polyfill$1; +Promise$2.Promise = Promise$2; -return Promise$1; +return Promise$2; }))); - - //# sourceMappingURL=es6-promise.map |