diff options
Diffstat (limited to 'deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/socks-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.auto.js')
1 files changed, 383 insertions, 361 deletions
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/socks-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.auto.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/socks-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.auto.js index 51eb80a648..9e5e513f56 100644 --- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/socks-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.auto.js +++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/socks-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/dist/es6-promise.auto.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 4.1.1 + * @version v4.2.4+314e4831 */ (function (global, factory) { @@ -21,7 +21,9 @@ function isFunction(x) { return typeof x === 'function'; } -var _isArray = undefined; + + +var _isArray = void 0; if (Array.isArray) { _isArray = Array.isArray; } else { @@ -33,8 +35,8 @@ if (Array.isArray) { var isArray = _isArray; var len = 0; -var vertxNext = undefined; -var customSchedulerFn = undefined; +var vertxNext = void 0; +var customSchedulerFn = void 0; var asap = function asap(callback, arg) { queue[len] = callback; @@ -63,7 +65,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'; @@ -134,8 +136,7 @@ function flush() { function attemptVertx() { try { - var r = require; - var vertx = r('vertx'); + var vertx = Function('return this')().require('vertx'); vertxNext = vertx.runOnLoop || vertx.runOnContext; return useVertxTimer(); } catch (e) { @@ -143,7 +144,7 @@ function attemptVertx() { } } -var scheduleFlush = undefined; +var scheduleFlush = void 0; // Decide what async method to use to triggering processing of queued callbacks: if (isNode) { scheduleFlush = useNextTick(); @@ -158,8 +159,6 @@ if (isNode) { } function then(onFulfillment, onRejection) { - var _arguments = arguments; - var parent = this; var child = new this.constructor(noop); @@ -170,13 +169,12 @@ function then(onFulfillment, onRejection) { var _state = parent._state; + if (_state) { - (function () { - var callback = _arguments[_state - 1]; - asap(function () { - return invokeCallback(_state, child, callback, parent._result); - }); - })(); + var callback = arguments[_state - 1]; + asap(function () { + return invokeCallback(_state, child, callback, parent._result); + }); } else { subscribe(parent, child, onFulfillment, onRejection); } @@ -228,7 +226,7 @@ function resolve$1(object) { return promise; } -var PROMISE_ID = Math.random().toString(36).substring(16); +var PROMISE_ID = Math.random().toString(36).substring(2); function noop() {} @@ -236,7 +234,7 @@ var PENDING = void 0; var FULFILLED = 1; var REJECTED = 2; -var GET_THEN_ERROR = new ErrorObject(); +var TRY_CATCH_ERROR = { error: null }; function selfFulfillment() { return new TypeError("You cannot resolve a promise with itself"); @@ -250,8 +248,8 @@ function getThen(promise) { try { return promise.then; } catch (error) { - GET_THEN_ERROR.error = error; - return GET_THEN_ERROR; + TRY_CATCH_ERROR.error = error; + return TRY_CATCH_ERROR; } } @@ -310,9 +308,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 === GET_THEN_ERROR) { - reject(promise, GET_THEN_ERROR.error); - GET_THEN_ERROR.error = null; + if (then$$1 === TRY_CATCH_ERROR) { + reject(promise, TRY_CATCH_ERROR.error); + TRY_CATCH_ERROR.error = null; } else if (then$$1 === undefined) { fulfill(promise, maybeThenable); } else if (isFunction(then$$1)) { @@ -368,6 +366,7 @@ function subscribe(parent, child, onFulfillment, onRejection) { var _subscribers = parent._subscribers; var length = _subscribers.length; + parent._onerror = null; _subscribers[length] = child; @@ -387,8 +386,8 @@ function publish(promise) { return; } - var child = undefined, - callback = undefined, + var child = void 0, + callback = void 0, detail = promise._result; for (var i = 0; i < subscribers.length; i += 3) { @@ -405,12 +404,6 @@ 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); @@ -422,10 +415,10 @@ function tryCatch(callback, detail) { function invokeCallback(settled, promise, callback, detail) { var hasCallback = isFunction(callback), - value = undefined, - error = undefined, - succeeded = undefined, - failed = undefined; + value = void 0, + error = void 0, + succeeded = void 0, + failed = void 0; if (hasCallback) { value = tryCatch(callback, detail); @@ -450,14 +443,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) { @@ -484,97 +477,103 @@ function makePromise(promise) { promise._subscribers = []; } -function Enumerator$1(Constructor, input) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop); +function validationError() { + return new Error('Array Methods must be provided an Array'); +} - if (!this.promise[PROMISE_ID]) { - makePromise(this.promise); - } +var Enumerator = function () { + function Enumerator(Constructor, input) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop); + + 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) { - fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(input); - if (this._remaining === 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 { + reject(this.promise, validationError()); } - } else { - reject(this.promise, validationError()); } -} -function validationError() { - return new Error('Array Methods must be provided an Array'); -} + Enumerator.prototype._enumerate = function _enumerate(input) { + for (var i = 0; this._state === PENDING && i < input.length; i++) { + this._eachEntry(input[i], i); + } + }; -Enumerator$1.prototype._enumerate = function (input) { - for (var i = 0; this._state === PENDING && i < input.length; i++) { - this._eachEntry(input[i], i); - } -}; + Enumerator.prototype._eachEntry = function _eachEntry(entry, i) { + var c = this._instanceConstructor; + var resolve$$1 = c.resolve; -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$3) { - var promise = new c(noop); - handleMaybeThenable(promise, entry, _then); - this._willSettleAt(promise, 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(new c(function (resolve$$1) { + return resolve$$1(entry); + }), i); + } } else { - this._willSettleAt(new c(function (resolve$$1) { - return resolve$$1(entry); - }), i); + this._willSettleAt(resolve$$1(entry), i); } - } else { - this._willSettleAt(resolve$$1(entry), i); - } -}; + }; -Enumerator$1.prototype._settledAt = function (state, i, value) { - var promise = this.promise; + Enumerator.prototype._settledAt = function _settledAt(state, i, value) { + var promise = this.promise; - if (promise._state === PENDING) { - this._remaining--; - if (state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = value; + if (promise._state === PENDING) { + this._remaining--; + + 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$1.prototype._willSettleAt = function (promise, i) { - var enumerator = this; + Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) { + var enumerator = this; - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); -}; + subscribe(promise, undefined, function (value) { + return enumerator._settledAt(FULFILLED, i, value); + }, function (reason) { + return enumerator._settledAt(REJECTED, i, reason); + }); + }; + + return Enumerator; +}(); /** `Promise.all` accepts an array of promises, and returns a new promise which @@ -623,8 +622,8 @@ Enumerator$1.prototype._willSettleAt = function (promise, i) { fulfilled, or rejected if any of them become rejected. @static */ -function all$1(entries) { - return new Enumerator$1(this, entries).promise; +function all(entries) { + return new Enumerator(this, entries).promise; } /** @@ -692,7 +691,7 @@ function all$1(entries) { @return {Promise} a promise which settles in the same way as the first passed promise to settle. */ -function race$1(entries) { +function race(entries) { /*jshint validthis:true */ var Constructor = this; @@ -859,301 +858,324 @@ function needsNew() { ``` @class Promise - @param {function} resolver + @param {Function} resolver Useful for tooling. @constructor */ -function Promise$3(resolver) { - this[PROMISE_ID] = nextId(); - this._result = this._state = undefined; - this._subscribers = []; - - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise$3 ? initializePromise(this, resolver) : needsNew(); - } -} -Promise$3.all = all$1; -Promise$3.race = race$1; -Promise$3.resolve = resolve$1; -Promise$3.reject = reject$1; -Promise$3._setScheduler = setScheduler; -Promise$3._setAsap = setAsap; -Promise$3._asap = asap; +var Promise$2 = function () { + function Promise(resolver) { + this[PROMISE_ID] = nextId(); + this._result = this._state = undefined; + this._subscribers = []; -Promise$3.prototype = { - constructor: Promise$3, + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + } + } /** - 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) { + 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 { + // success } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // 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); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ // success - }, function(reason){ - // failure - }); - ``` + } + }); + ``` + 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} + */ - Advanced Example - -------------- + /** + `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} + */ - Synchronous Example - ```javascript - let author, books; + Promise.prototype.catch = function _catch(onRejection) { + return this.then(null, onRejection); + }; - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` + /** + `finally` will be invoked regardless of the promise's fate just as native + try/catch/finally behaves - Errback Example + Synchronous example: ```js - - function foundBooks(books) { - + findAuthor() { + if (Math.random() > 0.5) { + throw new Error(); + } + return new Author(); } - function failure(reason) { - + try { + return findAuthor(); // succeed or fail + } catch(error) { + return findOtherAuther(); + } finally { + // always runs + // doesn't affect the return value } - - 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 - } - }); ``` - Promise Example; + Asynchronous example: - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong + ```js + findAuthor().catch(function(reason){ + return findOtherAuther(); + }).finally(function(){ + // author was either found, or not }); ``` - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. + @method finally + @param {Function} callback @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. - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } + Promise.prototype.finally = function _finally(callback) { + var promise = this; + var constructor = promise.constructor; - // async with promises - findAuthor().catch(function(reason){ - // something went wrong + return promise.then(function (value) { + return constructor.resolve(callback()).then(function () { + return value; + }); + }, function (reason) { + return constructor.resolve(callback()).then(function () { + throw reason; + }); }); - ``` + }; - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ - 'catch': function _catch(onRejection) { - return this.then(null, onRejection); - } -}; + return Promise; +}(); + +Promise$2.prototype.then = then; +Promise$2.all = all; +Promise$2.race = race; +Promise$2.resolve = resolve$1; +Promise$2.reject = reject$1; +Promise$2._setScheduler = setScheduler; +Promise$2._setAsap = setAsap; +Promise$2._asap = asap; /*global self*/ -function polyfill$1() { - var local = undefined; +function polyfill() { + var local = void 0; - 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$3; + local.Promise = Promise$2; } // Strange compat.. -Promise$3.polyfill = polyfill$1; -Promise$3.Promise = Promise$3; +Promise$2.polyfill = polyfill; +Promise$2.Promise = Promise$2; -Promise$3.polyfill(); +Promise$2.polyfill(); -return Promise$3; +return Promise$2; }))); + + //# sourceMappingURL=es6-promise.auto.map |