@@ -2119,14 +2119,24 @@ stringify.stable = deterministicStringify
21192119stringify.stableStringify = deterministicStringify
21202120
21212121var arr = []
2122+ var replacerStack = []
21222123
21232124// Regular stringify
21242125function stringify (obj, replacer, spacer) {
21252126 decirc(obj, '', [], undefined)
2126- var res = JSON.stringify(obj, replacer, spacer)
2127+ var res
2128+ if (replacerStack.length === 0) {
2129+ res = JSON.stringify(obj, replacer, spacer)
2130+ } else {
2131+ res = JSON.stringify(obj, replaceGetterValues(replacer), spacer)
2132+ }
21272133 while (arr.length !== 0) {
21282134 var part = arr.pop()
2129- part[0][part[1]] = part[2]
2135+ if (part.length === 4) {
2136+ Object.defineProperty(part[0], part[1], part[3])
2137+ } else {
2138+ part[0][part[1]] = part[2]
2139+ }
21302140 }
21312141 return res
21322142}
@@ -2135,8 +2145,18 @@ function decirc (val, k, stack, parent) {
21352145 if (typeof val === 'object' && val !== null) {
21362146 for (i = 0; i < stack.length; i++) {
21372147 if (stack[i] === val) {
2138- parent[k] = '[Circular]'
2139- arr.push([parent, k, val])
2148+ var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k)
2149+ if (propertyDescriptor.get !== undefined) {
2150+ if (propertyDescriptor.configurable) {
2151+ Object.defineProperty(parent, k, { value: '[Circular]' })
2152+ arr.push([parent, k, val, propertyDescriptor])
2153+ } else {
2154+ replacerStack.push([val, k])
2155+ }
2156+ } else {
2157+ parent[k] = '[Circular]'
2158+ arr.push([parent, k, val])
2159+ }
21402160 return
21412161 }
21422162 }
@@ -2170,10 +2190,19 @@ function compareFunction (a, b) {
21702190
21712191function deterministicStringify (obj, replacer, spacer) {
21722192 var tmp = deterministicDecirc(obj, '', [], undefined) || obj
2173- var res = JSON.stringify(tmp, replacer, spacer)
2193+ var res
2194+ if (replacerStack.length === 0) {
2195+ res = JSON.stringify(tmp, replacer, spacer)
2196+ } else {
2197+ res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer)
2198+ }
21742199 while (arr.length !== 0) {
21752200 var part = arr.pop()
2176- part[0][part[1]] = part[2]
2201+ if (part.length === 4) {
2202+ Object.defineProperty(part[0], part[1], part[3])
2203+ } else {
2204+ part[0][part[1]] = part[2]
2205+ }
21772206 }
21782207 return res
21792208}
@@ -2183,8 +2212,18 @@ function deterministicDecirc (val, k, stack, parent) {
21832212 if (typeof val === 'object' && val !== null) {
21842213 for (i = 0; i < stack.length; i++) {
21852214 if (stack[i] === val) {
2186- parent[k] = '[Circular]'
2187- arr.push([parent, k, val])
2215+ var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k)
2216+ if (propertyDescriptor.get !== undefined) {
2217+ if (propertyDescriptor.configurable) {
2218+ Object.defineProperty(parent, k, { value: '[Circular]' })
2219+ arr.push([parent, k, val, propertyDescriptor])
2220+ } else {
2221+ replacerStack.push([val, k])
2222+ }
2223+ } else {
2224+ parent[k] = '[Circular]'
2225+ arr.push([parent, k, val])
2226+ }
21882227 return
21892228 }
21902229 }
@@ -2217,6 +2256,25 @@ function deterministicDecirc (val, k, stack, parent) {
22172256 }
22182257}
22192258
2259+ // wraps replacer function to handle values we couldn't replace
2260+ // and mark them as [Circular]
2261+ function replaceGetterValues (replacer) {
2262+ replacer = replacer !== undefined ? replacer : function (k, v) { return v }
2263+ return function (key, val) {
2264+ if (replacerStack.length > 0) {
2265+ for (var i = 0; i < replacerStack.length; i++) {
2266+ var part = replacerStack[i]
2267+ if (part[1] === key && part[0] === val) {
2268+ val = '[Circular]'
2269+ replacerStack.splice(i, 1)
2270+ break
2271+ }
2272+ }
2273+ }
2274+ return replacer.call(this, key, val)
2275+ }
2276+ }
2277+
22202278},{}],6:[function(require,module,exports){
22212279exports.read = function (buffer, offset, isLE, mLen, nBytes) {
22222280 var e, m
@@ -2504,7 +2562,7 @@ function Agent() {
25042562 this._defaults = [];
25052563}
25062564
2507- ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert'].forEach(function (fn) {
2565+ ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts' ].forEach(function (fn) {
25082566 // Default setting for all requests from this agent
25092567 Agent.prototype[fn] = function () {
25102568 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -2527,6 +2585,7 @@ Agent.prototype._setDefaults = function (req) {
25272585};
25282586
25292587module.exports = Agent;
2588+
25302589},{}],9:[function(require,module,exports){
25312590"use strict";
25322591
@@ -2599,19 +2658,19 @@ request.getXHR = function () {
25992658
26002659 try {
26012660 return new ActiveXObject('Microsoft.XMLHTTP');
2602- } catch (err ) {}
2661+ } catch (_unused ) {}
26032662
26042663 try {
26052664 return new ActiveXObject('Msxml2.XMLHTTP.6.0');
2606- } catch (err ) {}
2665+ } catch (_unused2 ) {}
26072666
26082667 try {
26092668 return new ActiveXObject('Msxml2.XMLHTTP.3.0');
2610- } catch (err ) {}
2669+ } catch (_unused3 ) {}
26112670
26122671 try {
26132672 return new ActiveXObject('Msxml2.XMLHTTP');
2614- } catch (err ) {}
2673+ } catch (_unused4 ) {}
26152674
26162675 throw new Error('Browser-only version of superagent could not find XHR');
26172676};
@@ -2661,7 +2720,7 @@ function pushEncodedKeyValuePair(pairs, key, val) {
26612720 if (val === undefined) return;
26622721
26632722 if (val === null) {
2664- pairs.push(encodeURIComponent (key));
2723+ pairs.push(encodeURI (key));
26652724 return;
26662725 }
26672726
@@ -2674,7 +2733,7 @@ function pushEncodedKeyValuePair(pairs, key, val) {
26742733 if (Object.prototype.hasOwnProperty.call(val, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), val[subkey]);
26752734 }
26762735 } else {
2677- pairs.push(encodeURIComponent (key) + '=' + encodeURIComponent(val));
2736+ pairs.push(encodeURI (key) + '=' + encodeURIComponent(val));
26782737 }
26792738}
26802739/**
@@ -2955,10 +3014,10 @@ function Request(method, url) {
29553014
29563015 try {
29573016 res = new Response(self);
2958- } catch (err2 ) {
3017+ } catch (err_ ) {
29593018 err = new Error('Parser is unable to parse the response');
29603019 err.parse = true;
2961- err.original = err2 ; // issue #675: return the raw response if the response parsing fails
3020+ err.original = err_ ; // issue #675: return the raw response if the response parsing fails
29623021
29633022 if (self.xhr) {
29643023 // ie9 doesn't have 'response' property
@@ -2979,10 +3038,10 @@ function Request(method, url) {
29793038
29803039 try {
29813040 if (!self._isResponseOK(res)) {
2982- new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
3041+ new_err = new Error(res.statusText || res.text || 'Unsuccessful HTTP response');
29833042 }
2984- } catch (err2 ) {
2985- new_err = err2 ; // ok() callback can throw
3043+ } catch (err_ ) {
3044+ new_err = err_ ; // ok() callback can throw
29863045 } // #1000 don't catch errors from the callback to avoid double calling it
29873046
29883047
@@ -3196,8 +3255,8 @@ Request.prototype.agent = function () {
31963255 return this;
31973256};
31983257
3199- Request.prototype.buffer = Request.prototype.ca ;
3200- Request.prototype.ca = Request.prototype.agent ; // This throws, because it can't send/receive data as expected
3258+ Request.prototype.ca = Request.prototype.agent ;
3259+ Request.prototype.buffer = Request.prototype.ca ; // This throws, because it can't send/receive data as expected
32013260
32023261Request.prototype.write = function () {
32033262 throw new Error('Streaming is not supported in browser version of superagent');
@@ -3279,7 +3338,7 @@ Request.prototype._end = function () {
32793338
32803339 try {
32813340 status = xhr.status;
3282- } catch (err ) {
3341+ } catch (_unused5 ) {
32833342 status = 0;
32843343 }
32853344
@@ -3312,7 +3371,7 @@ Request.prototype._end = function () {
33123371 if (xhr.upload) {
33133372 xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
33143373 }
3315- } catch (err ) {// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.
3374+ } catch (_unused6 ) {// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.
33163375 // Reported here:
33173376 // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context
33183377 }
@@ -3547,6 +3606,7 @@ request.put = function (url, data, fn) {
35473606 if (fn) req.end(fn);
35483607 return req;
35493608};
3609+
35503610},{"./agent-base":8,"./is-object":10,"./request-base":11,"./response-base":12,"component-emitter":4,"fast-safe-stringify":5}],10:[function(require,module,exports){
35513611"use strict";
35523612
@@ -3564,6 +3624,7 @@ function isObject(obj) {
35643624}
35653625
35663626module.exports = isObject;
3627+
35673628},{}],11:[function(require,module,exports){
35683629"use strict";
35693630
@@ -3761,15 +3822,15 @@ RequestBase.prototype._shouldRetry = function (err, res) {
37613822
37623823 if (override === true) return true;
37633824 if (override === false) return false; // undefined falls back to defaults
3764- } catch (err2 ) {
3765- console.error(err2 );
3825+ } catch (err_ ) {
3826+ console.error(err_ );
37663827 }
37673828 }
37683829
37693830 if (res && res.status && res.status >= 500 && res.status !== 501) return true;
37703831
37713832 if (err) {
3772- if (err.code && ERROR_CODES.indexOf (err.code) !== -1 ) return true; // Superagent timeout
3833+ if (err.code && ERROR_CODES.includes (err.code)) return true; // Superagent timeout
37733834
37743835 if (err.timeout && err.code === 'ECONNABORTED') return true;
37753836 if (err.crossDomain) return true;
@@ -3795,6 +3856,7 @@ RequestBase.prototype._retry = function () {
37953856
37963857 this._aborted = false;
37973858 this.timedout = false;
3859+ this.timedoutError = null;
37983860 return this._end();
37993861};
38003862/**
@@ -3818,6 +3880,11 @@ RequestBase.prototype.then = function (resolve, reject) {
38183880
38193881 this._fullfilledPromise = new Promise(function (resolve, reject) {
38203882 self.on('abort', function () {
3883+ if (_this.timedout && _this.timedoutError) {
3884+ reject(_this.timedoutError);
3885+ return;
3886+ }
3887+
38213888 var err = new Error('Aborted');
38223889 err.code = 'ABORTED';
38233890 err.status = _this.status;
@@ -3924,8 +3991,7 @@ RequestBase.prototype.set = function (field, val) {
39243991 this._header[field.toLowerCase()] = val;
39253992 this.header[field] = val;
39263993 return this;
3927- }; // eslint-disable-next-line valid-jsdoc
3928-
3994+ };
39293995/**
39303996 * Remove header `field`.
39313997 * Case-insensitive.
@@ -4248,7 +4314,7 @@ RequestBase.prototype._finalizeQueryString = function () {
42484314 var query = this._query.join('&');
42494315
42504316 if (query) {
4251- this.url += (this.url.indexOf ('?') >= 0 ? '&' : '?') + query;
4317+ this.url += (this.url.includes ('?') ? '&' : '?') + query;
42524318 }
42534319
42544320 this._query.length = 0; // Makes the call idempotent
@@ -4257,15 +4323,15 @@ RequestBase.prototype._finalizeQueryString = function () {
42574323 var index = this.url.indexOf('?');
42584324
42594325 if (index >= 0) {
4260- var queryArr = this.url.substring (index + 1).split('&');
4326+ var queryArr = this.url.slice (index + 1).split('&');
42614327
42624328 if (typeof this._sort === 'function') {
42634329 queryArr.sort(this._sort);
42644330 } else {
42654331 queryArr.sort();
42664332 }
42674333
4268- this.url = this.url.substring (0, index) + '?' + queryArr.join('&');
4334+ this.url = this.url.slice (0, index) + '?' + queryArr.join('&');
42694335 }
42704336 }
42714337}; // For backwards compat only
@@ -4291,6 +4357,7 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
42914357 err.code = 'ECONNABORTED';
42924358 err.errno = errno;
42934359 this.timedout = true;
4360+ this.timedoutError = err;
42944361 this.abort();
42954362 this.callback(err);
42964363};
@@ -4311,6 +4378,7 @@ RequestBase.prototype._setTimeouts = function () {
43114378 }, this._responseTimeout);
43124379 }
43134380};
4381+
43144382},{"./is-object":10}],12:[function(require,module,exports){
43154383"use strict";
43164384
@@ -4393,7 +4461,7 @@ ResponseBase.prototype._setHeaderProperties = function (header) {
43934461 if (header.link) {
43944462 this.links = utils.parseLinks(header.link);
43954463 }
4396- } catch (err ) {// ignore
4464+ } catch (_unused ) {// ignore
43974465 }
43984466};
43994467/**
@@ -4442,6 +4510,7 @@ ResponseBase.prototype._setStatusProperties = function (status) {
44424510 this.notFound = status === 404;
44434511 this.unprocessableEntity = status === 422;
44444512};
4513+
44454514},{"./utils":13}],13:[function(require,module,exports){
44464515"use strict";
44474516
@@ -4513,6 +4582,7 @@ exports.cleanHeader = function (header, changesOrigin) {
45134582
45144583 return header;
45154584};
4585+
45164586},{}],14:[function(require,module,exports){
45174587(function (process,Buffer){
45184588/**
0 commit comments