superagent 6.0.0 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist.babelrc +2 -1
- package/.dist.eslintrc +15 -2
- package/.github/FUNDING.yml +4 -0
- package/Makefile +2 -0
- package/README.md +9 -5
- package/SECURITY.md +6 -0
- package/dist/superagent.js +2790 -1289
- package/dist/superagent.min.js +1 -1
- package/docs/test.html +3085 -3547
- package/index.html +554 -1
- package/lib/agent-base.js +28 -10
- package/lib/client.js +141 -117
- package/lib/is-object.js +4 -4
- package/lib/node/agent.js +39 -18
- package/lib/node/http2wrapper.js +11 -10
- package/lib/node/index.js +174 -138
- package/lib/node/parsers/json.js +7 -7
- package/lib/node/parsers/urlencoded.js +1 -1
- package/lib/node/response.js +15 -15
- package/lib/node/unzip.js +8 -8
- package/lib/request-base.js +51 -25
- package/lib/response-base.js +10 -10
- package/lib/utils.js +19 -19
- package/package.json +81 -74
package/dist/superagent.js
CHANGED
|
@@ -1,31 +1,89 @@
|
|
|
1
1
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
},{}],2:[function(require,module,exports){
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
var GetIntrinsic = require('get-intrinsic');
|
|
8
|
+
|
|
9
|
+
var callBind = require('./');
|
|
10
|
+
|
|
11
|
+
var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
|
12
|
+
|
|
13
|
+
module.exports = function callBoundIntrinsic(name, allowMissing) {
|
|
14
|
+
var intrinsic = GetIntrinsic(name, !!allowMissing);
|
|
15
|
+
|
|
16
|
+
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
|
|
17
|
+
return callBind(intrinsic);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return intrinsic;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
},{"./":3,"get-intrinsic":8}],3:[function(require,module,exports){
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
var bind = require('function-bind');
|
|
27
|
+
|
|
28
|
+
var GetIntrinsic = require('get-intrinsic');
|
|
29
|
+
|
|
30
|
+
var $apply = GetIntrinsic('%Function.prototype.apply%');
|
|
31
|
+
var $call = GetIntrinsic('%Function.prototype.call%');
|
|
32
|
+
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
|
|
33
|
+
var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
|
34
|
+
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
|
35
|
+
var $max = GetIntrinsic('%Math.max%');
|
|
36
|
+
|
|
37
|
+
if ($defineProperty) {
|
|
38
|
+
try {
|
|
39
|
+
$defineProperty({}, 'a', {
|
|
40
|
+
value: 1
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {
|
|
43
|
+
$defineProperty = null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = function callBind(originalFunction) {
|
|
48
|
+
var func = $reflectApply(bind, $call, arguments);
|
|
49
|
+
|
|
50
|
+
if ($gOPD && $defineProperty) {
|
|
51
|
+
var desc = $gOPD(func, 'length');
|
|
52
|
+
|
|
53
|
+
if (desc.configurable) {
|
|
54
|
+
$defineProperty(func, 'length', {
|
|
55
|
+
value: 1 + $max(0, originalFunction.length - (arguments.length - 1))
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return func;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var applyBind = function applyBind() {
|
|
64
|
+
return $reflectApply(bind, $apply, arguments);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if ($defineProperty) {
|
|
68
|
+
$defineProperty(module.exports, 'apply', {
|
|
69
|
+
value: applyBind
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
module.exports.apply = applyBind;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
},{"function-bind":7,"get-intrinsic":8}],4:[function(require,module,exports){
|
|
76
|
+
"use strict";
|
|
77
|
+
|
|
7
78
|
if (typeof module !== 'undefined') {
|
|
8
79
|
module.exports = Emitter;
|
|
9
80
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Initialize a new `Emitter`.
|
|
12
|
-
*
|
|
13
|
-
* @api public
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
81
|
|
|
17
82
|
function Emitter(obj) {
|
|
18
83
|
if (obj) return mixin(obj);
|
|
19
84
|
}
|
|
20
85
|
|
|
21
86
|
;
|
|
22
|
-
/**
|
|
23
|
-
* Mixin the emitter properties.
|
|
24
|
-
*
|
|
25
|
-
* @param {Object} obj
|
|
26
|
-
* @return {Object}
|
|
27
|
-
* @api private
|
|
28
|
-
*/
|
|
29
87
|
|
|
30
88
|
function mixin(obj) {
|
|
31
89
|
for (var key in Emitter.prototype) {
|
|
@@ -34,31 +92,12 @@ function mixin(obj) {
|
|
|
34
92
|
|
|
35
93
|
return obj;
|
|
36
94
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Listen on the given `event` with `fn`.
|
|
39
|
-
*
|
|
40
|
-
* @param {String} event
|
|
41
|
-
* @param {Function} fn
|
|
42
|
-
* @return {Emitter}
|
|
43
|
-
* @api public
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
95
|
|
|
47
96
|
Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
|
|
48
97
|
this._callbacks = this._callbacks || {};
|
|
49
98
|
(this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
|
|
50
99
|
return this;
|
|
51
100
|
};
|
|
52
|
-
/**
|
|
53
|
-
* Adds an `event` listener that will be invoked a single
|
|
54
|
-
* time then automatically removed.
|
|
55
|
-
*
|
|
56
|
-
* @param {String} event
|
|
57
|
-
* @param {Function} fn
|
|
58
|
-
* @return {Emitter}
|
|
59
|
-
* @api public
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
101
|
|
|
63
102
|
Emitter.prototype.once = function (event, fn) {
|
|
64
103
|
function on() {
|
|
@@ -70,34 +109,22 @@ Emitter.prototype.once = function (event, fn) {
|
|
|
70
109
|
this.on(event, on);
|
|
71
110
|
return this;
|
|
72
111
|
};
|
|
73
|
-
/**
|
|
74
|
-
* Remove the given callback for `event` or all
|
|
75
|
-
* registered callbacks.
|
|
76
|
-
*
|
|
77
|
-
* @param {String} event
|
|
78
|
-
* @param {Function} fn
|
|
79
|
-
* @return {Emitter}
|
|
80
|
-
* @api public
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
112
|
|
|
84
113
|
Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
|
|
85
|
-
this._callbacks = this._callbacks || {};
|
|
114
|
+
this._callbacks = this._callbacks || {};
|
|
86
115
|
|
|
87
116
|
if (0 == arguments.length) {
|
|
88
117
|
this._callbacks = {};
|
|
89
118
|
return this;
|
|
90
|
-
}
|
|
91
|
-
|
|
119
|
+
}
|
|
92
120
|
|
|
93
121
|
var callbacks = this._callbacks['$' + event];
|
|
94
|
-
if (!callbacks) return this;
|
|
122
|
+
if (!callbacks) return this;
|
|
95
123
|
|
|
96
124
|
if (1 == arguments.length) {
|
|
97
125
|
delete this._callbacks['$' + event];
|
|
98
126
|
return this;
|
|
99
|
-
}
|
|
100
|
-
|
|
127
|
+
}
|
|
101
128
|
|
|
102
129
|
var cb;
|
|
103
130
|
|
|
@@ -108,9 +135,7 @@ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.rem
|
|
|
108
135
|
callbacks.splice(i, 1);
|
|
109
136
|
break;
|
|
110
137
|
}
|
|
111
|
-
}
|
|
112
|
-
// one is subscribed for to avoid memory leak.
|
|
113
|
-
|
|
138
|
+
}
|
|
114
139
|
|
|
115
140
|
if (callbacks.length === 0) {
|
|
116
141
|
delete this._callbacks['$' + event];
|
|
@@ -118,14 +143,6 @@ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.rem
|
|
|
118
143
|
|
|
119
144
|
return this;
|
|
120
145
|
};
|
|
121
|
-
/**
|
|
122
|
-
* Emit `event` with the given args.
|
|
123
|
-
*
|
|
124
|
-
* @param {String} event
|
|
125
|
-
* @param {Mixed} ...
|
|
126
|
-
* @return {Emitter}
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
146
|
|
|
130
147
|
Emitter.prototype.emit = function (event) {
|
|
131
148
|
this._callbacks = this._callbacks || {};
|
|
@@ -146,251 +163,2533 @@ Emitter.prototype.emit = function (event) {
|
|
|
146
163
|
|
|
147
164
|
return this;
|
|
148
165
|
};
|
|
149
|
-
/**
|
|
150
|
-
* Return array of callbacks for `event`.
|
|
151
|
-
*
|
|
152
|
-
* @param {String} event
|
|
153
|
-
* @return {Array}
|
|
154
|
-
* @api public
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
166
|
|
|
158
167
|
Emitter.prototype.listeners = function (event) {
|
|
159
168
|
this._callbacks = this._callbacks || {};
|
|
160
169
|
return this._callbacks['$' + event] || [];
|
|
161
170
|
};
|
|
162
|
-
/**
|
|
163
|
-
* Check if this emitter has `event` handlers.
|
|
164
|
-
*
|
|
165
|
-
* @param {String} event
|
|
166
|
-
* @return {Boolean}
|
|
167
|
-
* @api public
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
171
|
|
|
171
172
|
Emitter.prototype.hasListeners = function (event) {
|
|
172
173
|
return !!this.listeners(event).length;
|
|
173
174
|
};
|
|
174
175
|
|
|
175
|
-
},{}],
|
|
176
|
+
},{}],5:[function(require,module,exports){
|
|
176
177
|
"use strict";
|
|
177
178
|
|
|
178
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
179
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
179
180
|
|
|
180
181
|
module.exports = stringify;
|
|
181
182
|
stringify.default = stringify;
|
|
182
183
|
stringify.stable = deterministicStringify;
|
|
183
184
|
stringify.stableStringify = deterministicStringify;
|
|
185
|
+
var LIMIT_REPLACE_NODE = '[...]';
|
|
186
|
+
var CIRCULAR_REPLACE_NODE = '[Circular]';
|
|
184
187
|
var arr = [];
|
|
185
|
-
var replacerStack = [];
|
|
188
|
+
var replacerStack = [];
|
|
186
189
|
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
function defaultOptions() {
|
|
191
|
+
return {
|
|
192
|
+
depthLimit: Number.MAX_SAFE_INTEGER,
|
|
193
|
+
edgesLimit: Number.MAX_SAFE_INTEGER
|
|
194
|
+
};
|
|
195
|
+
}
|
|
190
196
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
|
|
197
|
+
function stringify(obj, replacer, spacer, options) {
|
|
198
|
+
if (typeof options === 'undefined') {
|
|
199
|
+
options = defaultOptions();
|
|
195
200
|
}
|
|
196
201
|
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
decirc(obj, '', 0, [], undefined, 0, options);
|
|
203
|
+
var res;
|
|
199
204
|
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
try {
|
|
206
|
+
if (replacerStack.length === 0) {
|
|
207
|
+
res = JSON.stringify(obj, replacer, spacer);
|
|
202
208
|
} else {
|
|
203
|
-
|
|
209
|
+
res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
|
|
210
|
+
}
|
|
211
|
+
} catch (_) {
|
|
212
|
+
return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
|
|
213
|
+
} finally {
|
|
214
|
+
while (arr.length !== 0) {
|
|
215
|
+
var part = arr.pop();
|
|
216
|
+
|
|
217
|
+
if (part.length === 4) {
|
|
218
|
+
Object.defineProperty(part[0], part[1], part[3]);
|
|
219
|
+
} else {
|
|
220
|
+
part[0][part[1]] = part[2];
|
|
221
|
+
}
|
|
204
222
|
}
|
|
205
223
|
}
|
|
206
224
|
|
|
207
225
|
return res;
|
|
208
226
|
}
|
|
209
227
|
|
|
210
|
-
function
|
|
228
|
+
function setReplace(replace, val, k, parent) {
|
|
229
|
+
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
|
|
230
|
+
|
|
231
|
+
if (propertyDescriptor.get !== undefined) {
|
|
232
|
+
if (propertyDescriptor.configurable) {
|
|
233
|
+
Object.defineProperty(parent, k, {
|
|
234
|
+
value: replace
|
|
235
|
+
});
|
|
236
|
+
arr.push([parent, k, val, propertyDescriptor]);
|
|
237
|
+
} else {
|
|
238
|
+
replacerStack.push([val, k, replace]);
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
parent[k] = replace;
|
|
242
|
+
arr.push([parent, k, val]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
247
|
+
depth += 1;
|
|
211
248
|
var i;
|
|
212
249
|
|
|
213
250
|
if (_typeof(val) === 'object' && val !== null) {
|
|
214
251
|
for (i = 0; i < stack.length; i++) {
|
|
215
252
|
if (stack[i] === val) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (propertyDescriptor.get !== undefined) {
|
|
219
|
-
if (propertyDescriptor.configurable) {
|
|
220
|
-
Object.defineProperty(parent, k, {
|
|
221
|
-
value: '[Circular]'
|
|
222
|
-
});
|
|
223
|
-
arr.push([parent, k, val, propertyDescriptor]);
|
|
224
|
-
} else {
|
|
225
|
-
replacerStack.push([val, k]);
|
|
226
|
-
}
|
|
227
|
-
} else {
|
|
228
|
-
parent[k] = '[Circular]';
|
|
229
|
-
arr.push([parent, k, val]);
|
|
230
|
-
}
|
|
231
|
-
|
|
253
|
+
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
232
254
|
return;
|
|
233
255
|
}
|
|
234
256
|
}
|
|
235
257
|
|
|
236
|
-
|
|
258
|
+
if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
|
|
259
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
|
|
264
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
stack.push(val);
|
|
237
269
|
|
|
238
270
|
if (Array.isArray(val)) {
|
|
239
271
|
for (i = 0; i < val.length; i++) {
|
|
240
|
-
decirc(val[i], i, stack, val);
|
|
272
|
+
decirc(val[i], i, i, stack, val, depth, options);
|
|
241
273
|
}
|
|
242
274
|
} else {
|
|
243
275
|
var keys = Object.keys(val);
|
|
244
276
|
|
|
245
277
|
for (i = 0; i < keys.length; i++) {
|
|
246
278
|
var key = keys[i];
|
|
247
|
-
decirc(val[key], key, stack, val);
|
|
279
|
+
decirc(val[key], key, i, stack, val, depth, options);
|
|
248
280
|
}
|
|
249
281
|
}
|
|
250
282
|
|
|
251
283
|
stack.pop();
|
|
252
284
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
285
|
+
}
|
|
255
286
|
|
|
256
287
|
function compareFunction(a, b) {
|
|
257
288
|
if (a < b) {
|
|
258
289
|
return -1;
|
|
259
290
|
}
|
|
260
291
|
|
|
261
|
-
if (a > b) {
|
|
262
|
-
return 1;
|
|
292
|
+
if (a > b) {
|
|
293
|
+
return 1;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function deterministicStringify(obj, replacer, spacer, options) {
|
|
300
|
+
if (typeof options === 'undefined') {
|
|
301
|
+
options = defaultOptions();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
var tmp = deterministicDecirc(obj, '', 0, [], undefined, 0, options) || obj;
|
|
305
|
+
var res;
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
if (replacerStack.length === 0) {
|
|
309
|
+
res = JSON.stringify(tmp, replacer, spacer);
|
|
310
|
+
} else {
|
|
311
|
+
res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer);
|
|
312
|
+
}
|
|
313
|
+
} catch (_) {
|
|
314
|
+
return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
|
|
315
|
+
} finally {
|
|
316
|
+
while (arr.length !== 0) {
|
|
317
|
+
var part = arr.pop();
|
|
318
|
+
|
|
319
|
+
if (part.length === 4) {
|
|
320
|
+
Object.defineProperty(part[0], part[1], part[3]);
|
|
321
|
+
} else {
|
|
322
|
+
part[0][part[1]] = part[2];
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return res;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
331
|
+
depth += 1;
|
|
332
|
+
var i;
|
|
333
|
+
|
|
334
|
+
if (_typeof(val) === 'object' && val !== null) {
|
|
335
|
+
for (i = 0; i < stack.length; i++) {
|
|
336
|
+
if (stack[i] === val) {
|
|
337
|
+
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
if (typeof val.toJSON === 'function') {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
} catch (_) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
|
|
351
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
|
|
356
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
stack.push(val);
|
|
361
|
+
|
|
362
|
+
if (Array.isArray(val)) {
|
|
363
|
+
for (i = 0; i < val.length; i++) {
|
|
364
|
+
deterministicDecirc(val[i], i, i, stack, val, depth, options);
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
var tmp = {};
|
|
368
|
+
var keys = Object.keys(val).sort(compareFunction);
|
|
369
|
+
|
|
370
|
+
for (i = 0; i < keys.length; i++) {
|
|
371
|
+
var key = keys[i];
|
|
372
|
+
deterministicDecirc(val[key], key, i, stack, val, depth, options);
|
|
373
|
+
tmp[key] = val[key];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (typeof parent !== 'undefined') {
|
|
377
|
+
arr.push([parent, k, val]);
|
|
378
|
+
parent[k] = tmp;
|
|
379
|
+
} else {
|
|
380
|
+
return tmp;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
stack.pop();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function replaceGetterValues(replacer) {
|
|
389
|
+
replacer = typeof replacer !== 'undefined' ? replacer : function (k, v) {
|
|
390
|
+
return v;
|
|
391
|
+
};
|
|
392
|
+
return function (key, val) {
|
|
393
|
+
if (replacerStack.length > 0) {
|
|
394
|
+
for (var i = 0; i < replacerStack.length; i++) {
|
|
395
|
+
var part = replacerStack[i];
|
|
396
|
+
|
|
397
|
+
if (part[1] === key && part[0] === val) {
|
|
398
|
+
val = part[2];
|
|
399
|
+
replacerStack.splice(i, 1);
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return replacer.call(this, key, val);
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
},{}],6:[function(require,module,exports){
|
|
410
|
+
'use strict';
|
|
411
|
+
|
|
412
|
+
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
413
|
+
var slice = Array.prototype.slice;
|
|
414
|
+
var toStr = Object.prototype.toString;
|
|
415
|
+
var funcType = '[object Function]';
|
|
416
|
+
|
|
417
|
+
module.exports = function bind(that) {
|
|
418
|
+
var target = this;
|
|
419
|
+
|
|
420
|
+
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
|
|
421
|
+
throw new TypeError(ERROR_MESSAGE + target);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
var args = slice.call(arguments, 1);
|
|
425
|
+
var bound;
|
|
426
|
+
|
|
427
|
+
var binder = function binder() {
|
|
428
|
+
if (this instanceof bound) {
|
|
429
|
+
var result = target.apply(this, args.concat(slice.call(arguments)));
|
|
430
|
+
|
|
431
|
+
if (Object(result) === result) {
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return this;
|
|
436
|
+
} else {
|
|
437
|
+
return target.apply(that, args.concat(slice.call(arguments)));
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
var boundLength = Math.max(0, target.length - args.length);
|
|
442
|
+
var boundArgs = [];
|
|
443
|
+
|
|
444
|
+
for (var i = 0; i < boundLength; i++) {
|
|
445
|
+
boundArgs.push('$' + i);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
|
|
449
|
+
|
|
450
|
+
if (target.prototype) {
|
|
451
|
+
var Empty = function Empty() {};
|
|
452
|
+
|
|
453
|
+
Empty.prototype = target.prototype;
|
|
454
|
+
bound.prototype = new Empty();
|
|
455
|
+
Empty.prototype = null;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return bound;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
},{}],7:[function(require,module,exports){
|
|
462
|
+
'use strict';
|
|
463
|
+
|
|
464
|
+
var implementation = require('./implementation');
|
|
465
|
+
|
|
466
|
+
module.exports = Function.prototype.bind || implementation;
|
|
467
|
+
|
|
468
|
+
},{"./implementation":6}],8:[function(require,module,exports){
|
|
469
|
+
'use strict';
|
|
470
|
+
|
|
471
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
472
|
+
|
|
473
|
+
var undefined;
|
|
474
|
+
var $SyntaxError = SyntaxError;
|
|
475
|
+
var $Function = Function;
|
|
476
|
+
var $TypeError = TypeError;
|
|
477
|
+
|
|
478
|
+
var getEvalledConstructor = function getEvalledConstructor(expressionSyntax) {
|
|
479
|
+
try {
|
|
480
|
+
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
481
|
+
} catch (e) {}
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
485
|
+
|
|
486
|
+
if ($gOPD) {
|
|
487
|
+
try {
|
|
488
|
+
$gOPD({}, '');
|
|
489
|
+
} catch (e) {
|
|
490
|
+
$gOPD = null;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
var throwTypeError = function throwTypeError() {
|
|
495
|
+
throw new $TypeError();
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
var ThrowTypeError = $gOPD ? function () {
|
|
499
|
+
try {
|
|
500
|
+
arguments.callee;
|
|
501
|
+
return throwTypeError;
|
|
502
|
+
} catch (calleeThrows) {
|
|
503
|
+
try {
|
|
504
|
+
return $gOPD(arguments, 'callee').get;
|
|
505
|
+
} catch (gOPDthrows) {
|
|
506
|
+
return throwTypeError;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}() : throwTypeError;
|
|
510
|
+
|
|
511
|
+
var hasSymbols = require('has-symbols')();
|
|
512
|
+
|
|
513
|
+
var getProto = Object.getPrototypeOf || function (x) {
|
|
514
|
+
return x.__proto__;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
var needsEval = {};
|
|
518
|
+
var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
|
|
519
|
+
var INTRINSICS = {
|
|
520
|
+
'%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
|
|
521
|
+
'%Array%': Array,
|
|
522
|
+
'%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
|
|
523
|
+
'%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
|
|
524
|
+
'%AsyncFromSyncIteratorPrototype%': undefined,
|
|
525
|
+
'%AsyncFunction%': needsEval,
|
|
526
|
+
'%AsyncGenerator%': needsEval,
|
|
527
|
+
'%AsyncGeneratorFunction%': needsEval,
|
|
528
|
+
'%AsyncIteratorPrototype%': needsEval,
|
|
529
|
+
'%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
|
|
530
|
+
'%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
|
|
531
|
+
'%Boolean%': Boolean,
|
|
532
|
+
'%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
|
|
533
|
+
'%Date%': Date,
|
|
534
|
+
'%decodeURI%': decodeURI,
|
|
535
|
+
'%decodeURIComponent%': decodeURIComponent,
|
|
536
|
+
'%encodeURI%': encodeURI,
|
|
537
|
+
'%encodeURIComponent%': encodeURIComponent,
|
|
538
|
+
'%Error%': Error,
|
|
539
|
+
'%eval%': eval,
|
|
540
|
+
'%EvalError%': EvalError,
|
|
541
|
+
'%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
|
|
542
|
+
'%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
|
|
543
|
+
'%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
|
|
544
|
+
'%Function%': $Function,
|
|
545
|
+
'%GeneratorFunction%': needsEval,
|
|
546
|
+
'%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
|
|
547
|
+
'%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
|
|
548
|
+
'%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
|
|
549
|
+
'%isFinite%': isFinite,
|
|
550
|
+
'%isNaN%': isNaN,
|
|
551
|
+
'%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
|
|
552
|
+
'%JSON%': (typeof JSON === "undefined" ? "undefined" : _typeof(JSON)) === 'object' ? JSON : undefined,
|
|
553
|
+
'%Map%': typeof Map === 'undefined' ? undefined : Map,
|
|
554
|
+
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
|
|
555
|
+
'%Math%': Math,
|
|
556
|
+
'%Number%': Number,
|
|
557
|
+
'%Object%': Object,
|
|
558
|
+
'%parseFloat%': parseFloat,
|
|
559
|
+
'%parseInt%': parseInt,
|
|
560
|
+
'%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
|
|
561
|
+
'%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
|
|
562
|
+
'%RangeError%': RangeError,
|
|
563
|
+
'%ReferenceError%': ReferenceError,
|
|
564
|
+
'%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
|
|
565
|
+
'%RegExp%': RegExp,
|
|
566
|
+
'%Set%': typeof Set === 'undefined' ? undefined : Set,
|
|
567
|
+
'%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
|
|
568
|
+
'%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
|
|
569
|
+
'%String%': String,
|
|
570
|
+
'%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
|
|
571
|
+
'%Symbol%': hasSymbols ? Symbol : undefined,
|
|
572
|
+
'%SyntaxError%': $SyntaxError,
|
|
573
|
+
'%ThrowTypeError%': ThrowTypeError,
|
|
574
|
+
'%TypedArray%': TypedArray,
|
|
575
|
+
'%TypeError%': $TypeError,
|
|
576
|
+
'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
|
|
577
|
+
'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
|
|
578
|
+
'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
|
|
579
|
+
'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
|
|
580
|
+
'%URIError%': URIError,
|
|
581
|
+
'%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
|
|
582
|
+
'%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
|
|
583
|
+
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
var doEval = function doEval(name) {
|
|
587
|
+
var value;
|
|
588
|
+
|
|
589
|
+
if (name === '%AsyncFunction%') {
|
|
590
|
+
value = getEvalledConstructor('async function () {}');
|
|
591
|
+
} else if (name === '%GeneratorFunction%') {
|
|
592
|
+
value = getEvalledConstructor('function* () {}');
|
|
593
|
+
} else if (name === '%AsyncGeneratorFunction%') {
|
|
594
|
+
value = getEvalledConstructor('async function* () {}');
|
|
595
|
+
} else if (name === '%AsyncGenerator%') {
|
|
596
|
+
var fn = doEval('%AsyncGeneratorFunction%');
|
|
597
|
+
|
|
598
|
+
if (fn) {
|
|
599
|
+
value = fn.prototype;
|
|
600
|
+
}
|
|
601
|
+
} else if (name === '%AsyncIteratorPrototype%') {
|
|
602
|
+
var gen = doEval('%AsyncGenerator%');
|
|
603
|
+
|
|
604
|
+
if (gen) {
|
|
605
|
+
value = getProto(gen.prototype);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
INTRINSICS[name] = value;
|
|
610
|
+
return value;
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
var LEGACY_ALIASES = {
|
|
614
|
+
'%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
|
|
615
|
+
'%ArrayPrototype%': ['Array', 'prototype'],
|
|
616
|
+
'%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
|
|
617
|
+
'%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
|
|
618
|
+
'%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
|
|
619
|
+
'%ArrayProto_values%': ['Array', 'prototype', 'values'],
|
|
620
|
+
'%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
|
|
621
|
+
'%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
|
|
622
|
+
'%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
|
|
623
|
+
'%BooleanPrototype%': ['Boolean', 'prototype'],
|
|
624
|
+
'%DataViewPrototype%': ['DataView', 'prototype'],
|
|
625
|
+
'%DatePrototype%': ['Date', 'prototype'],
|
|
626
|
+
'%ErrorPrototype%': ['Error', 'prototype'],
|
|
627
|
+
'%EvalErrorPrototype%': ['EvalError', 'prototype'],
|
|
628
|
+
'%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
|
|
629
|
+
'%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
|
|
630
|
+
'%FunctionPrototype%': ['Function', 'prototype'],
|
|
631
|
+
'%Generator%': ['GeneratorFunction', 'prototype'],
|
|
632
|
+
'%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
|
|
633
|
+
'%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
|
|
634
|
+
'%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
|
|
635
|
+
'%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
|
|
636
|
+
'%JSONParse%': ['JSON', 'parse'],
|
|
637
|
+
'%JSONStringify%': ['JSON', 'stringify'],
|
|
638
|
+
'%MapPrototype%': ['Map', 'prototype'],
|
|
639
|
+
'%NumberPrototype%': ['Number', 'prototype'],
|
|
640
|
+
'%ObjectPrototype%': ['Object', 'prototype'],
|
|
641
|
+
'%ObjProto_toString%': ['Object', 'prototype', 'toString'],
|
|
642
|
+
'%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
|
|
643
|
+
'%PromisePrototype%': ['Promise', 'prototype'],
|
|
644
|
+
'%PromiseProto_then%': ['Promise', 'prototype', 'then'],
|
|
645
|
+
'%Promise_all%': ['Promise', 'all'],
|
|
646
|
+
'%Promise_reject%': ['Promise', 'reject'],
|
|
647
|
+
'%Promise_resolve%': ['Promise', 'resolve'],
|
|
648
|
+
'%RangeErrorPrototype%': ['RangeError', 'prototype'],
|
|
649
|
+
'%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
|
|
650
|
+
'%RegExpPrototype%': ['RegExp', 'prototype'],
|
|
651
|
+
'%SetPrototype%': ['Set', 'prototype'],
|
|
652
|
+
'%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
|
|
653
|
+
'%StringPrototype%': ['String', 'prototype'],
|
|
654
|
+
'%SymbolPrototype%': ['Symbol', 'prototype'],
|
|
655
|
+
'%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
|
|
656
|
+
'%TypedArrayPrototype%': ['TypedArray', 'prototype'],
|
|
657
|
+
'%TypeErrorPrototype%': ['TypeError', 'prototype'],
|
|
658
|
+
'%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
|
|
659
|
+
'%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
|
|
660
|
+
'%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
|
|
661
|
+
'%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
|
|
662
|
+
'%URIErrorPrototype%': ['URIError', 'prototype'],
|
|
663
|
+
'%WeakMapPrototype%': ['WeakMap', 'prototype'],
|
|
664
|
+
'%WeakSetPrototype%': ['WeakSet', 'prototype']
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
var bind = require('function-bind');
|
|
668
|
+
|
|
669
|
+
var hasOwn = require('has');
|
|
670
|
+
|
|
671
|
+
var $concat = bind.call(Function.call, Array.prototype.concat);
|
|
672
|
+
var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
673
|
+
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
674
|
+
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
675
|
+
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
676
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
677
|
+
|
|
678
|
+
var stringToPath = function stringToPath(string) {
|
|
679
|
+
var first = $strSlice(string, 0, 1);
|
|
680
|
+
var last = $strSlice(string, -1);
|
|
681
|
+
|
|
682
|
+
if (first === '%' && last !== '%') {
|
|
683
|
+
throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
684
|
+
} else if (last === '%' && first !== '%') {
|
|
685
|
+
throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
var result = [];
|
|
689
|
+
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
690
|
+
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
|
|
691
|
+
});
|
|
692
|
+
return result;
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
696
|
+
var intrinsicName = name;
|
|
697
|
+
var alias;
|
|
698
|
+
|
|
699
|
+
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
700
|
+
alias = LEGACY_ALIASES[intrinsicName];
|
|
701
|
+
intrinsicName = '%' + alias[0] + '%';
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (hasOwn(INTRINSICS, intrinsicName)) {
|
|
705
|
+
var value = INTRINSICS[intrinsicName];
|
|
706
|
+
|
|
707
|
+
if (value === needsEval) {
|
|
708
|
+
value = doEval(intrinsicName);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
if (typeof value === 'undefined' && !allowMissing) {
|
|
712
|
+
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
return {
|
|
716
|
+
alias: alias,
|
|
717
|
+
name: intrinsicName,
|
|
718
|
+
value: value
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
module.exports = function GetIntrinsic(name, allowMissing) {
|
|
726
|
+
if (typeof name !== 'string' || name.length === 0) {
|
|
727
|
+
throw new $TypeError('intrinsic name must be a non-empty string');
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
731
|
+
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
var parts = stringToPath(name);
|
|
735
|
+
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
736
|
+
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
737
|
+
var intrinsicRealName = intrinsic.name;
|
|
738
|
+
var value = intrinsic.value;
|
|
739
|
+
var skipFurtherCaching = false;
|
|
740
|
+
var alias = intrinsic.alias;
|
|
741
|
+
|
|
742
|
+
if (alias) {
|
|
743
|
+
intrinsicBaseName = alias[0];
|
|
744
|
+
$spliceApply(parts, $concat([0, 1], alias));
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
for (var i = 1, isOwn = true; i < parts.length; i += 1) {
|
|
748
|
+
var part = parts[i];
|
|
749
|
+
var first = $strSlice(part, 0, 1);
|
|
750
|
+
var last = $strSlice(part, -1);
|
|
751
|
+
|
|
752
|
+
if ((first === '"' || first === "'" || first === '`' || last === '"' || last === "'" || last === '`') && first !== last) {
|
|
753
|
+
throw new $SyntaxError('property names with quotes must have matching quotes');
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
if (part === 'constructor' || !isOwn) {
|
|
757
|
+
skipFurtherCaching = true;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
intrinsicBaseName += '.' + part;
|
|
761
|
+
intrinsicRealName = '%' + intrinsicBaseName + '%';
|
|
762
|
+
|
|
763
|
+
if (hasOwn(INTRINSICS, intrinsicRealName)) {
|
|
764
|
+
value = INTRINSICS[intrinsicRealName];
|
|
765
|
+
} else if (value != null) {
|
|
766
|
+
if (!(part in value)) {
|
|
767
|
+
if (!allowMissing) {
|
|
768
|
+
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
return void undefined;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
if ($gOPD && i + 1 >= parts.length) {
|
|
775
|
+
var desc = $gOPD(value, part);
|
|
776
|
+
isOwn = !!desc;
|
|
777
|
+
|
|
778
|
+
if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
|
|
779
|
+
value = desc.get;
|
|
780
|
+
} else {
|
|
781
|
+
value = value[part];
|
|
782
|
+
}
|
|
783
|
+
} else {
|
|
784
|
+
isOwn = hasOwn(value, part);
|
|
785
|
+
value = value[part];
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
if (isOwn && !skipFurtherCaching) {
|
|
789
|
+
INTRINSICS[intrinsicRealName] = value;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
return value;
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
},{"function-bind":7,"has":11,"has-symbols":9}],9:[function(require,module,exports){
|
|
798
|
+
'use strict';
|
|
799
|
+
|
|
800
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
801
|
+
|
|
802
|
+
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
803
|
+
|
|
804
|
+
var hasSymbolSham = require('./shams');
|
|
805
|
+
|
|
806
|
+
module.exports = function hasNativeSymbols() {
|
|
807
|
+
if (typeof origSymbol !== 'function') {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
if (typeof Symbol !== 'function') {
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (_typeof(origSymbol('foo')) !== 'symbol') {
|
|
816
|
+
return false;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
if (_typeof(Symbol('bar')) !== 'symbol') {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
return hasSymbolSham();
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
},{"./shams":10}],10:[function(require,module,exports){
|
|
827
|
+
'use strict';
|
|
828
|
+
|
|
829
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
830
|
+
|
|
831
|
+
module.exports = function hasSymbols() {
|
|
832
|
+
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
|
|
833
|
+
return false;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (_typeof(Symbol.iterator) === 'symbol') {
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
var obj = {};
|
|
841
|
+
var sym = Symbol('test');
|
|
842
|
+
var symObj = Object(sym);
|
|
843
|
+
|
|
844
|
+
if (typeof sym === 'string') {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
if (Object.prototype.toString.call(sym) !== '[object Symbol]') {
|
|
849
|
+
return false;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') {
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
var symVal = 42;
|
|
857
|
+
obj[sym] = symVal;
|
|
858
|
+
|
|
859
|
+
for (sym in obj) {
|
|
860
|
+
return false;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) {
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
var syms = Object.getOwnPropertySymbols(obj);
|
|
872
|
+
|
|
873
|
+
if (syms.length !== 1 || syms[0] !== sym) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
882
|
+
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
883
|
+
|
|
884
|
+
if (descriptor.value !== symVal || descriptor.enumerable !== true) {
|
|
885
|
+
return false;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
return true;
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
},{}],11:[function(require,module,exports){
|
|
893
|
+
'use strict';
|
|
894
|
+
|
|
895
|
+
var bind = require('function-bind');
|
|
896
|
+
|
|
897
|
+
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
898
|
+
|
|
899
|
+
},{"function-bind":7}],12:[function(require,module,exports){
|
|
900
|
+
"use strict";
|
|
901
|
+
|
|
902
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
903
|
+
|
|
904
|
+
var hasMap = typeof Map === 'function' && Map.prototype;
|
|
905
|
+
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
|
906
|
+
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
|
|
907
|
+
var mapForEach = hasMap && Map.prototype.forEach;
|
|
908
|
+
var hasSet = typeof Set === 'function' && Set.prototype;
|
|
909
|
+
var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
|
|
910
|
+
var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
|
|
911
|
+
var setForEach = hasSet && Set.prototype.forEach;
|
|
912
|
+
var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
|
|
913
|
+
var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
|
|
914
|
+
var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
|
|
915
|
+
var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
|
|
916
|
+
var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
|
|
917
|
+
var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
|
|
918
|
+
var booleanValueOf = Boolean.prototype.valueOf;
|
|
919
|
+
var objectToString = Object.prototype.toString;
|
|
920
|
+
var functionToString = Function.prototype.toString;
|
|
921
|
+
var $match = String.prototype.match;
|
|
922
|
+
var $slice = String.prototype.slice;
|
|
923
|
+
var $replace = String.prototype.replace;
|
|
924
|
+
var $toUpperCase = String.prototype.toUpperCase;
|
|
925
|
+
var $toLowerCase = String.prototype.toLowerCase;
|
|
926
|
+
var $test = RegExp.prototype.test;
|
|
927
|
+
var $concat = Array.prototype.concat;
|
|
928
|
+
var $join = Array.prototype.join;
|
|
929
|
+
var $arrSlice = Array.prototype.slice;
|
|
930
|
+
var $floor = Math.floor;
|
|
931
|
+
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
|
932
|
+
var gOPS = Object.getOwnPropertySymbols;
|
|
933
|
+
var symToString = typeof Symbol === 'function' && _typeof(Symbol.iterator) === 'symbol' ? Symbol.prototype.toString : null;
|
|
934
|
+
var hasShammedSymbols = typeof Symbol === 'function' && _typeof(Symbol.iterator) === 'object';
|
|
935
|
+
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (_typeof(Symbol.toStringTag) === hasShammedSymbols ? 'object' : 'symbol') ? Symbol.toStringTag : null;
|
|
936
|
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
937
|
+
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function (O) {
|
|
938
|
+
return O.__proto__;
|
|
939
|
+
} : null);
|
|
940
|
+
|
|
941
|
+
function addNumericSeparator(num, str) {
|
|
942
|
+
if (num === Infinity || num === -Infinity || num !== num || num && num > -1000 && num < 1000 || $test.call(/e/, str)) {
|
|
943
|
+
return str;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
|
|
947
|
+
|
|
948
|
+
if (typeof num === 'number') {
|
|
949
|
+
var int = num < 0 ? -$floor(-num) : $floor(num);
|
|
950
|
+
|
|
951
|
+
if (int !== num) {
|
|
952
|
+
var intStr = String(int);
|
|
953
|
+
var dec = $slice.call(str, intStr.length + 1);
|
|
954
|
+
return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
return $replace.call(str, sepRegex, '$&_');
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
var inspectCustom = require('./util.inspect').custom;
|
|
962
|
+
|
|
963
|
+
var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
|
|
964
|
+
|
|
965
|
+
module.exports = function inspect_(obj, options, depth, seen) {
|
|
966
|
+
var opts = options || {};
|
|
967
|
+
|
|
968
|
+
if (has(opts, 'quoteStyle') && opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double') {
|
|
969
|
+
throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
if (has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number' ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) {
|
|
973
|
+
throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
|
|
977
|
+
|
|
978
|
+
if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
|
|
979
|
+
throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
if (has(opts, 'indent') && opts.indent !== null && opts.indent !== '\t' && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) {
|
|
983
|
+
throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
|
|
987
|
+
throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
var numericSeparator = opts.numericSeparator;
|
|
991
|
+
|
|
992
|
+
if (typeof obj === 'undefined') {
|
|
993
|
+
return 'undefined';
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
if (obj === null) {
|
|
997
|
+
return 'null';
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
if (typeof obj === 'boolean') {
|
|
1001
|
+
return obj ? 'true' : 'false';
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
if (typeof obj === 'string') {
|
|
1005
|
+
return inspectString(obj, opts);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
if (typeof obj === 'number') {
|
|
1009
|
+
if (obj === 0) {
|
|
1010
|
+
return Infinity / obj > 0 ? '0' : '-0';
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
var str = String(obj);
|
|
1014
|
+
return numericSeparator ? addNumericSeparator(obj, str) : str;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
if (typeof obj === 'bigint') {
|
|
1018
|
+
var bigIntStr = String(obj) + 'n';
|
|
1019
|
+
return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
|
|
1023
|
+
|
|
1024
|
+
if (typeof depth === 'undefined') {
|
|
1025
|
+
depth = 0;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
if (depth >= maxDepth && maxDepth > 0 && _typeof(obj) === 'object') {
|
|
1029
|
+
return isArray(obj) ? '[Array]' : '[Object]';
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
var indent = getIndent(opts, depth);
|
|
1033
|
+
|
|
1034
|
+
if (typeof seen === 'undefined') {
|
|
1035
|
+
seen = [];
|
|
1036
|
+
} else if (indexOf(seen, obj) >= 0) {
|
|
1037
|
+
return '[Circular]';
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
function inspect(value, from, noIndent) {
|
|
1041
|
+
if (from) {
|
|
1042
|
+
seen = $arrSlice.call(seen);
|
|
1043
|
+
seen.push(from);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
if (noIndent) {
|
|
1047
|
+
var newOpts = {
|
|
1048
|
+
depth: opts.depth
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
if (has(opts, 'quoteStyle')) {
|
|
1052
|
+
newOpts.quoteStyle = opts.quoteStyle;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
return inspect_(value, newOpts, depth + 1, seen);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return inspect_(value, opts, depth + 1, seen);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
if (typeof obj === 'function') {
|
|
1062
|
+
var name = nameOf(obj);
|
|
1063
|
+
var keys = arrObjKeys(obj, inspect);
|
|
1064
|
+
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if (isSymbol(obj)) {
|
|
1068
|
+
var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
|
|
1069
|
+
return _typeof(obj) === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
if (isElement(obj)) {
|
|
1073
|
+
var s = '<' + $toLowerCase.call(String(obj.nodeName));
|
|
1074
|
+
var attrs = obj.attributes || [];
|
|
1075
|
+
|
|
1076
|
+
for (var i = 0; i < attrs.length; i++) {
|
|
1077
|
+
s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
s += '>';
|
|
1081
|
+
|
|
1082
|
+
if (obj.childNodes && obj.childNodes.length) {
|
|
1083
|
+
s += '...';
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
|
|
1087
|
+
return s;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
if (isArray(obj)) {
|
|
1091
|
+
if (obj.length === 0) {
|
|
1092
|
+
return '[]';
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
var xs = arrObjKeys(obj, inspect);
|
|
1096
|
+
|
|
1097
|
+
if (indent && !singleLineValues(xs)) {
|
|
1098
|
+
return '[' + indentedJoin(xs, indent) + ']';
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
return '[ ' + $join.call(xs, ', ') + ' ]';
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
if (isError(obj)) {
|
|
1105
|
+
var parts = arrObjKeys(obj, inspect);
|
|
1106
|
+
|
|
1107
|
+
if ('cause' in obj && !isEnumerable.call(obj, 'cause')) {
|
|
1108
|
+
return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
if (parts.length === 0) {
|
|
1112
|
+
return '[' + String(obj) + ']';
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
if (_typeof(obj) === 'object' && customInspect) {
|
|
1119
|
+
if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
|
|
1120
|
+
return obj[inspectSymbol]();
|
|
1121
|
+
} else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
|
|
1122
|
+
return obj.inspect();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if (isMap(obj)) {
|
|
1127
|
+
var mapParts = [];
|
|
1128
|
+
mapForEach.call(obj, function (value, key) {
|
|
1129
|
+
mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
|
|
1130
|
+
});
|
|
1131
|
+
return collectionOf('Map', mapSize.call(obj), mapParts, indent);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
if (isSet(obj)) {
|
|
1135
|
+
var setParts = [];
|
|
1136
|
+
setForEach.call(obj, function (value) {
|
|
1137
|
+
setParts.push(inspect(value, obj));
|
|
1138
|
+
});
|
|
1139
|
+
return collectionOf('Set', setSize.call(obj), setParts, indent);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
if (isWeakMap(obj)) {
|
|
1143
|
+
return weakCollectionOf('WeakMap');
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
if (isWeakSet(obj)) {
|
|
1147
|
+
return weakCollectionOf('WeakSet');
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
if (isWeakRef(obj)) {
|
|
1151
|
+
return weakCollectionOf('WeakRef');
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
if (isNumber(obj)) {
|
|
1155
|
+
return markBoxed(inspect(Number(obj)));
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
if (isBigInt(obj)) {
|
|
1159
|
+
return markBoxed(inspect(bigIntValueOf.call(obj)));
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
if (isBoolean(obj)) {
|
|
1163
|
+
return markBoxed(booleanValueOf.call(obj));
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
if (isString(obj)) {
|
|
1167
|
+
return markBoxed(inspect(String(obj)));
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
if (!isDate(obj) && !isRegExp(obj)) {
|
|
1171
|
+
var ys = arrObjKeys(obj, inspect);
|
|
1172
|
+
var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
1173
|
+
var protoTag = obj instanceof Object ? '' : 'null prototype';
|
|
1174
|
+
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
|
|
1175
|
+
var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
|
|
1176
|
+
var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
|
|
1177
|
+
|
|
1178
|
+
if (ys.length === 0) {
|
|
1179
|
+
return tag + '{}';
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
if (indent) {
|
|
1183
|
+
return tag + '{' + indentedJoin(ys, indent) + '}';
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
return tag + '{ ' + $join.call(ys, ', ') + ' }';
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
return String(obj);
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
function wrapQuotes(s, defaultStyle, opts) {
|
|
1193
|
+
var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
|
|
1194
|
+
return quoteChar + s + quoteChar;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
function quote(s) {
|
|
1198
|
+
return $replace.call(String(s), /"/g, '"');
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
function isArray(obj) {
|
|
1202
|
+
return toStr(obj) === '[object Array]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
function isDate(obj) {
|
|
1206
|
+
return toStr(obj) === '[object Date]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
function isRegExp(obj) {
|
|
1210
|
+
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
function isError(obj) {
|
|
1214
|
+
return toStr(obj) === '[object Error]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
function isString(obj) {
|
|
1218
|
+
return toStr(obj) === '[object String]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
function isNumber(obj) {
|
|
1222
|
+
return toStr(obj) === '[object Number]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
function isBoolean(obj) {
|
|
1226
|
+
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
function isSymbol(obj) {
|
|
1230
|
+
if (hasShammedSymbols) {
|
|
1231
|
+
return obj && _typeof(obj) === 'object' && obj instanceof Symbol;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
if (_typeof(obj) === 'symbol') {
|
|
1235
|
+
return true;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
if (!obj || _typeof(obj) !== 'object' || !symToString) {
|
|
1239
|
+
return false;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
try {
|
|
1243
|
+
symToString.call(obj);
|
|
1244
|
+
return true;
|
|
1245
|
+
} catch (e) {}
|
|
1246
|
+
|
|
1247
|
+
return false;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
function isBigInt(obj) {
|
|
1251
|
+
if (!obj || _typeof(obj) !== 'object' || !bigIntValueOf) {
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
try {
|
|
1256
|
+
bigIntValueOf.call(obj);
|
|
1257
|
+
return true;
|
|
1258
|
+
} catch (e) {}
|
|
1259
|
+
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
var hasOwn = Object.prototype.hasOwnProperty || function (key) {
|
|
1264
|
+
return key in this;
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
function has(obj, key) {
|
|
1268
|
+
return hasOwn.call(obj, key);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
function toStr(obj) {
|
|
1272
|
+
return objectToString.call(obj);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function nameOf(f) {
|
|
1276
|
+
if (f.name) {
|
|
1277
|
+
return f.name;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
|
|
1281
|
+
|
|
1282
|
+
if (m) {
|
|
1283
|
+
return m[1];
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
return null;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
function indexOf(xs, x) {
|
|
1290
|
+
if (xs.indexOf) {
|
|
1291
|
+
return xs.indexOf(x);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
for (var i = 0, l = xs.length; i < l; i++) {
|
|
1295
|
+
if (xs[i] === x) {
|
|
1296
|
+
return i;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
return -1;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
function isMap(x) {
|
|
1304
|
+
if (!mapSize || !x || _typeof(x) !== 'object') {
|
|
1305
|
+
return false;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
try {
|
|
1309
|
+
mapSize.call(x);
|
|
1310
|
+
|
|
1311
|
+
try {
|
|
1312
|
+
setSize.call(x);
|
|
1313
|
+
} catch (s) {
|
|
1314
|
+
return true;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
return x instanceof Map;
|
|
1318
|
+
} catch (e) {}
|
|
1319
|
+
|
|
1320
|
+
return false;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
function isWeakMap(x) {
|
|
1324
|
+
if (!weakMapHas || !x || _typeof(x) !== 'object') {
|
|
1325
|
+
return false;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
try {
|
|
1329
|
+
weakMapHas.call(x, weakMapHas);
|
|
1330
|
+
|
|
1331
|
+
try {
|
|
1332
|
+
weakSetHas.call(x, weakSetHas);
|
|
1333
|
+
} catch (s) {
|
|
1334
|
+
return true;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
return x instanceof WeakMap;
|
|
1338
|
+
} catch (e) {}
|
|
1339
|
+
|
|
1340
|
+
return false;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
function isWeakRef(x) {
|
|
1344
|
+
if (!weakRefDeref || !x || _typeof(x) !== 'object') {
|
|
1345
|
+
return false;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
try {
|
|
1349
|
+
weakRefDeref.call(x);
|
|
1350
|
+
return true;
|
|
1351
|
+
} catch (e) {}
|
|
1352
|
+
|
|
1353
|
+
return false;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
function isSet(x) {
|
|
1357
|
+
if (!setSize || !x || _typeof(x) !== 'object') {
|
|
1358
|
+
return false;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
try {
|
|
1362
|
+
setSize.call(x);
|
|
1363
|
+
|
|
1364
|
+
try {
|
|
1365
|
+
mapSize.call(x);
|
|
1366
|
+
} catch (m) {
|
|
1367
|
+
return true;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
return x instanceof Set;
|
|
1371
|
+
} catch (e) {}
|
|
1372
|
+
|
|
1373
|
+
return false;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
function isWeakSet(x) {
|
|
1377
|
+
if (!weakSetHas || !x || _typeof(x) !== 'object') {
|
|
1378
|
+
return false;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
try {
|
|
1382
|
+
weakSetHas.call(x, weakSetHas);
|
|
1383
|
+
|
|
1384
|
+
try {
|
|
1385
|
+
weakMapHas.call(x, weakMapHas);
|
|
1386
|
+
} catch (s) {
|
|
1387
|
+
return true;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
return x instanceof WeakSet;
|
|
1391
|
+
} catch (e) {}
|
|
1392
|
+
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
function isElement(x) {
|
|
1397
|
+
if (!x || _typeof(x) !== 'object') {
|
|
1398
|
+
return false;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
|
|
1402
|
+
return true;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function inspectString(str, opts) {
|
|
1409
|
+
if (str.length > opts.maxStringLength) {
|
|
1410
|
+
var remaining = str.length - opts.maxStringLength;
|
|
1411
|
+
var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
|
|
1412
|
+
return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
|
|
1416
|
+
return wrapQuotes(s, 'single', opts);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
function lowbyte(c) {
|
|
1420
|
+
var n = c.charCodeAt(0);
|
|
1421
|
+
var x = {
|
|
1422
|
+
8: 'b',
|
|
1423
|
+
9: 't',
|
|
1424
|
+
10: 'n',
|
|
1425
|
+
12: 'f',
|
|
1426
|
+
13: 'r'
|
|
1427
|
+
}[n];
|
|
1428
|
+
|
|
1429
|
+
if (x) {
|
|
1430
|
+
return '\\' + x;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
function markBoxed(str) {
|
|
1437
|
+
return 'Object(' + str + ')';
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
function weakCollectionOf(type) {
|
|
1441
|
+
return type + ' { ? }';
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
function collectionOf(type, size, entries, indent) {
|
|
1445
|
+
var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
|
|
1446
|
+
return type + ' (' + size + ') {' + joinedEntries + '}';
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
function singleLineValues(xs) {
|
|
1450
|
+
for (var i = 0; i < xs.length; i++) {
|
|
1451
|
+
if (indexOf(xs[i], '\n') >= 0) {
|
|
1452
|
+
return false;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
return true;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
function getIndent(opts, depth) {
|
|
1460
|
+
var baseIndent;
|
|
1461
|
+
|
|
1462
|
+
if (opts.indent === '\t') {
|
|
1463
|
+
baseIndent = '\t';
|
|
1464
|
+
} else if (typeof opts.indent === 'number' && opts.indent > 0) {
|
|
1465
|
+
baseIndent = $join.call(Array(opts.indent + 1), ' ');
|
|
1466
|
+
} else {
|
|
1467
|
+
return null;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
return {
|
|
1471
|
+
base: baseIndent,
|
|
1472
|
+
prev: $join.call(Array(depth + 1), baseIndent)
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
function indentedJoin(xs, indent) {
|
|
1477
|
+
if (xs.length === 0) {
|
|
1478
|
+
return '';
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
var lineJoiner = '\n' + indent.prev + indent.base;
|
|
1482
|
+
return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
function arrObjKeys(obj, inspect) {
|
|
1486
|
+
var isArr = isArray(obj);
|
|
1487
|
+
var xs = [];
|
|
1488
|
+
|
|
1489
|
+
if (isArr) {
|
|
1490
|
+
xs.length = obj.length;
|
|
1491
|
+
|
|
1492
|
+
for (var i = 0; i < obj.length; i++) {
|
|
1493
|
+
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
|
|
1498
|
+
var symMap;
|
|
1499
|
+
|
|
1500
|
+
if (hasShammedSymbols) {
|
|
1501
|
+
symMap = {};
|
|
1502
|
+
|
|
1503
|
+
for (var k = 0; k < syms.length; k++) {
|
|
1504
|
+
symMap['$' + syms[k]] = syms[k];
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
for (var key in obj) {
|
|
1509
|
+
if (!has(obj, key)) {
|
|
1510
|
+
continue;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
if (isArr && String(Number(key)) === key && key < obj.length) {
|
|
1514
|
+
continue;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
|
|
1518
|
+
continue;
|
|
1519
|
+
} else if ($test.call(/[^\w$]/, key)) {
|
|
1520
|
+
xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
|
|
1521
|
+
} else {
|
|
1522
|
+
xs.push(key + ': ' + inspect(obj[key], obj));
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
if (typeof gOPS === 'function') {
|
|
1527
|
+
for (var j = 0; j < syms.length; j++) {
|
|
1528
|
+
if (isEnumerable.call(obj, syms[j])) {
|
|
1529
|
+
xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
return xs;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
},{"./util.inspect":1}],13:[function(require,module,exports){
|
|
1538
|
+
"use strict";
|
|
1539
|
+
|
|
1540
|
+
var process = module.exports = {};
|
|
1541
|
+
var cachedSetTimeout;
|
|
1542
|
+
var cachedClearTimeout;
|
|
1543
|
+
|
|
1544
|
+
function defaultSetTimout() {
|
|
1545
|
+
throw new Error('setTimeout has not been defined');
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
function defaultClearTimeout() {
|
|
1549
|
+
throw new Error('clearTimeout has not been defined');
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
(function () {
|
|
1553
|
+
try {
|
|
1554
|
+
if (typeof setTimeout === 'function') {
|
|
1555
|
+
cachedSetTimeout = setTimeout;
|
|
1556
|
+
} else {
|
|
1557
|
+
cachedSetTimeout = defaultSetTimout;
|
|
1558
|
+
}
|
|
1559
|
+
} catch (e) {
|
|
1560
|
+
cachedSetTimeout = defaultSetTimout;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
try {
|
|
1564
|
+
if (typeof clearTimeout === 'function') {
|
|
1565
|
+
cachedClearTimeout = clearTimeout;
|
|
1566
|
+
} else {
|
|
1567
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
1568
|
+
}
|
|
1569
|
+
} catch (e) {
|
|
1570
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
1571
|
+
}
|
|
1572
|
+
})();
|
|
1573
|
+
|
|
1574
|
+
function runTimeout(fun) {
|
|
1575
|
+
if (cachedSetTimeout === setTimeout) {
|
|
1576
|
+
return setTimeout(fun, 0);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
1580
|
+
cachedSetTimeout = setTimeout;
|
|
1581
|
+
return setTimeout(fun, 0);
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
try {
|
|
1585
|
+
return cachedSetTimeout(fun, 0);
|
|
1586
|
+
} catch (e) {
|
|
1587
|
+
try {
|
|
1588
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
1589
|
+
} catch (e) {
|
|
1590
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
function runClearTimeout(marker) {
|
|
1596
|
+
if (cachedClearTimeout === clearTimeout) {
|
|
1597
|
+
return clearTimeout(marker);
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
1601
|
+
cachedClearTimeout = clearTimeout;
|
|
1602
|
+
return clearTimeout(marker);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
try {
|
|
1606
|
+
return cachedClearTimeout(marker);
|
|
1607
|
+
} catch (e) {
|
|
1608
|
+
try {
|
|
1609
|
+
return cachedClearTimeout.call(null, marker);
|
|
1610
|
+
} catch (e) {
|
|
1611
|
+
return cachedClearTimeout.call(this, marker);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
var queue = [];
|
|
1617
|
+
var draining = false;
|
|
1618
|
+
var currentQueue;
|
|
1619
|
+
var queueIndex = -1;
|
|
1620
|
+
|
|
1621
|
+
function cleanUpNextTick() {
|
|
1622
|
+
if (!draining || !currentQueue) {
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
draining = false;
|
|
1627
|
+
|
|
1628
|
+
if (currentQueue.length) {
|
|
1629
|
+
queue = currentQueue.concat(queue);
|
|
1630
|
+
} else {
|
|
1631
|
+
queueIndex = -1;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
if (queue.length) {
|
|
1635
|
+
drainQueue();
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
function drainQueue() {
|
|
1640
|
+
if (draining) {
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
1645
|
+
draining = true;
|
|
1646
|
+
var len = queue.length;
|
|
1647
|
+
|
|
1648
|
+
while (len) {
|
|
1649
|
+
currentQueue = queue;
|
|
1650
|
+
queue = [];
|
|
1651
|
+
|
|
1652
|
+
while (++queueIndex < len) {
|
|
1653
|
+
if (currentQueue) {
|
|
1654
|
+
currentQueue[queueIndex].run();
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
queueIndex = -1;
|
|
1659
|
+
len = queue.length;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
currentQueue = null;
|
|
1663
|
+
draining = false;
|
|
1664
|
+
runClearTimeout(timeout);
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
process.nextTick = function (fun) {
|
|
1668
|
+
var args = new Array(arguments.length - 1);
|
|
1669
|
+
|
|
1670
|
+
if (arguments.length > 1) {
|
|
1671
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1672
|
+
args[i - 1] = arguments[i];
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
queue.push(new Item(fun, args));
|
|
1677
|
+
|
|
1678
|
+
if (queue.length === 1 && !draining) {
|
|
1679
|
+
runTimeout(drainQueue);
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
|
|
1683
|
+
function Item(fun, array) {
|
|
1684
|
+
this.fun = fun;
|
|
1685
|
+
this.array = array;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
Item.prototype.run = function () {
|
|
1689
|
+
this.fun.apply(null, this.array);
|
|
1690
|
+
};
|
|
1691
|
+
|
|
1692
|
+
process.title = 'browser';
|
|
1693
|
+
process.browser = true;
|
|
1694
|
+
process.env = {};
|
|
1695
|
+
process.argv = [];
|
|
1696
|
+
process.version = '';
|
|
1697
|
+
process.versions = {};
|
|
1698
|
+
|
|
1699
|
+
function noop() {}
|
|
1700
|
+
|
|
1701
|
+
process.on = noop;
|
|
1702
|
+
process.addListener = noop;
|
|
1703
|
+
process.once = noop;
|
|
1704
|
+
process.off = noop;
|
|
1705
|
+
process.removeListener = noop;
|
|
1706
|
+
process.removeAllListeners = noop;
|
|
1707
|
+
process.emit = noop;
|
|
1708
|
+
process.prependListener = noop;
|
|
1709
|
+
process.prependOnceListener = noop;
|
|
1710
|
+
|
|
1711
|
+
process.listeners = function (name) {
|
|
1712
|
+
return [];
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
process.binding = function (name) {
|
|
1716
|
+
throw new Error('process.binding is not supported');
|
|
1717
|
+
};
|
|
1718
|
+
|
|
1719
|
+
process.cwd = function () {
|
|
1720
|
+
return '/';
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
process.chdir = function (dir) {
|
|
1724
|
+
throw new Error('process.chdir is not supported');
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
process.umask = function () {
|
|
1728
|
+
return 0;
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
},{}],14:[function(require,module,exports){
|
|
1732
|
+
'use strict';
|
|
1733
|
+
|
|
1734
|
+
var replace = String.prototype.replace;
|
|
1735
|
+
var percentTwenties = /%20/g;
|
|
1736
|
+
var Format = {
|
|
1737
|
+
RFC1738: 'RFC1738',
|
|
1738
|
+
RFC3986: 'RFC3986'
|
|
1739
|
+
};
|
|
1740
|
+
module.exports = {
|
|
1741
|
+
'default': Format.RFC3986,
|
|
1742
|
+
formatters: {
|
|
1743
|
+
RFC1738: function RFC1738(value) {
|
|
1744
|
+
return replace.call(value, percentTwenties, '+');
|
|
1745
|
+
},
|
|
1746
|
+
RFC3986: function RFC3986(value) {
|
|
1747
|
+
return String(value);
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
RFC1738: Format.RFC1738,
|
|
1751
|
+
RFC3986: Format.RFC3986
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1754
|
+
},{}],15:[function(require,module,exports){
|
|
1755
|
+
'use strict';
|
|
1756
|
+
|
|
1757
|
+
var stringify = require('./stringify');
|
|
1758
|
+
|
|
1759
|
+
var parse = require('./parse');
|
|
1760
|
+
|
|
1761
|
+
var formats = require('./formats');
|
|
1762
|
+
|
|
1763
|
+
module.exports = {
|
|
1764
|
+
formats: formats,
|
|
1765
|
+
parse: parse,
|
|
1766
|
+
stringify: stringify
|
|
1767
|
+
};
|
|
1768
|
+
|
|
1769
|
+
},{"./formats":14,"./parse":16,"./stringify":17}],16:[function(require,module,exports){
|
|
1770
|
+
'use strict';
|
|
1771
|
+
|
|
1772
|
+
var utils = require('./utils');
|
|
1773
|
+
|
|
1774
|
+
var has = Object.prototype.hasOwnProperty;
|
|
1775
|
+
var isArray = Array.isArray;
|
|
1776
|
+
var defaults = {
|
|
1777
|
+
allowDots: false,
|
|
1778
|
+
allowPrototypes: false,
|
|
1779
|
+
allowSparse: false,
|
|
1780
|
+
arrayLimit: 20,
|
|
1781
|
+
charset: 'utf-8',
|
|
1782
|
+
charsetSentinel: false,
|
|
1783
|
+
comma: false,
|
|
1784
|
+
decoder: utils.decode,
|
|
1785
|
+
delimiter: '&',
|
|
1786
|
+
depth: 5,
|
|
1787
|
+
ignoreQueryPrefix: false,
|
|
1788
|
+
interpretNumericEntities: false,
|
|
1789
|
+
parameterLimit: 1000,
|
|
1790
|
+
parseArrays: true,
|
|
1791
|
+
plainObjects: false,
|
|
1792
|
+
strictNullHandling: false
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
var interpretNumericEntities = function interpretNumericEntities(str) {
|
|
1796
|
+
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
|
1797
|
+
return String.fromCharCode(parseInt(numberStr, 10));
|
|
1798
|
+
});
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
var parseArrayValue = function parseArrayValue(val, options) {
|
|
1802
|
+
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
1803
|
+
return val.split(',');
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
return val;
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1809
|
+
var isoSentinel = 'utf8=%26%2310003%3B';
|
|
1810
|
+
var charsetSentinel = 'utf8=%E2%9C%93';
|
|
1811
|
+
|
|
1812
|
+
var parseValues = function parseQueryStringValues(str, options) {
|
|
1813
|
+
var obj = {};
|
|
1814
|
+
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
|
1815
|
+
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
|
1816
|
+
var parts = cleanStr.split(options.delimiter, limit);
|
|
1817
|
+
var skipIndex = -1;
|
|
1818
|
+
var i;
|
|
1819
|
+
var charset = options.charset;
|
|
1820
|
+
|
|
1821
|
+
if (options.charsetSentinel) {
|
|
1822
|
+
for (i = 0; i < parts.length; ++i) {
|
|
1823
|
+
if (parts[i].indexOf('utf8=') === 0) {
|
|
1824
|
+
if (parts[i] === charsetSentinel) {
|
|
1825
|
+
charset = 'utf-8';
|
|
1826
|
+
} else if (parts[i] === isoSentinel) {
|
|
1827
|
+
charset = 'iso-8859-1';
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
skipIndex = i;
|
|
1831
|
+
i = parts.length;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
for (i = 0; i < parts.length; ++i) {
|
|
1837
|
+
if (i === skipIndex) {
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
var part = parts[i];
|
|
1842
|
+
var bracketEqualsPos = part.indexOf(']=');
|
|
1843
|
+
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
|
1844
|
+
var key, val;
|
|
1845
|
+
|
|
1846
|
+
if (pos === -1) {
|
|
1847
|
+
key = options.decoder(part, defaults.decoder, charset, 'key');
|
|
1848
|
+
val = options.strictNullHandling ? null : '';
|
|
1849
|
+
} else {
|
|
1850
|
+
key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
|
|
1851
|
+
val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options), function (encodedVal) {
|
|
1852
|
+
return options.decoder(encodedVal, defaults.decoder, charset, 'value');
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
|
|
1857
|
+
val = interpretNumericEntities(val);
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
if (part.indexOf('[]=') > -1) {
|
|
1861
|
+
val = isArray(val) ? [val] : val;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
if (has.call(obj, key)) {
|
|
1865
|
+
obj[key] = utils.combine(obj[key], val);
|
|
1866
|
+
} else {
|
|
1867
|
+
obj[key] = val;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
return obj;
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
var parseObject = function parseObject(chain, val, options, valuesParsed) {
|
|
1875
|
+
var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
|
1876
|
+
|
|
1877
|
+
for (var i = chain.length - 1; i >= 0; --i) {
|
|
1878
|
+
var obj;
|
|
1879
|
+
var root = chain[i];
|
|
1880
|
+
|
|
1881
|
+
if (root === '[]' && options.parseArrays) {
|
|
1882
|
+
obj = [].concat(leaf);
|
|
1883
|
+
} else {
|
|
1884
|
+
obj = options.plainObjects ? Object.create(null) : {};
|
|
1885
|
+
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
|
1886
|
+
var index = parseInt(cleanRoot, 10);
|
|
1887
|
+
|
|
1888
|
+
if (!options.parseArrays && cleanRoot === '') {
|
|
1889
|
+
obj = {
|
|
1890
|
+
0: leaf
|
|
1891
|
+
};
|
|
1892
|
+
} else if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
|
|
1893
|
+
obj = [];
|
|
1894
|
+
obj[index] = leaf;
|
|
1895
|
+
} else {
|
|
1896
|
+
obj[cleanRoot] = leaf;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
leaf = obj;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
return leaf;
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1906
|
+
var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
|
|
1907
|
+
if (!givenKey) {
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
|
1912
|
+
var brackets = /(\[[^[\]]*])/;
|
|
1913
|
+
var child = /(\[[^[\]]*])/g;
|
|
1914
|
+
var segment = options.depth > 0 && brackets.exec(key);
|
|
1915
|
+
var parent = segment ? key.slice(0, segment.index) : key;
|
|
1916
|
+
var keys = [];
|
|
1917
|
+
|
|
1918
|
+
if (parent) {
|
|
1919
|
+
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
|
1920
|
+
if (!options.allowPrototypes) {
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
keys.push(parent);
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
var i = 0;
|
|
1929
|
+
|
|
1930
|
+
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
|
|
1931
|
+
i += 1;
|
|
1932
|
+
|
|
1933
|
+
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
|
1934
|
+
if (!options.allowPrototypes) {
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
keys.push(segment[1]);
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
if (segment) {
|
|
1943
|
+
keys.push('[' + key.slice(segment.index) + ']');
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
return parseObject(keys, val, options, valuesParsed);
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
var normalizeParseOptions = function normalizeParseOptions(opts) {
|
|
1950
|
+
if (!opts) {
|
|
1951
|
+
return defaults;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
|
|
1955
|
+
throw new TypeError('Decoder has to be a function.');
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
1959
|
+
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
|
|
1963
|
+
return {
|
|
1964
|
+
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
1965
|
+
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
|
|
1966
|
+
allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
|
|
1967
|
+
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
|
|
1968
|
+
charset: charset,
|
|
1969
|
+
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
|
1970
|
+
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
|
|
1971
|
+
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
|
|
1972
|
+
delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
|
|
1973
|
+
depth: typeof opts.depth === 'number' || opts.depth === false ? +opts.depth : defaults.depth,
|
|
1974
|
+
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
|
|
1975
|
+
interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
|
|
1976
|
+
parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
|
|
1977
|
+
parseArrays: opts.parseArrays !== false,
|
|
1978
|
+
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
|
|
1979
|
+
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
1980
|
+
};
|
|
1981
|
+
};
|
|
1982
|
+
|
|
1983
|
+
module.exports = function (str, opts) {
|
|
1984
|
+
var options = normalizeParseOptions(opts);
|
|
1985
|
+
|
|
1986
|
+
if (str === '' || str === null || typeof str === 'undefined') {
|
|
1987
|
+
return options.plainObjects ? Object.create(null) : {};
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
|
1991
|
+
var obj = options.plainObjects ? Object.create(null) : {};
|
|
1992
|
+
var keys = Object.keys(tempObj);
|
|
1993
|
+
|
|
1994
|
+
for (var i = 0; i < keys.length; ++i) {
|
|
1995
|
+
var key = keys[i];
|
|
1996
|
+
var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
|
|
1997
|
+
obj = utils.merge(obj, newObj, options);
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
if (options.allowSparse === true) {
|
|
2001
|
+
return obj;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
return utils.compact(obj);
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
},{"./utils":18}],17:[function(require,module,exports){
|
|
2008
|
+
'use strict';
|
|
2009
|
+
|
|
2010
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2011
|
+
|
|
2012
|
+
var getSideChannel = require('side-channel');
|
|
2013
|
+
|
|
2014
|
+
var utils = require('./utils');
|
|
2015
|
+
|
|
2016
|
+
var formats = require('./formats');
|
|
2017
|
+
|
|
2018
|
+
var has = Object.prototype.hasOwnProperty;
|
|
2019
|
+
var arrayPrefixGenerators = {
|
|
2020
|
+
brackets: function brackets(prefix) {
|
|
2021
|
+
return prefix + '[]';
|
|
2022
|
+
},
|
|
2023
|
+
comma: 'comma',
|
|
2024
|
+
indices: function indices(prefix, key) {
|
|
2025
|
+
return prefix + '[' + key + ']';
|
|
2026
|
+
},
|
|
2027
|
+
repeat: function repeat(prefix) {
|
|
2028
|
+
return prefix;
|
|
2029
|
+
}
|
|
2030
|
+
};
|
|
2031
|
+
var isArray = Array.isArray;
|
|
2032
|
+
var split = String.prototype.split;
|
|
2033
|
+
var push = Array.prototype.push;
|
|
2034
|
+
|
|
2035
|
+
var pushToArray = function pushToArray(arr, valueOrArray) {
|
|
2036
|
+
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
2037
|
+
};
|
|
2038
|
+
|
|
2039
|
+
var toISO = Date.prototype.toISOString;
|
|
2040
|
+
var defaultFormat = formats['default'];
|
|
2041
|
+
var defaults = {
|
|
2042
|
+
addQueryPrefix: false,
|
|
2043
|
+
allowDots: false,
|
|
2044
|
+
charset: 'utf-8',
|
|
2045
|
+
charsetSentinel: false,
|
|
2046
|
+
delimiter: '&',
|
|
2047
|
+
encode: true,
|
|
2048
|
+
encoder: utils.encode,
|
|
2049
|
+
encodeValuesOnly: false,
|
|
2050
|
+
format: defaultFormat,
|
|
2051
|
+
formatter: formats.formatters[defaultFormat],
|
|
2052
|
+
indices: false,
|
|
2053
|
+
serializeDate: function serializeDate(date) {
|
|
2054
|
+
return toISO.call(date);
|
|
2055
|
+
},
|
|
2056
|
+
skipNulls: false,
|
|
2057
|
+
strictNullHandling: false
|
|
2058
|
+
};
|
|
2059
|
+
|
|
2060
|
+
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
2061
|
+
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || _typeof(v) === 'symbol' || typeof v === 'bigint';
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
var sentinel = {};
|
|
2065
|
+
|
|
2066
|
+
var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
|
|
2067
|
+
var obj = object;
|
|
2068
|
+
var tmpSc = sideChannel;
|
|
2069
|
+
var step = 0;
|
|
2070
|
+
var findFlag = false;
|
|
2071
|
+
|
|
2072
|
+
while ((tmpSc = tmpSc.get(sentinel)) !== undefined && !findFlag) {
|
|
2073
|
+
var pos = tmpSc.get(object);
|
|
2074
|
+
step += 1;
|
|
2075
|
+
|
|
2076
|
+
if (typeof pos !== 'undefined') {
|
|
2077
|
+
if (pos === step) {
|
|
2078
|
+
throw new RangeError('Cyclic object value');
|
|
2079
|
+
} else {
|
|
2080
|
+
findFlag = true;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
if (typeof tmpSc.get(sentinel) === 'undefined') {
|
|
2085
|
+
step = 0;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
if (typeof filter === 'function') {
|
|
2090
|
+
obj = filter(prefix, obj);
|
|
2091
|
+
} else if (obj instanceof Date) {
|
|
2092
|
+
obj = serializeDate(obj);
|
|
2093
|
+
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
|
2094
|
+
obj = utils.maybeMap(obj, function (value) {
|
|
2095
|
+
if (value instanceof Date) {
|
|
2096
|
+
return serializeDate(value);
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
return value;
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
if (obj === null) {
|
|
2104
|
+
if (strictNullHandling) {
|
|
2105
|
+
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
obj = '';
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
|
|
2112
|
+
if (encoder) {
|
|
2113
|
+
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
|
|
2114
|
+
|
|
2115
|
+
if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
|
|
2116
|
+
var valuesArray = split.call(String(obj), ',');
|
|
2117
|
+
var valuesJoined = '';
|
|
2118
|
+
|
|
2119
|
+
for (var i = 0; i < valuesArray.length; ++i) {
|
|
2120
|
+
valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
return [formatter(keyValue) + '=' + valuesJoined];
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
return [formatter(prefix) + '=' + formatter(String(obj))];
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
var values = [];
|
|
2133
|
+
|
|
2134
|
+
if (typeof obj === 'undefined') {
|
|
2135
|
+
return values;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
var objKeys;
|
|
2139
|
+
|
|
2140
|
+
if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
|
2141
|
+
objKeys = [{
|
|
2142
|
+
value: obj.length > 0 ? obj.join(',') || null : undefined
|
|
2143
|
+
}];
|
|
2144
|
+
} else if (isArray(filter)) {
|
|
2145
|
+
objKeys = filter;
|
|
2146
|
+
} else {
|
|
2147
|
+
var keys = Object.keys(obj);
|
|
2148
|
+
objKeys = sort ? keys.sort(sort) : keys;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
for (var j = 0; j < objKeys.length; ++j) {
|
|
2152
|
+
var key = objKeys[j];
|
|
2153
|
+
var value = _typeof(key) === 'object' && key.value !== undefined ? key.value : obj[key];
|
|
2154
|
+
|
|
2155
|
+
if (skipNulls && value === null) {
|
|
2156
|
+
continue;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix : prefix + (allowDots ? '.' + key : '[' + key + ']');
|
|
2160
|
+
sideChannel.set(object, step);
|
|
2161
|
+
var valueSideChannel = getSideChannel();
|
|
2162
|
+
valueSideChannel.set(sentinel, sideChannel);
|
|
2163
|
+
pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
return values;
|
|
2167
|
+
};
|
|
2168
|
+
|
|
2169
|
+
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
|
2170
|
+
if (!opts) {
|
|
2171
|
+
return defaults;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
|
|
2175
|
+
throw new TypeError('Encoder has to be a function.');
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
var charset = opts.charset || defaults.charset;
|
|
2179
|
+
|
|
2180
|
+
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
2181
|
+
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
var format = formats['default'];
|
|
2185
|
+
|
|
2186
|
+
if (typeof opts.format !== 'undefined') {
|
|
2187
|
+
if (!has.call(formats.formatters, opts.format)) {
|
|
2188
|
+
throw new TypeError('Unknown format option provided.');
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
format = opts.format;
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
var formatter = formats.formatters[format];
|
|
2195
|
+
var filter = defaults.filter;
|
|
2196
|
+
|
|
2197
|
+
if (typeof opts.filter === 'function' || isArray(opts.filter)) {
|
|
2198
|
+
filter = opts.filter;
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
return {
|
|
2202
|
+
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
|
2203
|
+
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
2204
|
+
charset: charset,
|
|
2205
|
+
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
|
2206
|
+
delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
|
|
2207
|
+
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
|
|
2208
|
+
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
|
|
2209
|
+
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
|
|
2210
|
+
filter: filter,
|
|
2211
|
+
format: format,
|
|
2212
|
+
formatter: formatter,
|
|
2213
|
+
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
|
|
2214
|
+
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
|
|
2215
|
+
sort: typeof opts.sort === 'function' ? opts.sort : null,
|
|
2216
|
+
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
2217
|
+
};
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2220
|
+
module.exports = function (object, opts) {
|
|
2221
|
+
var obj = object;
|
|
2222
|
+
var options = normalizeStringifyOptions(opts);
|
|
2223
|
+
var objKeys;
|
|
2224
|
+
var filter;
|
|
2225
|
+
|
|
2226
|
+
if (typeof options.filter === 'function') {
|
|
2227
|
+
filter = options.filter;
|
|
2228
|
+
obj = filter('', obj);
|
|
2229
|
+
} else if (isArray(options.filter)) {
|
|
2230
|
+
filter = options.filter;
|
|
2231
|
+
objKeys = filter;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
var keys = [];
|
|
2235
|
+
|
|
2236
|
+
if (_typeof(obj) !== 'object' || obj === null) {
|
|
2237
|
+
return '';
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
var arrayFormat;
|
|
2241
|
+
|
|
2242
|
+
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
|
2243
|
+
arrayFormat = opts.arrayFormat;
|
|
2244
|
+
} else if (opts && 'indices' in opts) {
|
|
2245
|
+
arrayFormat = opts.indices ? 'indices' : 'repeat';
|
|
2246
|
+
} else {
|
|
2247
|
+
arrayFormat = 'indices';
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
|
2251
|
+
|
|
2252
|
+
if (!objKeys) {
|
|
2253
|
+
objKeys = Object.keys(obj);
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
if (options.sort) {
|
|
2257
|
+
objKeys.sort(options.sort);
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
var sideChannel = getSideChannel();
|
|
2261
|
+
|
|
2262
|
+
for (var i = 0; i < objKeys.length; ++i) {
|
|
2263
|
+
var key = objKeys[i];
|
|
2264
|
+
|
|
2265
|
+
if (options.skipNulls && obj[key] === null) {
|
|
2266
|
+
continue;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel));
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
var joined = keys.join(options.delimiter);
|
|
2273
|
+
var prefix = options.addQueryPrefix === true ? '?' : '';
|
|
2274
|
+
|
|
2275
|
+
if (options.charsetSentinel) {
|
|
2276
|
+
if (options.charset === 'iso-8859-1') {
|
|
2277
|
+
prefix += 'utf8=%26%2310003%3B&';
|
|
2278
|
+
} else {
|
|
2279
|
+
prefix += 'utf8=%E2%9C%93&';
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
return joined.length > 0 ? prefix + joined : '';
|
|
2284
|
+
};
|
|
2285
|
+
|
|
2286
|
+
},{"./formats":14,"./utils":18,"side-channel":19}],18:[function(require,module,exports){
|
|
2287
|
+
'use strict';
|
|
2288
|
+
|
|
2289
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2290
|
+
|
|
2291
|
+
var formats = require('./formats');
|
|
2292
|
+
|
|
2293
|
+
var has = Object.prototype.hasOwnProperty;
|
|
2294
|
+
var isArray = Array.isArray;
|
|
2295
|
+
|
|
2296
|
+
var hexTable = function () {
|
|
2297
|
+
var array = [];
|
|
2298
|
+
|
|
2299
|
+
for (var i = 0; i < 256; ++i) {
|
|
2300
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
return array;
|
|
2304
|
+
}();
|
|
2305
|
+
|
|
2306
|
+
var compactQueue = function compactQueue(queue) {
|
|
2307
|
+
while (queue.length > 1) {
|
|
2308
|
+
var item = queue.pop();
|
|
2309
|
+
var obj = item.obj[item.prop];
|
|
2310
|
+
|
|
2311
|
+
if (isArray(obj)) {
|
|
2312
|
+
var compacted = [];
|
|
2313
|
+
|
|
2314
|
+
for (var j = 0; j < obj.length; ++j) {
|
|
2315
|
+
if (typeof obj[j] !== 'undefined') {
|
|
2316
|
+
compacted.push(obj[j]);
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
item.obj[item.prop] = compacted;
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2325
|
+
var arrayToObject = function arrayToObject(source, options) {
|
|
2326
|
+
var obj = options && options.plainObjects ? Object.create(null) : {};
|
|
2327
|
+
|
|
2328
|
+
for (var i = 0; i < source.length; ++i) {
|
|
2329
|
+
if (typeof source[i] !== 'undefined') {
|
|
2330
|
+
obj[i] = source[i];
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
return obj;
|
|
2335
|
+
};
|
|
2336
|
+
|
|
2337
|
+
var merge = function merge(target, source, options) {
|
|
2338
|
+
if (!source) {
|
|
2339
|
+
return target;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
if (_typeof(source) !== 'object') {
|
|
2343
|
+
if (isArray(target)) {
|
|
2344
|
+
target.push(source);
|
|
2345
|
+
} else if (target && _typeof(target) === 'object') {
|
|
2346
|
+
if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
|
|
2347
|
+
target[source] = true;
|
|
2348
|
+
}
|
|
2349
|
+
} else {
|
|
2350
|
+
return [target, source];
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
return target;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
if (!target || _typeof(target) !== 'object') {
|
|
2357
|
+
return [target].concat(source);
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
var mergeTarget = target;
|
|
2361
|
+
|
|
2362
|
+
if (isArray(target) && !isArray(source)) {
|
|
2363
|
+
mergeTarget = arrayToObject(target, options);
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
if (isArray(target) && isArray(source)) {
|
|
2367
|
+
source.forEach(function (item, i) {
|
|
2368
|
+
if (has.call(target, i)) {
|
|
2369
|
+
var targetItem = target[i];
|
|
2370
|
+
|
|
2371
|
+
if (targetItem && _typeof(targetItem) === 'object' && item && _typeof(item) === 'object') {
|
|
2372
|
+
target[i] = merge(targetItem, item, options);
|
|
2373
|
+
} else {
|
|
2374
|
+
target.push(item);
|
|
2375
|
+
}
|
|
2376
|
+
} else {
|
|
2377
|
+
target[i] = item;
|
|
2378
|
+
}
|
|
2379
|
+
});
|
|
2380
|
+
return target;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
2384
|
+
var value = source[key];
|
|
2385
|
+
|
|
2386
|
+
if (has.call(acc, key)) {
|
|
2387
|
+
acc[key] = merge(acc[key], value, options);
|
|
2388
|
+
} else {
|
|
2389
|
+
acc[key] = value;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
return acc;
|
|
2393
|
+
}, mergeTarget);
|
|
2394
|
+
};
|
|
2395
|
+
|
|
2396
|
+
var assign = function assignSingleSource(target, source) {
|
|
2397
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
2398
|
+
acc[key] = source[key];
|
|
2399
|
+
return acc;
|
|
2400
|
+
}, target);
|
|
2401
|
+
};
|
|
2402
|
+
|
|
2403
|
+
var decode = function decode(str, decoder, charset) {
|
|
2404
|
+
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
2405
|
+
|
|
2406
|
+
if (charset === 'iso-8859-1') {
|
|
2407
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
try {
|
|
2411
|
+
return decodeURIComponent(strWithoutPlus);
|
|
2412
|
+
} catch (e) {
|
|
2413
|
+
return strWithoutPlus;
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2417
|
+
var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
|
2418
|
+
if (str.length === 0) {
|
|
2419
|
+
return str;
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
var string = str;
|
|
2423
|
+
|
|
2424
|
+
if (_typeof(str) === 'symbol') {
|
|
2425
|
+
string = Symbol.prototype.toString.call(str);
|
|
2426
|
+
} else if (typeof str !== 'string') {
|
|
2427
|
+
string = String(str);
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
if (charset === 'iso-8859-1') {
|
|
2431
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
2432
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
var out = '';
|
|
2437
|
+
|
|
2438
|
+
for (var i = 0; i < string.length; ++i) {
|
|
2439
|
+
var c = string.charCodeAt(i);
|
|
2440
|
+
|
|
2441
|
+
if (c === 0x2D || c === 0x2E || c === 0x5F || c === 0x7E || c >= 0x30 && c <= 0x39 || c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || format === formats.RFC1738 && (c === 0x28 || c === 0x29)) {
|
|
2442
|
+
out += string.charAt(i);
|
|
2443
|
+
continue;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
if (c < 0x80) {
|
|
2447
|
+
out = out + hexTable[c];
|
|
2448
|
+
continue;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
if (c < 0x800) {
|
|
2452
|
+
out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);
|
|
2453
|
+
continue;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
if (c < 0xD800 || c >= 0xE000) {
|
|
2457
|
+
out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);
|
|
2458
|
+
continue;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
i += 1;
|
|
2462
|
+
c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);
|
|
2463
|
+
out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
return out;
|
|
2467
|
+
};
|
|
2468
|
+
|
|
2469
|
+
var compact = function compact(value) {
|
|
2470
|
+
var queue = [{
|
|
2471
|
+
obj: {
|
|
2472
|
+
o: value
|
|
2473
|
+
},
|
|
2474
|
+
prop: 'o'
|
|
2475
|
+
}];
|
|
2476
|
+
var refs = [];
|
|
2477
|
+
|
|
2478
|
+
for (var i = 0; i < queue.length; ++i) {
|
|
2479
|
+
var item = queue[i];
|
|
2480
|
+
var obj = item.obj[item.prop];
|
|
2481
|
+
var keys = Object.keys(obj);
|
|
2482
|
+
|
|
2483
|
+
for (var j = 0; j < keys.length; ++j) {
|
|
2484
|
+
var key = keys[j];
|
|
2485
|
+
var val = obj[key];
|
|
2486
|
+
|
|
2487
|
+
if (_typeof(val) === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
2488
|
+
queue.push({
|
|
2489
|
+
obj: obj,
|
|
2490
|
+
prop: key
|
|
2491
|
+
});
|
|
2492
|
+
refs.push(val);
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
compactQueue(queue);
|
|
2498
|
+
return value;
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2501
|
+
var isRegExp = function isRegExp(obj) {
|
|
2502
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
2503
|
+
};
|
|
2504
|
+
|
|
2505
|
+
var isBuffer = function isBuffer(obj) {
|
|
2506
|
+
if (!obj || _typeof(obj) !== 'object') {
|
|
2507
|
+
return false;
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
2511
|
+
};
|
|
2512
|
+
|
|
2513
|
+
var combine = function combine(a, b) {
|
|
2514
|
+
return [].concat(a, b);
|
|
2515
|
+
};
|
|
2516
|
+
|
|
2517
|
+
var maybeMap = function maybeMap(val, fn) {
|
|
2518
|
+
if (isArray(val)) {
|
|
2519
|
+
var mapped = [];
|
|
2520
|
+
|
|
2521
|
+
for (var i = 0; i < val.length; i += 1) {
|
|
2522
|
+
mapped.push(fn(val[i]));
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
return mapped;
|
|
263
2526
|
}
|
|
264
2527
|
|
|
265
|
-
return
|
|
266
|
-
}
|
|
2528
|
+
return fn(val);
|
|
2529
|
+
};
|
|
267
2530
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
2531
|
+
module.exports = {
|
|
2532
|
+
arrayToObject: arrayToObject,
|
|
2533
|
+
assign: assign,
|
|
2534
|
+
combine: combine,
|
|
2535
|
+
compact: compact,
|
|
2536
|
+
decode: decode,
|
|
2537
|
+
encode: encode,
|
|
2538
|
+
isBuffer: isBuffer,
|
|
2539
|
+
isRegExp: isRegExp,
|
|
2540
|
+
maybeMap: maybeMap,
|
|
2541
|
+
merge: merge
|
|
2542
|
+
};
|
|
271
2543
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
} else {
|
|
275
|
-
res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer);
|
|
276
|
-
}
|
|
2544
|
+
},{"./formats":14}],19:[function(require,module,exports){
|
|
2545
|
+
'use strict';
|
|
277
2546
|
|
|
278
|
-
|
|
279
|
-
var part = arr.pop();
|
|
2547
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
280
2548
|
|
|
281
|
-
|
|
282
|
-
Object.defineProperty(part[0], part[1], part[3]);
|
|
283
|
-
} else {
|
|
284
|
-
part[0][part[1]] = part[2];
|
|
285
|
-
}
|
|
286
|
-
}
|
|
2549
|
+
var GetIntrinsic = require('get-intrinsic');
|
|
287
2550
|
|
|
288
|
-
|
|
289
|
-
}
|
|
2551
|
+
var callBound = require('call-bind/callBound');
|
|
290
2552
|
|
|
291
|
-
|
|
292
|
-
var i;
|
|
2553
|
+
var inspect = require('object-inspect');
|
|
293
2554
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
|
304
|
-
arr.push([parent, k, val, propertyDescriptor]);
|
|
305
|
-
} else {
|
|
306
|
-
replacerStack.push([val, k]);
|
|
307
|
-
}
|
|
308
|
-
} else {
|
|
309
|
-
parent[k] = '[Circular]';
|
|
310
|
-
arr.push([parent, k, val]);
|
|
311
|
-
}
|
|
2555
|
+
var $TypeError = GetIntrinsic('%TypeError%');
|
|
2556
|
+
var $WeakMap = GetIntrinsic('%WeakMap%', true);
|
|
2557
|
+
var $Map = GetIntrinsic('%Map%', true);
|
|
2558
|
+
var $weakMapGet = callBound('WeakMap.prototype.get', true);
|
|
2559
|
+
var $weakMapSet = callBound('WeakMap.prototype.set', true);
|
|
2560
|
+
var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
|
2561
|
+
var $mapGet = callBound('Map.prototype.get', true);
|
|
2562
|
+
var $mapSet = callBound('Map.prototype.set', true);
|
|
2563
|
+
var $mapHas = callBound('Map.prototype.has', true);
|
|
312
2564
|
|
|
313
|
-
|
|
314
|
-
|
|
2565
|
+
var listGetNode = function listGetNode(list, key) {
|
|
2566
|
+
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
|
2567
|
+
if (curr.key === key) {
|
|
2568
|
+
prev.next = curr.next;
|
|
2569
|
+
curr.next = list.next;
|
|
2570
|
+
list.next = curr;
|
|
2571
|
+
return curr;
|
|
315
2572
|
}
|
|
2573
|
+
}
|
|
2574
|
+
};
|
|
316
2575
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
2576
|
+
var listGet = function listGet(objects, key) {
|
|
2577
|
+
var node = listGetNode(objects, key);
|
|
2578
|
+
return node && node.value;
|
|
2579
|
+
};
|
|
320
2580
|
|
|
321
|
-
|
|
2581
|
+
var listSet = function listSet(objects, key, value) {
|
|
2582
|
+
var node = listGetNode(objects, key);
|
|
322
2583
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
2584
|
+
if (node) {
|
|
2585
|
+
node.value = value;
|
|
2586
|
+
} else {
|
|
2587
|
+
objects.next = {
|
|
2588
|
+
key: key,
|
|
2589
|
+
next: objects.next,
|
|
2590
|
+
value: value
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
331
2594
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
tmp[key] = val[key];
|
|
336
|
-
}
|
|
2595
|
+
var listHas = function listHas(objects, key) {
|
|
2596
|
+
return !!listGetNode(objects, key);
|
|
2597
|
+
};
|
|
337
2598
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
2599
|
+
module.exports = function getSideChannel() {
|
|
2600
|
+
var $wm;
|
|
2601
|
+
var $m;
|
|
2602
|
+
var $o;
|
|
2603
|
+
var channel = {
|
|
2604
|
+
assert: function assert(key) {
|
|
2605
|
+
if (!channel.has(key)) {
|
|
2606
|
+
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
get: function get(key) {
|
|
2610
|
+
if ($WeakMap && key && (_typeof(key) === 'object' || typeof key === 'function')) {
|
|
2611
|
+
if ($wm) {
|
|
2612
|
+
return $weakMapGet($wm, key);
|
|
2613
|
+
}
|
|
2614
|
+
} else if ($Map) {
|
|
2615
|
+
if ($m) {
|
|
2616
|
+
return $mapGet($m, key);
|
|
2617
|
+
}
|
|
341
2618
|
} else {
|
|
342
|
-
|
|
2619
|
+
if ($o) {
|
|
2620
|
+
return listGet($o, key);
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
},
|
|
2624
|
+
has: function has(key) {
|
|
2625
|
+
if ($WeakMap && key && (_typeof(key) === 'object' || typeof key === 'function')) {
|
|
2626
|
+
if ($wm) {
|
|
2627
|
+
return $weakMapHas($wm, key);
|
|
2628
|
+
}
|
|
2629
|
+
} else if ($Map) {
|
|
2630
|
+
if ($m) {
|
|
2631
|
+
return $mapHas($m, key);
|
|
2632
|
+
}
|
|
2633
|
+
} else {
|
|
2634
|
+
if ($o) {
|
|
2635
|
+
return listHas($o, key);
|
|
2636
|
+
}
|
|
343
2637
|
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
stack.pop();
|
|
347
|
-
}
|
|
348
|
-
} // wraps replacer function to handle values we couldn't replace
|
|
349
|
-
// and mark them as [Circular]
|
|
350
2638
|
|
|
2639
|
+
return false;
|
|
2640
|
+
},
|
|
2641
|
+
set: function set(key, value) {
|
|
2642
|
+
if ($WeakMap && key && (_typeof(key) === 'object' || typeof key === 'function')) {
|
|
2643
|
+
if (!$wm) {
|
|
2644
|
+
$wm = new $WeakMap();
|
|
2645
|
+
}
|
|
351
2646
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (replacerStack.length > 0) {
|
|
358
|
-
for (var i = 0; i < replacerStack.length; i++) {
|
|
359
|
-
var part = replacerStack[i];
|
|
2647
|
+
$weakMapSet($wm, key, value);
|
|
2648
|
+
} else if ($Map) {
|
|
2649
|
+
if (!$m) {
|
|
2650
|
+
$m = new $Map();
|
|
2651
|
+
}
|
|
360
2652
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
2653
|
+
$mapSet($m, key, value);
|
|
2654
|
+
} else {
|
|
2655
|
+
if (!$o) {
|
|
2656
|
+
$o = {
|
|
2657
|
+
key: {},
|
|
2658
|
+
next: null
|
|
2659
|
+
};
|
|
365
2660
|
}
|
|
2661
|
+
|
|
2662
|
+
listSet($o, key, value);
|
|
366
2663
|
}
|
|
367
2664
|
}
|
|
368
|
-
|
|
369
|
-
return replacer.call(this, key, val);
|
|
370
2665
|
};
|
|
371
|
-
|
|
2666
|
+
return channel;
|
|
2667
|
+
};
|
|
372
2668
|
|
|
373
|
-
},{}],
|
|
2669
|
+
},{"call-bind/callBound":2,"get-intrinsic":8,"object-inspect":12}],20:[function(require,module,exports){
|
|
374
2670
|
"use strict";
|
|
375
2671
|
|
|
376
2672
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
377
2673
|
|
|
378
2674
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
379
2675
|
|
|
380
|
-
function
|
|
381
|
-
|
|
382
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
2676
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
383
2677
|
|
|
384
2678
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
385
2679
|
|
|
2680
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2681
|
+
|
|
2682
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2683
|
+
|
|
386
2684
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
387
2685
|
|
|
388
2686
|
function Agent() {
|
|
389
2687
|
this._defaults = [];
|
|
390
2688
|
}
|
|
391
2689
|
|
|
392
|
-
|
|
393
|
-
|
|
2690
|
+
var _loop = function _loop() {
|
|
2691
|
+
var fn = _arr[_i];
|
|
2692
|
+
|
|
394
2693
|
Agent.prototype[fn] = function () {
|
|
395
2694
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
396
2695
|
args[_key] = arguments[_key];
|
|
@@ -403,53 +2702,60 @@ function Agent() {
|
|
|
403
2702
|
|
|
404
2703
|
return this;
|
|
405
2704
|
};
|
|
406
|
-
}
|
|
2705
|
+
};
|
|
407
2706
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
2707
|
+
for (var _i = 0, _arr = ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']; _i < _arr.length; _i++) {
|
|
2708
|
+
_loop();
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
Agent.prototype._setDefaults = function (request) {
|
|
2712
|
+
var _iterator = _createForOfIteratorHelper(this._defaults),
|
|
2713
|
+
_step;
|
|
2714
|
+
|
|
2715
|
+
try {
|
|
2716
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2717
|
+
var def = _step.value;
|
|
2718
|
+
request[def.fn].apply(request, _toConsumableArray(def.args));
|
|
2719
|
+
}
|
|
2720
|
+
} catch (err) {
|
|
2721
|
+
_iterator.e(err);
|
|
2722
|
+
} finally {
|
|
2723
|
+
_iterator.f();
|
|
2724
|
+
}
|
|
412
2725
|
};
|
|
413
2726
|
|
|
414
2727
|
module.exports = Agent;
|
|
415
2728
|
|
|
416
|
-
},{}],
|
|
2729
|
+
},{}],21:[function(require,module,exports){
|
|
417
2730
|
"use strict";
|
|
418
2731
|
|
|
419
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
2732
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
420
2733
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
*
|
|
424
|
-
* @param {Object} obj
|
|
425
|
-
* @return {Boolean}
|
|
426
|
-
* @api private
|
|
427
|
-
*/
|
|
428
|
-
function isObject(obj) {
|
|
429
|
-
return obj !== null && _typeof(obj) === 'object';
|
|
2734
|
+
function isObject(object) {
|
|
2735
|
+
return object !== null && _typeof(object) === 'object';
|
|
430
2736
|
}
|
|
431
2737
|
|
|
432
2738
|
module.exports = isObject;
|
|
433
2739
|
|
|
434
|
-
},{}],
|
|
2740
|
+
},{}],22:[function(require,module,exports){
|
|
435
2741
|
"use strict";
|
|
436
2742
|
|
|
437
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
2743
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2744
|
+
|
|
2745
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2746
|
+
|
|
2747
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2748
|
+
|
|
2749
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
438
2750
|
|
|
439
|
-
/**
|
|
440
|
-
* Root reference for iframes.
|
|
441
|
-
*/
|
|
442
2751
|
var root;
|
|
443
2752
|
|
|
444
2753
|
if (typeof window !== 'undefined') {
|
|
445
|
-
// Browser window
|
|
446
2754
|
root = window;
|
|
447
2755
|
} else if (typeof self === 'undefined') {
|
|
448
|
-
// Other environments
|
|
449
2756
|
console.warn('Using browser-only version of superagent in non-browser environment');
|
|
450
2757
|
root = void 0;
|
|
451
2758
|
} else {
|
|
452
|
-
// Web Worker
|
|
453
2759
|
root = self;
|
|
454
2760
|
}
|
|
455
2761
|
|
|
@@ -457,6 +2763,8 @@ var Emitter = require('component-emitter');
|
|
|
457
2763
|
|
|
458
2764
|
var safeStringify = require('fast-safe-stringify');
|
|
459
2765
|
|
|
2766
|
+
var qs = require('qs');
|
|
2767
|
+
|
|
460
2768
|
var RequestBase = require('./request-base');
|
|
461
2769
|
|
|
462
2770
|
var isObject = require('./is-object');
|
|
@@ -464,23 +2772,13 @@ var isObject = require('./is-object');
|
|
|
464
2772
|
var ResponseBase = require('./response-base');
|
|
465
2773
|
|
|
466
2774
|
var Agent = require('./agent-base');
|
|
467
|
-
/**
|
|
468
|
-
* Noop.
|
|
469
|
-
*/
|
|
470
|
-
|
|
471
2775
|
|
|
472
2776
|
function noop() {}
|
|
473
|
-
/**
|
|
474
|
-
* Expose `request`.
|
|
475
|
-
*/
|
|
476
|
-
|
|
477
2777
|
|
|
478
2778
|
module.exports = function (method, url) {
|
|
479
|
-
// callback
|
|
480
2779
|
if (typeof url === 'function') {
|
|
481
2780
|
return new exports.Request('GET', method).end(url);
|
|
482
|
-
}
|
|
483
|
-
|
|
2781
|
+
}
|
|
484
2782
|
|
|
485
2783
|
if (arguments.length === 1) {
|
|
486
2784
|
return new exports.Request('GET', method);
|
|
@@ -492,9 +2790,6 @@ module.exports = function (method, url) {
|
|
|
492
2790
|
exports = module.exports;
|
|
493
2791
|
var request = exports;
|
|
494
2792
|
exports.Request = Request;
|
|
495
|
-
/**
|
|
496
|
-
* Determine XHR.
|
|
497
|
-
*/
|
|
498
2793
|
|
|
499
2794
|
request.getXHR = function () {
|
|
500
2795
|
if (root.XMLHttpRequest && (!root.location || root.location.protocol !== 'file:' || !root.ActiveXObject)) {
|
|
@@ -519,114 +2814,78 @@ request.getXHR = function () {
|
|
|
519
2814
|
|
|
520
2815
|
throw new Error('Browser-only version of superagent could not find XHR');
|
|
521
2816
|
};
|
|
522
|
-
/**
|
|
523
|
-
* Removes leading and trailing whitespace, added to support IE.
|
|
524
|
-
*
|
|
525
|
-
* @param {String} s
|
|
526
|
-
* @return {String}
|
|
527
|
-
* @api private
|
|
528
|
-
*/
|
|
529
|
-
|
|
530
2817
|
|
|
531
2818
|
var trim = ''.trim ? function (s) {
|
|
532
2819
|
return s.trim();
|
|
533
2820
|
} : function (s) {
|
|
534
2821
|
return s.replace(/(^\s*|\s*$)/g, '');
|
|
535
2822
|
};
|
|
536
|
-
/**
|
|
537
|
-
* Serialize the given `obj`.
|
|
538
|
-
*
|
|
539
|
-
* @param {Object} obj
|
|
540
|
-
* @return {String}
|
|
541
|
-
* @api private
|
|
542
|
-
*/
|
|
543
2823
|
|
|
544
|
-
function serialize(
|
|
545
|
-
if (!isObject(
|
|
2824
|
+
function serialize(object) {
|
|
2825
|
+
if (!isObject(object)) return object;
|
|
546
2826
|
var pairs = [];
|
|
547
2827
|
|
|
548
|
-
for (var key in
|
|
549
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
2828
|
+
for (var key in object) {
|
|
2829
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) pushEncodedKeyValuePair(pairs, key, object[key]);
|
|
550
2830
|
}
|
|
551
2831
|
|
|
552
2832
|
return pairs.join('&');
|
|
553
2833
|
}
|
|
554
|
-
/**
|
|
555
|
-
* Helps 'serialize' with serializing arrays.
|
|
556
|
-
* Mutates the pairs array.
|
|
557
|
-
*
|
|
558
|
-
* @param {Array} pairs
|
|
559
|
-
* @param {String} key
|
|
560
|
-
* @param {Mixed} val
|
|
561
|
-
*/
|
|
562
2834
|
|
|
2835
|
+
function pushEncodedKeyValuePair(pairs, key, value) {
|
|
2836
|
+
if (value === undefined) return;
|
|
563
2837
|
|
|
564
|
-
|
|
565
|
-
if (val === undefined) return;
|
|
566
|
-
|
|
567
|
-
if (val === null) {
|
|
2838
|
+
if (value === null) {
|
|
568
2839
|
pairs.push(encodeURI(key));
|
|
569
2840
|
return;
|
|
570
2841
|
}
|
|
571
2842
|
|
|
572
|
-
if (Array.isArray(
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
2843
|
+
if (Array.isArray(value)) {
|
|
2844
|
+
var _iterator = _createForOfIteratorHelper(value),
|
|
2845
|
+
_step;
|
|
2846
|
+
|
|
2847
|
+
try {
|
|
2848
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2849
|
+
var v = _step.value;
|
|
2850
|
+
pushEncodedKeyValuePair(pairs, key, v);
|
|
2851
|
+
}
|
|
2852
|
+
} catch (err) {
|
|
2853
|
+
_iterator.e(err);
|
|
2854
|
+
} finally {
|
|
2855
|
+
_iterator.f();
|
|
2856
|
+
}
|
|
2857
|
+
} else if (isObject(value)) {
|
|
2858
|
+
for (var subkey in value) {
|
|
2859
|
+
if (Object.prototype.hasOwnProperty.call(value, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), value[subkey]);
|
|
579
2860
|
}
|
|
580
2861
|
} else {
|
|
581
|
-
pairs.push(encodeURI(key) + '=' + encodeURIComponent(
|
|
2862
|
+
pairs.push(encodeURI(key) + '=' + encodeURIComponent(value));
|
|
582
2863
|
}
|
|
583
2864
|
}
|
|
584
|
-
/**
|
|
585
|
-
* Expose serialization method.
|
|
586
|
-
*/
|
|
587
|
-
|
|
588
2865
|
|
|
589
2866
|
request.serializeObject = serialize;
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
* @return {Object}
|
|
595
|
-
* @api private
|
|
596
|
-
*/
|
|
597
|
-
|
|
598
|
-
function parseString(str) {
|
|
599
|
-
var obj = {};
|
|
600
|
-
var pairs = str.split('&');
|
|
2867
|
+
|
|
2868
|
+
function parseString(string_) {
|
|
2869
|
+
var object = {};
|
|
2870
|
+
var pairs = string_.split('&');
|
|
601
2871
|
var pair;
|
|
602
2872
|
var pos;
|
|
603
2873
|
|
|
604
|
-
for (var i = 0,
|
|
2874
|
+
for (var i = 0, length_ = pairs.length; i < length_; ++i) {
|
|
605
2875
|
pair = pairs[i];
|
|
606
2876
|
pos = pair.indexOf('=');
|
|
607
2877
|
|
|
608
2878
|
if (pos === -1) {
|
|
609
|
-
|
|
2879
|
+
object[decodeURIComponent(pair)] = '';
|
|
610
2880
|
} else {
|
|
611
|
-
|
|
2881
|
+
object[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1));
|
|
612
2882
|
}
|
|
613
2883
|
}
|
|
614
2884
|
|
|
615
|
-
return
|
|
2885
|
+
return object;
|
|
616
2886
|
}
|
|
617
|
-
/**
|
|
618
|
-
* Expose parser.
|
|
619
|
-
*/
|
|
620
|
-
|
|
621
2887
|
|
|
622
2888
|
request.parseString = parseString;
|
|
623
|
-
/**
|
|
624
|
-
* Default MIME type map.
|
|
625
|
-
*
|
|
626
|
-
* superagent.types.xml = 'application/xml';
|
|
627
|
-
*
|
|
628
|
-
*/
|
|
629
|
-
|
|
630
2889
|
request.types = {
|
|
631
2890
|
html: 'text/html',
|
|
632
2891
|
json: 'application/json',
|
|
@@ -635,133 +2894,49 @@ request.types = {
|
|
|
635
2894
|
form: 'application/x-www-form-urlencoded',
|
|
636
2895
|
'form-data': 'application/x-www-form-urlencoded'
|
|
637
2896
|
};
|
|
638
|
-
/**
|
|
639
|
-
* Default serialization map.
|
|
640
|
-
*
|
|
641
|
-
* superagent.serialize['application/xml'] = function(obj){
|
|
642
|
-
* return 'generated xml here';
|
|
643
|
-
* };
|
|
644
|
-
*
|
|
645
|
-
*/
|
|
646
|
-
|
|
647
2897
|
request.serialize = {
|
|
648
|
-
'application/x-www-form-urlencoded':
|
|
2898
|
+
'application/x-www-form-urlencoded': qs.stringify,
|
|
649
2899
|
'application/json': safeStringify
|
|
650
2900
|
};
|
|
651
|
-
/**
|
|
652
|
-
* Default parsers.
|
|
653
|
-
*
|
|
654
|
-
* superagent.parse['application/xml'] = function(str){
|
|
655
|
-
* return { object parsed from str };
|
|
656
|
-
* };
|
|
657
|
-
*
|
|
658
|
-
*/
|
|
659
|
-
|
|
660
2901
|
request.parse = {
|
|
661
2902
|
'application/x-www-form-urlencoded': parseString,
|
|
662
2903
|
'application/json': JSON.parse
|
|
663
2904
|
};
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
*
|
|
668
|
-
* @param {String} str
|
|
669
|
-
* @return {Object}
|
|
670
|
-
* @api private
|
|
671
|
-
*/
|
|
672
|
-
|
|
673
|
-
function parseHeader(str) {
|
|
674
|
-
var lines = str.split(/\r?\n/);
|
|
2905
|
+
|
|
2906
|
+
function parseHeader(string_) {
|
|
2907
|
+
var lines = string_.split(/\r?\n/);
|
|
675
2908
|
var fields = {};
|
|
676
2909
|
var index;
|
|
677
2910
|
var line;
|
|
678
2911
|
var field;
|
|
679
|
-
var
|
|
2912
|
+
var value;
|
|
680
2913
|
|
|
681
|
-
for (var i = 0,
|
|
2914
|
+
for (var i = 0, length_ = lines.length; i < length_; ++i) {
|
|
682
2915
|
line = lines[i];
|
|
683
2916
|
index = line.indexOf(':');
|
|
684
2917
|
|
|
685
2918
|
if (index === -1) {
|
|
686
|
-
// could be empty line, just skip it
|
|
687
2919
|
continue;
|
|
688
2920
|
}
|
|
689
2921
|
|
|
690
2922
|
field = line.slice(0, index).toLowerCase();
|
|
691
|
-
|
|
692
|
-
fields[field] =
|
|
2923
|
+
value = trim(line.slice(index + 1));
|
|
2924
|
+
fields[field] = value;
|
|
693
2925
|
}
|
|
694
2926
|
|
|
695
2927
|
return fields;
|
|
696
2928
|
}
|
|
697
|
-
/**
|
|
698
|
-
* Check if `mime` is json or has +json structured syntax suffix.
|
|
699
|
-
*
|
|
700
|
-
* @param {String} mime
|
|
701
|
-
* @return {Boolean}
|
|
702
|
-
* @api private
|
|
703
|
-
*/
|
|
704
|
-
|
|
705
2929
|
|
|
706
2930
|
function isJSON(mime) {
|
|
707
|
-
// should match /json or +json
|
|
708
|
-
// but not /json-seq
|
|
709
2931
|
return /[/+]json($|[^-\w])/i.test(mime);
|
|
710
2932
|
}
|
|
711
|
-
/**
|
|
712
|
-
* Initialize a new `Response` with the given `xhr`.
|
|
713
|
-
*
|
|
714
|
-
* - set flags (.ok, .error, etc)
|
|
715
|
-
* - parse header
|
|
716
|
-
*
|
|
717
|
-
* Examples:
|
|
718
|
-
*
|
|
719
|
-
* Aliasing `superagent` as `request` is nice:
|
|
720
|
-
*
|
|
721
|
-
* request = superagent;
|
|
722
|
-
*
|
|
723
|
-
* We can use the promise-like API, or pass callbacks:
|
|
724
|
-
*
|
|
725
|
-
* request.get('/').end(function(res){});
|
|
726
|
-
* request.get('/', function(res){});
|
|
727
|
-
*
|
|
728
|
-
* Sending data can be chained:
|
|
729
|
-
*
|
|
730
|
-
* request
|
|
731
|
-
* .post('/user')
|
|
732
|
-
* .send({ name: 'tj' })
|
|
733
|
-
* .end(function(res){});
|
|
734
|
-
*
|
|
735
|
-
* Or passed to `.send()`:
|
|
736
|
-
*
|
|
737
|
-
* request
|
|
738
|
-
* .post('/user')
|
|
739
|
-
* .send({ name: 'tj' }, function(res){});
|
|
740
|
-
*
|
|
741
|
-
* Or passed to `.post()`:
|
|
742
|
-
*
|
|
743
|
-
* request
|
|
744
|
-
* .post('/user', { name: 'tj' })
|
|
745
|
-
* .end(function(res){});
|
|
746
|
-
*
|
|
747
|
-
* Or further reduced to a single call for simple cases:
|
|
748
|
-
*
|
|
749
|
-
* request
|
|
750
|
-
* .post('/user', { name: 'tj' }, function(res){});
|
|
751
|
-
*
|
|
752
|
-
* @param {XMLHTTPRequest} xhr
|
|
753
|
-
* @param {Object} options
|
|
754
|
-
* @api private
|
|
755
|
-
*/
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
function Response(req) {
|
|
759
|
-
this.req = req;
|
|
760
|
-
this.xhr = this.req.xhr; // responseText is accessible only if responseType is '' or 'text' and on older browsers
|
|
761
2933
|
|
|
2934
|
+
function Response(request_) {
|
|
2935
|
+
this.req = request_;
|
|
2936
|
+
this.xhr = this.req.xhr;
|
|
762
2937
|
this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;
|
|
763
2938
|
this.statusText = this.req.xhr.statusText;
|
|
764
|
-
var status = this.xhr.status;
|
|
2939
|
+
var status = this.xhr.status;
|
|
765
2940
|
|
|
766
2941
|
if (status === 1223) {
|
|
767
2942
|
status = 204;
|
|
@@ -770,212 +2945,117 @@ function Response(req) {
|
|
|
770
2945
|
this._setStatusProperties(status);
|
|
771
2946
|
|
|
772
2947
|
this.headers = parseHeader(this.xhr.getAllResponseHeaders());
|
|
773
|
-
this.header = this.headers;
|
|
774
|
-
// getResponseHeader still works. so we get content-type even if getting
|
|
775
|
-
// other headers fails.
|
|
776
|
-
|
|
2948
|
+
this.header = this.headers;
|
|
777
2949
|
this.header['content-type'] = this.xhr.getResponseHeader('content-type');
|
|
778
2950
|
|
|
779
2951
|
this._setHeaderProperties(this.header);
|
|
780
2952
|
|
|
781
|
-
if (this.text === null &&
|
|
2953
|
+
if (this.text === null && request_._responseType) {
|
|
782
2954
|
this.body = this.xhr.response;
|
|
783
2955
|
} else {
|
|
784
2956
|
this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response);
|
|
785
2957
|
}
|
|
786
|
-
}
|
|
787
|
-
|
|
2958
|
+
}
|
|
788
2959
|
|
|
789
2960
|
ResponseBase(Response.prototype);
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
*
|
|
793
|
-
* Used for auto-parsing of bodies. Parsers
|
|
794
|
-
* are defined on the `superagent.parse` object.
|
|
795
|
-
*
|
|
796
|
-
* @param {String} str
|
|
797
|
-
* @return {Mixed}
|
|
798
|
-
* @api private
|
|
799
|
-
*/
|
|
800
|
-
|
|
801
|
-
Response.prototype._parseBody = function (str) {
|
|
2961
|
+
|
|
2962
|
+
Response.prototype._parseBody = function (string_) {
|
|
802
2963
|
var parse = request.parse[this.type];
|
|
803
2964
|
|
|
804
2965
|
if (this.req._parser) {
|
|
805
|
-
return this.req._parser(this,
|
|
2966
|
+
return this.req._parser(this, string_);
|
|
806
2967
|
}
|
|
807
2968
|
|
|
808
2969
|
if (!parse && isJSON(this.type)) {
|
|
809
2970
|
parse = request.parse['application/json'];
|
|
810
2971
|
}
|
|
811
2972
|
|
|
812
|
-
return parse &&
|
|
2973
|
+
return parse && string_ && (string_.length > 0 || string_ instanceof Object) ? parse(string_) : null;
|
|
813
2974
|
};
|
|
814
|
-
/**
|
|
815
|
-
* Return an `Error` representative of this response.
|
|
816
|
-
*
|
|
817
|
-
* @return {Error}
|
|
818
|
-
* @api public
|
|
819
|
-
*/
|
|
820
|
-
|
|
821
2975
|
|
|
822
2976
|
Response.prototype.toError = function () {
|
|
823
2977
|
var req = this.req;
|
|
824
2978
|
var method = req.method;
|
|
825
2979
|
var url = req.url;
|
|
826
|
-
var
|
|
827
|
-
var
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
return
|
|
2980
|
+
var message = "cannot ".concat(method, " ").concat(url, " (").concat(this.status, ")");
|
|
2981
|
+
var error = new Error(message);
|
|
2982
|
+
error.status = this.status;
|
|
2983
|
+
error.method = method;
|
|
2984
|
+
error.url = url;
|
|
2985
|
+
return error;
|
|
832
2986
|
};
|
|
833
|
-
/**
|
|
834
|
-
* Expose `Response`.
|
|
835
|
-
*/
|
|
836
|
-
|
|
837
2987
|
|
|
838
2988
|
request.Response = Response;
|
|
839
|
-
/**
|
|
840
|
-
* Initialize a new `Request` with the given `method` and `url`.
|
|
841
|
-
*
|
|
842
|
-
* @param {String} method
|
|
843
|
-
* @param {String} url
|
|
844
|
-
* @api public
|
|
845
|
-
*/
|
|
846
2989
|
|
|
847
2990
|
function Request(method, url) {
|
|
848
2991
|
var self = this;
|
|
849
2992
|
this._query = this._query || [];
|
|
850
2993
|
this.method = method;
|
|
851
2994
|
this.url = url;
|
|
852
|
-
this.header = {};
|
|
853
|
-
|
|
854
|
-
this._header = {}; // coerces header names to lowercase
|
|
855
|
-
|
|
2995
|
+
this.header = {};
|
|
2996
|
+
this._header = {};
|
|
856
2997
|
this.on('end', function () {
|
|
857
|
-
var
|
|
2998
|
+
var error = null;
|
|
858
2999
|
var res = null;
|
|
859
3000
|
|
|
860
3001
|
try {
|
|
861
3002
|
res = new Response(self);
|
|
862
|
-
} catch (
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
3003
|
+
} catch (error_) {
|
|
3004
|
+
error = new Error('Parser is unable to parse the response');
|
|
3005
|
+
error.parse = true;
|
|
3006
|
+
error.original = error_;
|
|
866
3007
|
|
|
867
3008
|
if (self.xhr) {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
err.status = self.xhr.status ? self.xhr.status : null;
|
|
872
|
-
err.statusCode = err.status; // backwards-compat only
|
|
3009
|
+
error.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response;
|
|
3010
|
+
error.status = self.xhr.status ? self.xhr.status : null;
|
|
3011
|
+
error.statusCode = error.status;
|
|
873
3012
|
} else {
|
|
874
|
-
|
|
875
|
-
|
|
3013
|
+
error.rawResponse = null;
|
|
3014
|
+
error.status = null;
|
|
876
3015
|
}
|
|
877
3016
|
|
|
878
|
-
return self.callback(
|
|
3017
|
+
return self.callback(error);
|
|
879
3018
|
}
|
|
880
3019
|
|
|
881
3020
|
self.emit('response', res);
|
|
882
|
-
var
|
|
3021
|
+
var new_error;
|
|
883
3022
|
|
|
884
3023
|
try {
|
|
885
3024
|
if (!self._isResponseOK(res)) {
|
|
886
|
-
|
|
3025
|
+
new_error = new Error(res.statusText || res.text || 'Unsuccessful HTTP response');
|
|
887
3026
|
}
|
|
888
|
-
} catch (
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
|
|
3027
|
+
} catch (err) {
|
|
3028
|
+
new_error = err;
|
|
3029
|
+
}
|
|
892
3030
|
|
|
893
|
-
if (
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
self.callback(
|
|
3031
|
+
if (new_error) {
|
|
3032
|
+
new_error.original = error;
|
|
3033
|
+
new_error.response = res;
|
|
3034
|
+
new_error.status = res.status;
|
|
3035
|
+
self.callback(new_error, res);
|
|
898
3036
|
} else {
|
|
899
3037
|
self.callback(null, res);
|
|
900
3038
|
}
|
|
901
3039
|
});
|
|
902
3040
|
}
|
|
903
|
-
/**
|
|
904
|
-
* Mixin `Emitter` and `RequestBase`.
|
|
905
|
-
*/
|
|
906
|
-
// eslint-disable-next-line new-cap
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
Emitter(Request.prototype); // eslint-disable-next-line new-cap
|
|
910
3041
|
|
|
3042
|
+
Emitter(Request.prototype);
|
|
911
3043
|
RequestBase(Request.prototype);
|
|
912
|
-
/**
|
|
913
|
-
* Set Content-Type to `type`, mapping values from `request.types`.
|
|
914
|
-
*
|
|
915
|
-
* Examples:
|
|
916
|
-
*
|
|
917
|
-
* superagent.types.xml = 'application/xml';
|
|
918
|
-
*
|
|
919
|
-
* request.post('/')
|
|
920
|
-
* .type('xml')
|
|
921
|
-
* .send(xmlstring)
|
|
922
|
-
* .end(callback);
|
|
923
|
-
*
|
|
924
|
-
* request.post('/')
|
|
925
|
-
* .type('application/xml')
|
|
926
|
-
* .send(xmlstring)
|
|
927
|
-
* .end(callback);
|
|
928
|
-
*
|
|
929
|
-
* @param {String} type
|
|
930
|
-
* @return {Request} for chaining
|
|
931
|
-
* @api public
|
|
932
|
-
*/
|
|
933
3044
|
|
|
934
3045
|
Request.prototype.type = function (type) {
|
|
935
3046
|
this.set('Content-Type', request.types[type] || type);
|
|
936
3047
|
return this;
|
|
937
3048
|
};
|
|
938
|
-
/**
|
|
939
|
-
* Set Accept to `type`, mapping values from `request.types`.
|
|
940
|
-
*
|
|
941
|
-
* Examples:
|
|
942
|
-
*
|
|
943
|
-
* superagent.types.json = 'application/json';
|
|
944
|
-
*
|
|
945
|
-
* request.get('/agent')
|
|
946
|
-
* .accept('json')
|
|
947
|
-
* .end(callback);
|
|
948
|
-
*
|
|
949
|
-
* request.get('/agent')
|
|
950
|
-
* .accept('application/json')
|
|
951
|
-
* .end(callback);
|
|
952
|
-
*
|
|
953
|
-
* @param {String} accept
|
|
954
|
-
* @return {Request} for chaining
|
|
955
|
-
* @api public
|
|
956
|
-
*/
|
|
957
|
-
|
|
958
3049
|
|
|
959
3050
|
Request.prototype.accept = function (type) {
|
|
960
3051
|
this.set('Accept', request.types[type] || type);
|
|
961
3052
|
return this;
|
|
962
3053
|
};
|
|
963
|
-
/**
|
|
964
|
-
* Set Authorization field value with `user` and `pass`.
|
|
965
|
-
*
|
|
966
|
-
* @param {String} user
|
|
967
|
-
* @param {String} [pass] optional in case of using 'bearer' as type
|
|
968
|
-
* @param {Object} options with 'type' property 'auto', 'basic' or 'bearer' (default 'basic')
|
|
969
|
-
* @return {Request} for chaining
|
|
970
|
-
* @api public
|
|
971
|
-
*/
|
|
972
|
-
|
|
973
3054
|
|
|
974
3055
|
Request.prototype.auth = function (user, pass, options) {
|
|
975
3056
|
if (arguments.length === 1) pass = '';
|
|
976
3057
|
|
|
977
3058
|
if (_typeof(pass) === 'object' && pass !== null) {
|
|
978
|
-
// pass is optional and can be replaced with options
|
|
979
3059
|
options = pass;
|
|
980
3060
|
pass = '';
|
|
981
3061
|
}
|
|
@@ -996,43 +3076,12 @@ Request.prototype.auth = function (user, pass, options) {
|
|
|
996
3076
|
|
|
997
3077
|
return this._auth(user, pass, options, encoder);
|
|
998
3078
|
};
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
*
|
|
1004
|
-
* request.get('/shoes')
|
|
1005
|
-
* .query('size=10')
|
|
1006
|
-
* .query({ color: 'blue' })
|
|
1007
|
-
*
|
|
1008
|
-
* @param {Object|String} val
|
|
1009
|
-
* @return {Request} for chaining
|
|
1010
|
-
* @api public
|
|
1011
|
-
*/
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
Request.prototype.query = function (val) {
|
|
1015
|
-
if (typeof val !== 'string') val = serialize(val);
|
|
1016
|
-
if (val) this._query.push(val);
|
|
3079
|
+
|
|
3080
|
+
Request.prototype.query = function (value) {
|
|
3081
|
+
if (typeof value !== 'string') value = serialize(value);
|
|
3082
|
+
if (value) this._query.push(value);
|
|
1017
3083
|
return this;
|
|
1018
3084
|
};
|
|
1019
|
-
/**
|
|
1020
|
-
* Queue the given `file` as an attachment to the specified `field`,
|
|
1021
|
-
* with optional `options` (or filename).
|
|
1022
|
-
*
|
|
1023
|
-
* ``` js
|
|
1024
|
-
* request.post('/upload')
|
|
1025
|
-
* .attach('content', new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
|
|
1026
|
-
* .end(callback);
|
|
1027
|
-
* ```
|
|
1028
|
-
*
|
|
1029
|
-
* @param {String} field
|
|
1030
|
-
* @param {Blob|File} file
|
|
1031
|
-
* @param {String|Object} options
|
|
1032
|
-
* @return {Request} for chaining
|
|
1033
|
-
* @api public
|
|
1034
|
-
*/
|
|
1035
|
-
|
|
1036
3085
|
|
|
1037
3086
|
Request.prototype.attach = function (field, file, options) {
|
|
1038
3087
|
if (file) {
|
|
@@ -1053,47 +3102,31 @@ Request.prototype._getFormData = function () {
|
|
|
1053
3102
|
|
|
1054
3103
|
return this._formData;
|
|
1055
3104
|
};
|
|
1056
|
-
/**
|
|
1057
|
-
* Invoke the callback with `err` and `res`
|
|
1058
|
-
* and handle arity check.
|
|
1059
|
-
*
|
|
1060
|
-
* @param {Error} err
|
|
1061
|
-
* @param {Response} res
|
|
1062
|
-
* @api private
|
|
1063
|
-
*/
|
|
1064
|
-
|
|
1065
3105
|
|
|
1066
|
-
Request.prototype.callback = function (
|
|
1067
|
-
if (this._shouldRetry(
|
|
3106
|
+
Request.prototype.callback = function (error, res) {
|
|
3107
|
+
if (this._shouldRetry(error, res)) {
|
|
1068
3108
|
return this._retry();
|
|
1069
3109
|
}
|
|
1070
3110
|
|
|
1071
3111
|
var fn = this._callback;
|
|
1072
3112
|
this.clearTimeout();
|
|
1073
3113
|
|
|
1074
|
-
if (
|
|
1075
|
-
if (this._maxRetries)
|
|
1076
|
-
this.emit('error',
|
|
3114
|
+
if (error) {
|
|
3115
|
+
if (this._maxRetries) error.retries = this._retries - 1;
|
|
3116
|
+
this.emit('error', error);
|
|
1077
3117
|
}
|
|
1078
3118
|
|
|
1079
|
-
fn(
|
|
3119
|
+
fn(error, res);
|
|
1080
3120
|
};
|
|
1081
|
-
/**
|
|
1082
|
-
* Invoke callback with x-domain error.
|
|
1083
|
-
*
|
|
1084
|
-
* @api private
|
|
1085
|
-
*/
|
|
1086
|
-
|
|
1087
3121
|
|
|
1088
3122
|
Request.prototype.crossDomainError = function () {
|
|
1089
|
-
var
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
this.callback(
|
|
1095
|
-
};
|
|
1096
|
-
|
|
3123
|
+
var error = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');
|
|
3124
|
+
error.crossDomain = true;
|
|
3125
|
+
error.status = this.status;
|
|
3126
|
+
error.method = this.method;
|
|
3127
|
+
error.url = this.url;
|
|
3128
|
+
this.callback(error);
|
|
3129
|
+
};
|
|
1097
3130
|
|
|
1098
3131
|
Request.prototype.agent = function () {
|
|
1099
3132
|
console.warn('This is not supported in browser version of superagent');
|
|
@@ -1101,44 +3134,25 @@ Request.prototype.agent = function () {
|
|
|
1101
3134
|
};
|
|
1102
3135
|
|
|
1103
3136
|
Request.prototype.ca = Request.prototype.agent;
|
|
1104
|
-
Request.prototype.buffer = Request.prototype.ca;
|
|
3137
|
+
Request.prototype.buffer = Request.prototype.ca;
|
|
1105
3138
|
|
|
1106
3139
|
Request.prototype.write = function () {
|
|
1107
3140
|
throw new Error('Streaming is not supported in browser version of superagent');
|
|
1108
3141
|
};
|
|
1109
3142
|
|
|
1110
3143
|
Request.prototype.pipe = Request.prototype.write;
|
|
1111
|
-
/**
|
|
1112
|
-
* Check if `obj` is a host object,
|
|
1113
|
-
* we don't want to serialize these :)
|
|
1114
|
-
*
|
|
1115
|
-
* @param {Object} obj host object
|
|
1116
|
-
* @return {Boolean} is a host object
|
|
1117
|
-
* @api private
|
|
1118
|
-
*/
|
|
1119
|
-
|
|
1120
|
-
Request.prototype._isHost = function (obj) {
|
|
1121
|
-
// Native objects stringify to [object File], [object Blob], [object FormData], etc.
|
|
1122
|
-
return obj && _typeof(obj) === 'object' && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]';
|
|
1123
|
-
};
|
|
1124
|
-
/**
|
|
1125
|
-
* Initiate request, invoking callback `fn(res)`
|
|
1126
|
-
* with an instanceof `Response`.
|
|
1127
|
-
*
|
|
1128
|
-
* @param {Function} fn
|
|
1129
|
-
* @return {Request} for chaining
|
|
1130
|
-
* @api public
|
|
1131
|
-
*/
|
|
1132
3144
|
|
|
3145
|
+
Request.prototype._isHost = function (object) {
|
|
3146
|
+
return object && _typeof(object) === 'object' && !Array.isArray(object) && Object.prototype.toString.call(object) !== '[object Object]';
|
|
3147
|
+
};
|
|
1133
3148
|
|
|
1134
3149
|
Request.prototype.end = function (fn) {
|
|
1135
3150
|
if (this._endCalled) {
|
|
1136
3151
|
console.warn('Warning: .end() was called twice. This is not supported in superagent');
|
|
1137
3152
|
}
|
|
1138
3153
|
|
|
1139
|
-
this._endCalled = true;
|
|
1140
|
-
|
|
1141
|
-
this._callback = fn || noop; // querystring
|
|
3154
|
+
this._endCalled = true;
|
|
3155
|
+
this._callback = fn || noop;
|
|
1142
3156
|
|
|
1143
3157
|
this._finalizeQueryString();
|
|
1144
3158
|
|
|
@@ -1146,15 +3160,14 @@ Request.prototype.end = function (fn) {
|
|
|
1146
3160
|
};
|
|
1147
3161
|
|
|
1148
3162
|
Request.prototype._setUploadTimeout = function () {
|
|
1149
|
-
var self = this;
|
|
3163
|
+
var self = this;
|
|
1150
3164
|
|
|
1151
3165
|
if (this._uploadTimeout && !this._uploadTimeoutTimer) {
|
|
1152
3166
|
this._uploadTimeoutTimer = setTimeout(function () {
|
|
1153
3167
|
self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');
|
|
1154
3168
|
}, this._uploadTimeout);
|
|
1155
3169
|
}
|
|
1156
|
-
};
|
|
1157
|
-
|
|
3170
|
+
};
|
|
1158
3171
|
|
|
1159
3172
|
Request.prototype._end = function () {
|
|
1160
3173
|
if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));
|
|
@@ -1163,10 +3176,9 @@ Request.prototype._end = function () {
|
|
|
1163
3176
|
var xhr = this.xhr;
|
|
1164
3177
|
var data = this._formData || this._data;
|
|
1165
3178
|
|
|
1166
|
-
this._setTimeouts();
|
|
3179
|
+
this._setTimeouts();
|
|
1167
3180
|
|
|
1168
|
-
|
|
1169
|
-
xhr.onreadystatechange = function () {
|
|
3181
|
+
xhr.addEventListener('readystatechange', function () {
|
|
1170
3182
|
var readyState = xhr.readyState;
|
|
1171
3183
|
|
|
1172
3184
|
if (readyState >= 2 && self._responseTimeoutTimer) {
|
|
@@ -1175,9 +3187,7 @@ Request.prototype._end = function () {
|
|
|
1175
3187
|
|
|
1176
3188
|
if (readyState !== 4) {
|
|
1177
3189
|
return;
|
|
1178
|
-
}
|
|
1179
|
-
// result in the error "Could not complete the operation due to error c00c023f"
|
|
1180
|
-
|
|
3190
|
+
}
|
|
1181
3191
|
|
|
1182
3192
|
var status;
|
|
1183
3193
|
|
|
@@ -1193,8 +3203,7 @@ Request.prototype._end = function () {
|
|
|
1193
3203
|
}
|
|
1194
3204
|
|
|
1195
3205
|
self.emit('end');
|
|
1196
|
-
};
|
|
1197
|
-
|
|
3206
|
+
});
|
|
1198
3207
|
|
|
1199
3208
|
var handleProgress = function handleProgress(direction, e) {
|
|
1200
3209
|
if (e.total > 0) {
|
|
@@ -1216,16 +3225,12 @@ Request.prototype._end = function () {
|
|
|
1216
3225
|
if (xhr.upload) {
|
|
1217
3226
|
xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
|
|
1218
3227
|
}
|
|
1219
|
-
} catch (_unused6) {
|
|
1220
|
-
// Reported here:
|
|
1221
|
-
// https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context
|
|
1222
|
-
}
|
|
3228
|
+
} catch (_unused6) {}
|
|
1223
3229
|
}
|
|
1224
3230
|
|
|
1225
3231
|
if (xhr.upload) {
|
|
1226
3232
|
this._setUploadTimeout();
|
|
1227
|
-
}
|
|
1228
|
-
|
|
3233
|
+
}
|
|
1229
3234
|
|
|
1230
3235
|
try {
|
|
1231
3236
|
if (this.username && this.password) {
|
|
@@ -1234,15 +3239,12 @@ Request.prototype._end = function () {
|
|
|
1234
3239
|
xhr.open(this.method, this.url, true);
|
|
1235
3240
|
}
|
|
1236
3241
|
} catch (err) {
|
|
1237
|
-
// see #1149
|
|
1238
3242
|
return this.callback(err);
|
|
1239
|
-
}
|
|
1240
|
-
|
|
3243
|
+
}
|
|
1241
3244
|
|
|
1242
|
-
if (this._withCredentials) xhr.withCredentials = true;
|
|
3245
|
+
if (this._withCredentials) xhr.withCredentials = true;
|
|
1243
3246
|
|
|
1244
3247
|
if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
|
|
1245
|
-
// serialize stuff
|
|
1246
3248
|
var contentType = this._header['content-type'];
|
|
1247
3249
|
|
|
1248
3250
|
var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
@@ -1252,8 +3254,7 @@ Request.prototype._end = function () {
|
|
|
1252
3254
|
}
|
|
1253
3255
|
|
|
1254
3256
|
if (_serialize) data = _serialize(data);
|
|
1255
|
-
}
|
|
1256
|
-
|
|
3257
|
+
}
|
|
1257
3258
|
|
|
1258
3259
|
for (var field in this.header) {
|
|
1259
3260
|
if (this.header[field] === null) continue;
|
|
@@ -1262,12 +3263,9 @@ Request.prototype._end = function () {
|
|
|
1262
3263
|
|
|
1263
3264
|
if (this._responseType) {
|
|
1264
3265
|
xhr.responseType = this._responseType;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
this.emit('request', this); // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing)
|
|
1269
|
-
// We need null here if data is undefined
|
|
3266
|
+
}
|
|
1270
3267
|
|
|
3268
|
+
this.emit('request', this);
|
|
1271
3269
|
xhr.send(typeof data === 'undefined' ? null : data);
|
|
1272
3270
|
};
|
|
1273
3271
|
|
|
@@ -1275,215 +3273,137 @@ request.agent = function () {
|
|
|
1275
3273
|
return new Agent();
|
|
1276
3274
|
};
|
|
1277
3275
|
|
|
1278
|
-
|
|
3276
|
+
var _loop = function _loop() {
|
|
3277
|
+
var method = _arr[_i];
|
|
3278
|
+
|
|
1279
3279
|
Agent.prototype[method.toLowerCase()] = function (url, fn) {
|
|
1280
|
-
var
|
|
3280
|
+
var request_ = new request.Request(method, url);
|
|
1281
3281
|
|
|
1282
|
-
this._setDefaults(
|
|
3282
|
+
this._setDefaults(request_);
|
|
1283
3283
|
|
|
1284
3284
|
if (fn) {
|
|
1285
|
-
|
|
3285
|
+
request_.end(fn);
|
|
1286
3286
|
}
|
|
1287
3287
|
|
|
1288
|
-
return
|
|
3288
|
+
return request_;
|
|
1289
3289
|
};
|
|
1290
|
-
}
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3292
|
+
for (var _i = 0, _arr = ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']; _i < _arr.length; _i++) {
|
|
3293
|
+
_loop();
|
|
3294
|
+
}
|
|
3295
|
+
|
|
1291
3296
|
Agent.prototype.del = Agent.prototype.delete;
|
|
1292
|
-
/**
|
|
1293
|
-
* GET `url` with optional callback `fn(res)`.
|
|
1294
|
-
*
|
|
1295
|
-
* @param {String} url
|
|
1296
|
-
* @param {Mixed|Function} [data] or fn
|
|
1297
|
-
* @param {Function} [fn]
|
|
1298
|
-
* @return {Request}
|
|
1299
|
-
* @api public
|
|
1300
|
-
*/
|
|
1301
3297
|
|
|
1302
3298
|
request.get = function (url, data, fn) {
|
|
1303
|
-
var
|
|
3299
|
+
var request_ = request('GET', url);
|
|
1304
3300
|
|
|
1305
3301
|
if (typeof data === 'function') {
|
|
1306
3302
|
fn = data;
|
|
1307
3303
|
data = null;
|
|
1308
3304
|
}
|
|
1309
3305
|
|
|
1310
|
-
if (data)
|
|
1311
|
-
if (fn)
|
|
1312
|
-
return
|
|
3306
|
+
if (data) request_.query(data);
|
|
3307
|
+
if (fn) request_.end(fn);
|
|
3308
|
+
return request_;
|
|
1313
3309
|
};
|
|
1314
|
-
/**
|
|
1315
|
-
* HEAD `url` with optional callback `fn(res)`.
|
|
1316
|
-
*
|
|
1317
|
-
* @param {String} url
|
|
1318
|
-
* @param {Mixed|Function} [data] or fn
|
|
1319
|
-
* @param {Function} [fn]
|
|
1320
|
-
* @return {Request}
|
|
1321
|
-
* @api public
|
|
1322
|
-
*/
|
|
1323
|
-
|
|
1324
3310
|
|
|
1325
3311
|
request.head = function (url, data, fn) {
|
|
1326
|
-
var
|
|
3312
|
+
var request_ = request('HEAD', url);
|
|
1327
3313
|
|
|
1328
3314
|
if (typeof data === 'function') {
|
|
1329
3315
|
fn = data;
|
|
1330
3316
|
data = null;
|
|
1331
3317
|
}
|
|
1332
3318
|
|
|
1333
|
-
if (data)
|
|
1334
|
-
if (fn)
|
|
1335
|
-
return
|
|
3319
|
+
if (data) request_.query(data);
|
|
3320
|
+
if (fn) request_.end(fn);
|
|
3321
|
+
return request_;
|
|
1336
3322
|
};
|
|
1337
|
-
/**
|
|
1338
|
-
* OPTIONS query to `url` with optional callback `fn(res)`.
|
|
1339
|
-
*
|
|
1340
|
-
* @param {String} url
|
|
1341
|
-
* @param {Mixed|Function} [data] or fn
|
|
1342
|
-
* @param {Function} [fn]
|
|
1343
|
-
* @return {Request}
|
|
1344
|
-
* @api public
|
|
1345
|
-
*/
|
|
1346
|
-
|
|
1347
3323
|
|
|
1348
3324
|
request.options = function (url, data, fn) {
|
|
1349
|
-
var
|
|
3325
|
+
var request_ = request('OPTIONS', url);
|
|
1350
3326
|
|
|
1351
3327
|
if (typeof data === 'function') {
|
|
1352
3328
|
fn = data;
|
|
1353
3329
|
data = null;
|
|
1354
3330
|
}
|
|
1355
3331
|
|
|
1356
|
-
if (data)
|
|
1357
|
-
if (fn)
|
|
1358
|
-
return
|
|
3332
|
+
if (data) request_.send(data);
|
|
3333
|
+
if (fn) request_.end(fn);
|
|
3334
|
+
return request_;
|
|
1359
3335
|
};
|
|
1360
|
-
/**
|
|
1361
|
-
* DELETE `url` with optional `data` and callback `fn(res)`.
|
|
1362
|
-
*
|
|
1363
|
-
* @param {String} url
|
|
1364
|
-
* @param {Mixed} [data]
|
|
1365
|
-
* @param {Function} [fn]
|
|
1366
|
-
* @return {Request}
|
|
1367
|
-
* @api public
|
|
1368
|
-
*/
|
|
1369
|
-
|
|
1370
3336
|
|
|
1371
3337
|
function del(url, data, fn) {
|
|
1372
|
-
var
|
|
3338
|
+
var request_ = request('DELETE', url);
|
|
1373
3339
|
|
|
1374
3340
|
if (typeof data === 'function') {
|
|
1375
3341
|
fn = data;
|
|
1376
3342
|
data = null;
|
|
1377
3343
|
}
|
|
1378
3344
|
|
|
1379
|
-
if (data)
|
|
1380
|
-
if (fn)
|
|
1381
|
-
return
|
|
3345
|
+
if (data) request_.send(data);
|
|
3346
|
+
if (fn) request_.end(fn);
|
|
3347
|
+
return request_;
|
|
1382
3348
|
}
|
|
1383
3349
|
|
|
1384
3350
|
request.del = del;
|
|
1385
3351
|
request.delete = del;
|
|
1386
|
-
/**
|
|
1387
|
-
* PATCH `url` with optional `data` and callback `fn(res)`.
|
|
1388
|
-
*
|
|
1389
|
-
* @param {String} url
|
|
1390
|
-
* @param {Mixed} [data]
|
|
1391
|
-
* @param {Function} [fn]
|
|
1392
|
-
* @return {Request}
|
|
1393
|
-
* @api public
|
|
1394
|
-
*/
|
|
1395
3352
|
|
|
1396
3353
|
request.patch = function (url, data, fn) {
|
|
1397
|
-
var
|
|
3354
|
+
var request_ = request('PATCH', url);
|
|
1398
3355
|
|
|
1399
3356
|
if (typeof data === 'function') {
|
|
1400
3357
|
fn = data;
|
|
1401
3358
|
data = null;
|
|
1402
3359
|
}
|
|
1403
3360
|
|
|
1404
|
-
if (data)
|
|
1405
|
-
if (fn)
|
|
1406
|
-
return
|
|
3361
|
+
if (data) request_.send(data);
|
|
3362
|
+
if (fn) request_.end(fn);
|
|
3363
|
+
return request_;
|
|
1407
3364
|
};
|
|
1408
|
-
/**
|
|
1409
|
-
* POST `url` with optional `data` and callback `fn(res)`.
|
|
1410
|
-
*
|
|
1411
|
-
* @param {String} url
|
|
1412
|
-
* @param {Mixed} [data]
|
|
1413
|
-
* @param {Function} [fn]
|
|
1414
|
-
* @return {Request}
|
|
1415
|
-
* @api public
|
|
1416
|
-
*/
|
|
1417
|
-
|
|
1418
3365
|
|
|
1419
3366
|
request.post = function (url, data, fn) {
|
|
1420
|
-
var
|
|
3367
|
+
var request_ = request('POST', url);
|
|
1421
3368
|
|
|
1422
3369
|
if (typeof data === 'function') {
|
|
1423
3370
|
fn = data;
|
|
1424
3371
|
data = null;
|
|
1425
3372
|
}
|
|
1426
3373
|
|
|
1427
|
-
if (data)
|
|
1428
|
-
if (fn)
|
|
1429
|
-
return
|
|
3374
|
+
if (data) request_.send(data);
|
|
3375
|
+
if (fn) request_.end(fn);
|
|
3376
|
+
return request_;
|
|
1430
3377
|
};
|
|
1431
|
-
/**
|
|
1432
|
-
* PUT `url` with optional `data` and callback `fn(res)`.
|
|
1433
|
-
*
|
|
1434
|
-
* @param {String} url
|
|
1435
|
-
* @param {Mixed|Function} [data] or fn
|
|
1436
|
-
* @param {Function} [fn]
|
|
1437
|
-
* @return {Request}
|
|
1438
|
-
* @api public
|
|
1439
|
-
*/
|
|
1440
|
-
|
|
1441
3378
|
|
|
1442
3379
|
request.put = function (url, data, fn) {
|
|
1443
|
-
var
|
|
3380
|
+
var request_ = request('PUT', url);
|
|
1444
3381
|
|
|
1445
3382
|
if (typeof data === 'function') {
|
|
1446
3383
|
fn = data;
|
|
1447
3384
|
data = null;
|
|
1448
3385
|
}
|
|
1449
3386
|
|
|
1450
|
-
if (data)
|
|
1451
|
-
if (fn)
|
|
1452
|
-
return
|
|
3387
|
+
if (data) request_.send(data);
|
|
3388
|
+
if (fn) request_.end(fn);
|
|
3389
|
+
return request_;
|
|
1453
3390
|
};
|
|
1454
3391
|
|
|
1455
|
-
},{"./agent-base":
|
|
3392
|
+
},{"./agent-base":20,"./is-object":21,"./request-base":23,"./response-base":24,"component-emitter":4,"fast-safe-stringify":5,"qs":15}],23:[function(require,module,exports){
|
|
3393
|
+
(function (process){(function (){
|
|
1456
3394
|
"use strict";
|
|
1457
3395
|
|
|
1458
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3396
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1459
3397
|
|
|
1460
|
-
|
|
1461
|
-
* Module of mixed-in functions shared between node and client code
|
|
1462
|
-
*/
|
|
1463
|
-
var isObject = require('./is-object');
|
|
1464
|
-
/**
|
|
1465
|
-
* Expose `RequestBase`.
|
|
1466
|
-
*/
|
|
3398
|
+
var semver = require('semver');
|
|
1467
3399
|
|
|
3400
|
+
var isObject = require('./is-object');
|
|
1468
3401
|
|
|
1469
3402
|
module.exports = RequestBase;
|
|
1470
|
-
/**
|
|
1471
|
-
* Initialize a new `RequestBase`.
|
|
1472
|
-
*
|
|
1473
|
-
* @api public
|
|
1474
|
-
*/
|
|
1475
3403
|
|
|
1476
3404
|
function RequestBase(object) {
|
|
1477
3405
|
if (object) return mixin(object);
|
|
1478
3406
|
}
|
|
1479
|
-
/**
|
|
1480
|
-
* Mixin the prototype properties.
|
|
1481
|
-
*
|
|
1482
|
-
* @param {Object} obj
|
|
1483
|
-
* @return {Object}
|
|
1484
|
-
* @api private
|
|
1485
|
-
*/
|
|
1486
|
-
|
|
1487
3407
|
|
|
1488
3408
|
function mixin(object) {
|
|
1489
3409
|
for (var key in RequestBase.prototype) {
|
|
@@ -1492,13 +3412,6 @@ function mixin(object) {
|
|
|
1492
3412
|
|
|
1493
3413
|
return object;
|
|
1494
3414
|
}
|
|
1495
|
-
/**
|
|
1496
|
-
* Clear previous timeout.
|
|
1497
|
-
*
|
|
1498
|
-
* @return {Request} for chaining
|
|
1499
|
-
* @api public
|
|
1500
|
-
*/
|
|
1501
|
-
|
|
1502
3415
|
|
|
1503
3416
|
RequestBase.prototype.clearTimeout = function () {
|
|
1504
3417
|
clearTimeout(this._timer);
|
|
@@ -1509,71 +3422,21 @@ RequestBase.prototype.clearTimeout = function () {
|
|
|
1509
3422
|
delete this._uploadTimeoutTimer;
|
|
1510
3423
|
return this;
|
|
1511
3424
|
};
|
|
1512
|
-
/**
|
|
1513
|
-
* Override default response body parser
|
|
1514
|
-
*
|
|
1515
|
-
* This function will be called to convert incoming data into request.body
|
|
1516
|
-
*
|
|
1517
|
-
* @param {Function}
|
|
1518
|
-
* @api public
|
|
1519
|
-
*/
|
|
1520
|
-
|
|
1521
3425
|
|
|
1522
3426
|
RequestBase.prototype.parse = function (fn) {
|
|
1523
3427
|
this._parser = fn;
|
|
1524
3428
|
return this;
|
|
1525
3429
|
};
|
|
1526
|
-
/**
|
|
1527
|
-
* Set format of binary response body.
|
|
1528
|
-
* In browser valid formats are 'blob' and 'arraybuffer',
|
|
1529
|
-
* which return Blob and ArrayBuffer, respectively.
|
|
1530
|
-
*
|
|
1531
|
-
* In Node all values result in Buffer.
|
|
1532
|
-
*
|
|
1533
|
-
* Examples:
|
|
1534
|
-
*
|
|
1535
|
-
* req.get('/')
|
|
1536
|
-
* .responseType('blob')
|
|
1537
|
-
* .end(callback);
|
|
1538
|
-
*
|
|
1539
|
-
* @param {String} val
|
|
1540
|
-
* @return {Request} for chaining
|
|
1541
|
-
* @api public
|
|
1542
|
-
*/
|
|
1543
|
-
|
|
1544
3430
|
|
|
1545
3431
|
RequestBase.prototype.responseType = function (value) {
|
|
1546
3432
|
this._responseType = value;
|
|
1547
3433
|
return this;
|
|
1548
3434
|
};
|
|
1549
|
-
/**
|
|
1550
|
-
* Override default request body serializer
|
|
1551
|
-
*
|
|
1552
|
-
* This function will be called to convert data set via .send or .attach into payload to send
|
|
1553
|
-
*
|
|
1554
|
-
* @param {Function}
|
|
1555
|
-
* @api public
|
|
1556
|
-
*/
|
|
1557
|
-
|
|
1558
3435
|
|
|
1559
3436
|
RequestBase.prototype.serialize = function (fn) {
|
|
1560
3437
|
this._serializer = fn;
|
|
1561
3438
|
return this;
|
|
1562
3439
|
};
|
|
1563
|
-
/**
|
|
1564
|
-
* Set timeouts.
|
|
1565
|
-
*
|
|
1566
|
-
* - response timeout is time between sending request and receiving the first byte of the response. Includes DNS and connection time.
|
|
1567
|
-
* - deadline is the time from start of the request to receiving response body in full. If the deadline is too short large files may not load at all on slow connections.
|
|
1568
|
-
* - upload is the time since last bit of data was sent or received. This timeout works only if deadline timeout is off
|
|
1569
|
-
*
|
|
1570
|
-
* Value of 0 or false means no timeout.
|
|
1571
|
-
*
|
|
1572
|
-
* @param {Number|Object} ms or {response, deadline}
|
|
1573
|
-
* @return {Request} for chaining
|
|
1574
|
-
* @api public
|
|
1575
|
-
*/
|
|
1576
|
-
|
|
1577
3440
|
|
|
1578
3441
|
RequestBase.prototype.timeout = function (options) {
|
|
1579
3442
|
if (!options || _typeof(options) !== 'object') {
|
|
@@ -1606,99 +3469,48 @@ RequestBase.prototype.timeout = function (options) {
|
|
|
1606
3469
|
|
|
1607
3470
|
return this;
|
|
1608
3471
|
};
|
|
1609
|
-
/**
|
|
1610
|
-
* Set number of retry attempts on error.
|
|
1611
|
-
*
|
|
1612
|
-
* Failed requests will be retried 'count' times if timeout or err.code >= 500.
|
|
1613
|
-
*
|
|
1614
|
-
* @param {Number} count
|
|
1615
|
-
* @param {Function} [fn]
|
|
1616
|
-
* @return {Request} for chaining
|
|
1617
|
-
* @api public
|
|
1618
|
-
*/
|
|
1619
|
-
|
|
1620
3472
|
|
|
1621
3473
|
RequestBase.prototype.retry = function (count, fn) {
|
|
1622
|
-
// Default to 1 if no count passed or true
|
|
1623
3474
|
if (arguments.length === 0 || count === true) count = 1;
|
|
1624
3475
|
if (count <= 0) count = 0;
|
|
1625
3476
|
this._maxRetries = count;
|
|
1626
3477
|
this._retries = 0;
|
|
1627
3478
|
this._retryCallback = fn;
|
|
1628
3479
|
return this;
|
|
1629
|
-
};
|
|
1630
|
-
// NOTE: we do not include ESOCKETTIMEDOUT because that is from `request` package
|
|
1631
|
-
// <https://github.com/sindresorhus/got/pull/537>
|
|
1632
|
-
//
|
|
1633
|
-
// NOTE: we do not include EADDRINFO because it was removed from libuv in 2014
|
|
1634
|
-
// <https://github.com/libuv/libuv/commit/02e1ebd40b807be5af46343ea873331b2ee4e9c1>
|
|
1635
|
-
// <https://github.com/request/request/search?q=ESOCKETTIMEDOUT&unscoped_q=ESOCKETTIMEDOUT>
|
|
1636
|
-
//
|
|
1637
|
-
//
|
|
1638
|
-
// TODO: expose these as configurable defaults
|
|
1639
|
-
//
|
|
1640
|
-
|
|
3480
|
+
};
|
|
1641
3481
|
|
|
1642
3482
|
var ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
|
|
1643
|
-
var STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
/**
|
|
1647
|
-
* Determine if a request should be retried.
|
|
1648
|
-
* (Inspired by https://github.com/sindresorhus/got#retry)
|
|
1649
|
-
*
|
|
1650
|
-
* @param {Error} err an error
|
|
1651
|
-
* @param {Response} [res] response
|
|
1652
|
-
* @returns {Boolean} if segment should be retried
|
|
1653
|
-
*/
|
|
1654
|
-
|
|
1655
|
-
RequestBase.prototype._shouldRetry = function (err, res) {
|
|
3483
|
+
var STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
|
|
3484
|
+
|
|
3485
|
+
RequestBase.prototype._shouldRetry = function (error, res) {
|
|
1656
3486
|
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
|
|
1657
3487
|
return false;
|
|
1658
3488
|
}
|
|
1659
3489
|
|
|
1660
3490
|
if (this._retryCallback) {
|
|
1661
3491
|
try {
|
|
1662
|
-
var override = this._retryCallback(
|
|
3492
|
+
var override = this._retryCallback(error, res);
|
|
1663
3493
|
|
|
1664
3494
|
if (override === true) return true;
|
|
1665
|
-
if (override === false) return false;
|
|
1666
|
-
} catch (
|
|
1667
|
-
console.error(
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
/*
|
|
1672
|
-
if (
|
|
1673
|
-
this.req &&
|
|
1674
|
-
this.req.method &&
|
|
1675
|
-
!METHODS.has(this.req.method.toUpperCase())
|
|
1676
|
-
)
|
|
1677
|
-
return false;
|
|
1678
|
-
*/
|
|
1679
|
-
|
|
3495
|
+
if (override === false) return false;
|
|
3496
|
+
} catch (error_) {
|
|
3497
|
+
console.error(error_);
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
1680
3500
|
|
|
1681
3501
|
if (res && res.status && STATUS_CODES.has(res.status)) return true;
|
|
1682
3502
|
|
|
1683
|
-
if (
|
|
1684
|
-
if (
|
|
1685
|
-
|
|
1686
|
-
if (
|
|
1687
|
-
if (err.crossDomain) return true;
|
|
3503
|
+
if (error) {
|
|
3504
|
+
if (error.code && ERROR_CODES.has(error.code)) return true;
|
|
3505
|
+
if (error.timeout && error.code === 'ECONNABORTED') return true;
|
|
3506
|
+
if (error.crossDomain) return true;
|
|
1688
3507
|
}
|
|
1689
3508
|
|
|
1690
3509
|
return false;
|
|
1691
3510
|
};
|
|
1692
|
-
/**
|
|
1693
|
-
* Retry request
|
|
1694
|
-
*
|
|
1695
|
-
* @return {Request} for chaining
|
|
1696
|
-
* @api private
|
|
1697
|
-
*/
|
|
1698
|
-
|
|
1699
3511
|
|
|
1700
3512
|
RequestBase.prototype._retry = function () {
|
|
1701
|
-
this.clearTimeout();
|
|
3513
|
+
this.clearTimeout();
|
|
1702
3514
|
|
|
1703
3515
|
if (this.req) {
|
|
1704
3516
|
this.req = null;
|
|
@@ -1710,14 +3522,6 @@ RequestBase.prototype._retry = function () {
|
|
|
1710
3522
|
this.timedoutError = null;
|
|
1711
3523
|
return this._end();
|
|
1712
3524
|
};
|
|
1713
|
-
/**
|
|
1714
|
-
* Promise support
|
|
1715
|
-
*
|
|
1716
|
-
* @param {Function} resolve
|
|
1717
|
-
* @param {Function} [reject]
|
|
1718
|
-
* @return {Request}
|
|
1719
|
-
*/
|
|
1720
|
-
|
|
1721
3525
|
|
|
1722
3526
|
RequestBase.prototype.then = function (resolve, reject) {
|
|
1723
3527
|
var _this = this;
|
|
@@ -1740,15 +3544,15 @@ RequestBase.prototype.then = function (resolve, reject) {
|
|
|
1740
3544
|
return;
|
|
1741
3545
|
}
|
|
1742
3546
|
|
|
1743
|
-
var
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
reject(
|
|
3547
|
+
var error = new Error('Aborted');
|
|
3548
|
+
error.code = 'ABORTED';
|
|
3549
|
+
error.status = _this.status;
|
|
3550
|
+
error.method = _this.method;
|
|
3551
|
+
error.url = _this.url;
|
|
3552
|
+
reject(error);
|
|
1749
3553
|
});
|
|
1750
|
-
self.end(function (
|
|
1751
|
-
if (
|
|
3554
|
+
self.end(function (error, res) {
|
|
3555
|
+
if (error) reject(error);else resolve(res);
|
|
1752
3556
|
});
|
|
1753
3557
|
});
|
|
1754
3558
|
}
|
|
@@ -1759,10 +3563,6 @@ RequestBase.prototype.then = function (resolve, reject) {
|
|
|
1759
3563
|
RequestBase.prototype.catch = function (cb) {
|
|
1760
3564
|
return this.then(undefined, cb);
|
|
1761
3565
|
};
|
|
1762
|
-
/**
|
|
1763
|
-
* Allow for extension
|
|
1764
|
-
*/
|
|
1765
|
-
|
|
1766
3566
|
|
|
1767
3567
|
RequestBase.prototype.use = function (fn) {
|
|
1768
3568
|
fn(this);
|
|
@@ -1786,53 +3586,12 @@ RequestBase.prototype._isResponseOK = function (res) {
|
|
|
1786
3586
|
|
|
1787
3587
|
return res.status >= 200 && res.status < 300;
|
|
1788
3588
|
};
|
|
1789
|
-
/**
|
|
1790
|
-
* Get request header `field`.
|
|
1791
|
-
* Case-insensitive.
|
|
1792
|
-
*
|
|
1793
|
-
* @param {String} field
|
|
1794
|
-
* @return {String}
|
|
1795
|
-
* @api public
|
|
1796
|
-
*/
|
|
1797
|
-
|
|
1798
3589
|
|
|
1799
3590
|
RequestBase.prototype.get = function (field) {
|
|
1800
3591
|
return this._header[field.toLowerCase()];
|
|
1801
3592
|
};
|
|
1802
|
-
/**
|
|
1803
|
-
* Get case-insensitive header `field` value.
|
|
1804
|
-
* This is a deprecated internal API. Use `.get(field)` instead.
|
|
1805
|
-
*
|
|
1806
|
-
* (getHeader is no longer used internally by the superagent code base)
|
|
1807
|
-
*
|
|
1808
|
-
* @param {String} field
|
|
1809
|
-
* @return {String}
|
|
1810
|
-
* @api private
|
|
1811
|
-
* @deprecated
|
|
1812
|
-
*/
|
|
1813
|
-
|
|
1814
3593
|
|
|
1815
3594
|
RequestBase.prototype.getHeader = RequestBase.prototype.get;
|
|
1816
|
-
/**
|
|
1817
|
-
* Set header `field` to `val`, or multiple fields with one object.
|
|
1818
|
-
* Case-insensitive.
|
|
1819
|
-
*
|
|
1820
|
-
* Examples:
|
|
1821
|
-
*
|
|
1822
|
-
* req.get('/')
|
|
1823
|
-
* .set('Accept', 'application/json')
|
|
1824
|
-
* .set('X-API-Key', 'foobar')
|
|
1825
|
-
* .end(callback);
|
|
1826
|
-
*
|
|
1827
|
-
* req.get('/')
|
|
1828
|
-
* .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
|
|
1829
|
-
* .end(callback);
|
|
1830
|
-
*
|
|
1831
|
-
* @param {String|Object} field
|
|
1832
|
-
* @param {String} val
|
|
1833
|
-
* @return {Request} for chaining
|
|
1834
|
-
* @api public
|
|
1835
|
-
*/
|
|
1836
3595
|
|
|
1837
3596
|
RequestBase.prototype.set = function (field, value) {
|
|
1838
3597
|
if (isObject(field)) {
|
|
@@ -1847,48 +3606,14 @@ RequestBase.prototype.set = function (field, value) {
|
|
|
1847
3606
|
this.header[field] = value;
|
|
1848
3607
|
return this;
|
|
1849
3608
|
};
|
|
1850
|
-
/**
|
|
1851
|
-
* Remove header `field`.
|
|
1852
|
-
* Case-insensitive.
|
|
1853
|
-
*
|
|
1854
|
-
* Example:
|
|
1855
|
-
*
|
|
1856
|
-
* req.get('/')
|
|
1857
|
-
* .unset('User-Agent')
|
|
1858
|
-
* .end(callback);
|
|
1859
|
-
*
|
|
1860
|
-
* @param {String} field field name
|
|
1861
|
-
*/
|
|
1862
|
-
|
|
1863
3609
|
|
|
1864
3610
|
RequestBase.prototype.unset = function (field) {
|
|
1865
3611
|
delete this._header[field.toLowerCase()];
|
|
1866
3612
|
delete this.header[field];
|
|
1867
3613
|
return this;
|
|
1868
3614
|
};
|
|
1869
|
-
/**
|
|
1870
|
-
* Write the field `name` and `val`, or multiple fields with one object
|
|
1871
|
-
* for "multipart/form-data" request bodies.
|
|
1872
|
-
*
|
|
1873
|
-
* ``` js
|
|
1874
|
-
* request.post('/upload')
|
|
1875
|
-
* .field('foo', 'bar')
|
|
1876
|
-
* .end(callback);
|
|
1877
|
-
*
|
|
1878
|
-
* request.post('/upload')
|
|
1879
|
-
* .field({ foo: 'bar', baz: 'qux' })
|
|
1880
|
-
* .end(callback);
|
|
1881
|
-
* ```
|
|
1882
|
-
*
|
|
1883
|
-
* @param {String|Object} name name of field
|
|
1884
|
-
* @param {String|Blob|File|Buffer|fs.ReadStream} val value of field
|
|
1885
|
-
* @return {Request} for chaining
|
|
1886
|
-
* @api public
|
|
1887
|
-
*/
|
|
1888
|
-
|
|
1889
3615
|
|
|
1890
3616
|
RequestBase.prototype.field = function (name, value) {
|
|
1891
|
-
// name should be either a string or an object.
|
|
1892
3617
|
if (name === null || undefined === name) {
|
|
1893
3618
|
throw new Error('.field(name, val) name can not be empty');
|
|
1894
3619
|
}
|
|
@@ -1911,8 +3636,7 @@ RequestBase.prototype.field = function (name, value) {
|
|
|
1911
3636
|
}
|
|
1912
3637
|
|
|
1913
3638
|
return this;
|
|
1914
|
-
}
|
|
1915
|
-
|
|
3639
|
+
}
|
|
1916
3640
|
|
|
1917
3641
|
if (value === null || undefined === value) {
|
|
1918
3642
|
throw new Error('.field(name, val) val can not be empty');
|
|
@@ -1926,13 +3650,6 @@ RequestBase.prototype.field = function (name, value) {
|
|
|
1926
3650
|
|
|
1927
3651
|
return this;
|
|
1928
3652
|
};
|
|
1929
|
-
/**
|
|
1930
|
-
* Abort the request, and clear potential timeout.
|
|
1931
|
-
*
|
|
1932
|
-
* @return {Request} request
|
|
1933
|
-
* @api public
|
|
1934
|
-
*/
|
|
1935
|
-
|
|
1936
3653
|
|
|
1937
3654
|
RequestBase.prototype.abort = function () {
|
|
1938
3655
|
if (this._aborted) {
|
|
@@ -1940,9 +3657,17 @@ RequestBase.prototype.abort = function () {
|
|
|
1940
3657
|
}
|
|
1941
3658
|
|
|
1942
3659
|
this._aborted = true;
|
|
1943
|
-
if (this.xhr) this.xhr.abort();
|
|
3660
|
+
if (this.xhr) this.xhr.abort();
|
|
1944
3661
|
|
|
1945
|
-
if (this.req)
|
|
3662
|
+
if (this.req) {
|
|
3663
|
+
if (semver.gte(process.version, 'v13.0.0') && semver.lt(process.version, 'v14.0.0')) {
|
|
3664
|
+
throw new Error('Superagent does not work in v13 properly with abort() due to Node.js core changes');
|
|
3665
|
+
} else if (semver.gte(process.version, 'v14.0.0')) {
|
|
3666
|
+
this.req.destroyed = true;
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
this.req.abort();
|
|
3670
|
+
}
|
|
1946
3671
|
|
|
1947
3672
|
this.clearTimeout();
|
|
1948
3673
|
this.emit('abort');
|
|
@@ -1961,7 +3686,6 @@ RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
|
|
|
1961
3686
|
break;
|
|
1962
3687
|
|
|
1963
3688
|
case 'bearer':
|
|
1964
|
-
// usage would be .auth(accessToken, { type: 'bearer' })
|
|
1965
3689
|
this.set('Authorization', "Bearer ".concat(user));
|
|
1966
3690
|
break;
|
|
1967
3691
|
|
|
@@ -1971,45 +3695,17 @@ RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
|
|
|
1971
3695
|
|
|
1972
3696
|
return this;
|
|
1973
3697
|
};
|
|
1974
|
-
/**
|
|
1975
|
-
* Enable transmission of cookies with x-domain requests.
|
|
1976
|
-
*
|
|
1977
|
-
* Note that for this to work the origin must not be
|
|
1978
|
-
* using "Access-Control-Allow-Origin" with a wildcard,
|
|
1979
|
-
* and also must set "Access-Control-Allow-Credentials"
|
|
1980
|
-
* to "true".
|
|
1981
|
-
*
|
|
1982
|
-
* @api public
|
|
1983
|
-
*/
|
|
1984
|
-
|
|
1985
3698
|
|
|
1986
3699
|
RequestBase.prototype.withCredentials = function (on) {
|
|
1987
|
-
// This is browser-only functionality. Node side is no-op.
|
|
1988
3700
|
if (on === undefined) on = true;
|
|
1989
3701
|
this._withCredentials = on;
|
|
1990
3702
|
return this;
|
|
1991
3703
|
};
|
|
1992
|
-
/**
|
|
1993
|
-
* Set the max redirects to `n`. Does nothing in browser XHR implementation.
|
|
1994
|
-
*
|
|
1995
|
-
* @param {Number} n
|
|
1996
|
-
* @return {Request} for chaining
|
|
1997
|
-
* @api public
|
|
1998
|
-
*/
|
|
1999
|
-
|
|
2000
3704
|
|
|
2001
3705
|
RequestBase.prototype.redirects = function (n) {
|
|
2002
3706
|
this._maxRedirects = n;
|
|
2003
3707
|
return this;
|
|
2004
3708
|
};
|
|
2005
|
-
/**
|
|
2006
|
-
* Maximum size of buffered response body, in bytes. Counts uncompressed size.
|
|
2007
|
-
* Default 200MB.
|
|
2008
|
-
*
|
|
2009
|
-
* @param {Number} n number of bytes
|
|
2010
|
-
* @return {Request} for chaining
|
|
2011
|
-
*/
|
|
2012
|
-
|
|
2013
3709
|
|
|
2014
3710
|
RequestBase.prototype.maxResponseSize = function (n) {
|
|
2015
3711
|
if (typeof n !== 'number') {
|
|
@@ -2019,15 +3715,6 @@ RequestBase.prototype.maxResponseSize = function (n) {
|
|
|
2019
3715
|
this._maxResponseSize = n;
|
|
2020
3716
|
return this;
|
|
2021
3717
|
};
|
|
2022
|
-
/**
|
|
2023
|
-
* Convert to a plain javascript object (not JSON string) of scalar properties.
|
|
2024
|
-
* Note as this method is designed to return a useful non-this value,
|
|
2025
|
-
* it cannot be chained.
|
|
2026
|
-
*
|
|
2027
|
-
* @return {Object} describing method, url, and data of this request
|
|
2028
|
-
* @api public
|
|
2029
|
-
*/
|
|
2030
|
-
|
|
2031
3718
|
|
|
2032
3719
|
RequestBase.prototype.toJSON = function () {
|
|
2033
3720
|
return {
|
|
@@ -2037,47 +3724,6 @@ RequestBase.prototype.toJSON = function () {
|
|
|
2037
3724
|
headers: this._header
|
|
2038
3725
|
};
|
|
2039
3726
|
};
|
|
2040
|
-
/**
|
|
2041
|
-
* Send `data` as the request body, defaulting the `.type()` to "json" when
|
|
2042
|
-
* an object is given.
|
|
2043
|
-
*
|
|
2044
|
-
* Examples:
|
|
2045
|
-
*
|
|
2046
|
-
* // manual json
|
|
2047
|
-
* request.post('/user')
|
|
2048
|
-
* .type('json')
|
|
2049
|
-
* .send('{"name":"tj"}')
|
|
2050
|
-
* .end(callback)
|
|
2051
|
-
*
|
|
2052
|
-
* // auto json
|
|
2053
|
-
* request.post('/user')
|
|
2054
|
-
* .send({ name: 'tj' })
|
|
2055
|
-
* .end(callback)
|
|
2056
|
-
*
|
|
2057
|
-
* // manual x-www-form-urlencoded
|
|
2058
|
-
* request.post('/user')
|
|
2059
|
-
* .type('form')
|
|
2060
|
-
* .send('name=tj')
|
|
2061
|
-
* .end(callback)
|
|
2062
|
-
*
|
|
2063
|
-
* // auto x-www-form-urlencoded
|
|
2064
|
-
* request.post('/user')
|
|
2065
|
-
* .type('form')
|
|
2066
|
-
* .send({ name: 'tj' })
|
|
2067
|
-
* .end(callback)
|
|
2068
|
-
*
|
|
2069
|
-
* // defaults to x-www-form-urlencoded
|
|
2070
|
-
* request.post('/user')
|
|
2071
|
-
* .send('name=tobi')
|
|
2072
|
-
* .send('species=ferret')
|
|
2073
|
-
* .end(callback)
|
|
2074
|
-
*
|
|
2075
|
-
* @param {String|Object} data
|
|
2076
|
-
* @return {Request} for chaining
|
|
2077
|
-
* @api public
|
|
2078
|
-
*/
|
|
2079
|
-
// eslint-disable-next-line complexity
|
|
2080
|
-
|
|
2081
3727
|
|
|
2082
3728
|
RequestBase.prototype.send = function (data) {
|
|
2083
3729
|
var isObject_ = isObject(data);
|
|
@@ -2095,15 +3741,13 @@ RequestBase.prototype.send = function (data) {
|
|
|
2095
3741
|
}
|
|
2096
3742
|
} else if (data && this._data && this._isHost(this._data)) {
|
|
2097
3743
|
throw new Error("Can't merge these send calls");
|
|
2098
|
-
}
|
|
2099
|
-
|
|
3744
|
+
}
|
|
2100
3745
|
|
|
2101
3746
|
if (isObject_ && isObject(this._data)) {
|
|
2102
3747
|
for (var key in data) {
|
|
2103
3748
|
if (Object.prototype.hasOwnProperty.call(data, key)) this._data[key] = data[key];
|
|
2104
3749
|
}
|
|
2105
3750
|
} else if (typeof data === 'string') {
|
|
2106
|
-
// default to x-www-form-urlencoded
|
|
2107
3751
|
if (!type) this.type('form');
|
|
2108
3752
|
type = this._header['content-type'];
|
|
2109
3753
|
if (type) type = type.toLowerCase().trim();
|
|
@@ -2119,52 +3763,16 @@ RequestBase.prototype.send = function (data) {
|
|
|
2119
3763
|
|
|
2120
3764
|
if (!isObject_ || this._isHost(data)) {
|
|
2121
3765
|
return this;
|
|
2122
|
-
}
|
|
2123
|
-
|
|
3766
|
+
}
|
|
2124
3767
|
|
|
2125
3768
|
if (!type) this.type('json');
|
|
2126
3769
|
return this;
|
|
2127
3770
|
};
|
|
2128
|
-
/**
|
|
2129
|
-
* Sort `querystring` by the sort function
|
|
2130
|
-
*
|
|
2131
|
-
*
|
|
2132
|
-
* Examples:
|
|
2133
|
-
*
|
|
2134
|
-
* // default order
|
|
2135
|
-
* request.get('/user')
|
|
2136
|
-
* .query('name=Nick')
|
|
2137
|
-
* .query('search=Manny')
|
|
2138
|
-
* .sortQuery()
|
|
2139
|
-
* .end(callback)
|
|
2140
|
-
*
|
|
2141
|
-
* // customized sort function
|
|
2142
|
-
* request.get('/user')
|
|
2143
|
-
* .query('name=Nick')
|
|
2144
|
-
* .query('search=Manny')
|
|
2145
|
-
* .sortQuery(function(a, b){
|
|
2146
|
-
* return a.length - b.length;
|
|
2147
|
-
* })
|
|
2148
|
-
* .end(callback)
|
|
2149
|
-
*
|
|
2150
|
-
*
|
|
2151
|
-
* @param {Function} sort
|
|
2152
|
-
* @return {Request} for chaining
|
|
2153
|
-
* @api public
|
|
2154
|
-
*/
|
|
2155
|
-
|
|
2156
3771
|
|
|
2157
3772
|
RequestBase.prototype.sortQuery = function (sort) {
|
|
2158
|
-
// _sort default to true but otherwise can be a function or boolean
|
|
2159
3773
|
this._sort = typeof sort === 'undefined' ? true : sort;
|
|
2160
3774
|
return this;
|
|
2161
3775
|
};
|
|
2162
|
-
/**
|
|
2163
|
-
* Compose querystring to append to req.url
|
|
2164
|
-
*
|
|
2165
|
-
* @api private
|
|
2166
|
-
*/
|
|
2167
|
-
|
|
2168
3776
|
|
|
2169
3777
|
RequestBase.prototype._finalizeQueryString = function () {
|
|
2170
3778
|
var query = this._query.join('&');
|
|
@@ -2173,7 +3781,7 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
2173
3781
|
this.url += (this.url.includes('?') ? '&' : '?') + query;
|
|
2174
3782
|
}
|
|
2175
3783
|
|
|
2176
|
-
this._query.length = 0;
|
|
3784
|
+
this._query.length = 0;
|
|
2177
3785
|
|
|
2178
3786
|
if (this._sort) {
|
|
2179
3787
|
var index = this.url.indexOf('?');
|
|
@@ -2190,43 +3798,35 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
2190
3798
|
this.url = this.url.slice(0, index) + '?' + queryArray.join('&');
|
|
2191
3799
|
}
|
|
2192
3800
|
}
|
|
2193
|
-
};
|
|
2194
|
-
|
|
3801
|
+
};
|
|
2195
3802
|
|
|
2196
3803
|
RequestBase.prototype._appendQueryString = function () {
|
|
2197
3804
|
console.warn('Unsupported');
|
|
2198
3805
|
};
|
|
2199
|
-
/**
|
|
2200
|
-
* Invoke callback with timeout error.
|
|
2201
|
-
*
|
|
2202
|
-
* @api private
|
|
2203
|
-
*/
|
|
2204
|
-
|
|
2205
3806
|
|
|
2206
3807
|
RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
2207
3808
|
if (this._aborted) {
|
|
2208
3809
|
return;
|
|
2209
3810
|
}
|
|
2210
3811
|
|
|
2211
|
-
var
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
3812
|
+
var error = new Error("".concat(reason + timeout, "ms exceeded"));
|
|
3813
|
+
error.timeout = timeout;
|
|
3814
|
+
error.code = 'ECONNABORTED';
|
|
3815
|
+
error.errno = errno;
|
|
2215
3816
|
this.timedout = true;
|
|
2216
|
-
this.timedoutError =
|
|
3817
|
+
this.timedoutError = error;
|
|
2217
3818
|
this.abort();
|
|
2218
|
-
this.callback(
|
|
3819
|
+
this.callback(error);
|
|
2219
3820
|
};
|
|
2220
3821
|
|
|
2221
3822
|
RequestBase.prototype._setTimeouts = function () {
|
|
2222
|
-
var self = this;
|
|
3823
|
+
var self = this;
|
|
2223
3824
|
|
|
2224
3825
|
if (this._timeout && !this._timer) {
|
|
2225
3826
|
this._timer = setTimeout(function () {
|
|
2226
3827
|
self._timeoutError('Timeout of ', self._timeout, 'ETIME');
|
|
2227
3828
|
}, this._timeout);
|
|
2228
|
-
}
|
|
2229
|
-
|
|
3829
|
+
}
|
|
2230
3830
|
|
|
2231
3831
|
if (this._responseTimeout && !this._responseTimeoutTimer) {
|
|
2232
3832
|
this._responseTimeoutTimer = setTimeout(function () {
|
|
@@ -2235,127 +3835,59 @@ RequestBase.prototype._setTimeouts = function () {
|
|
|
2235
3835
|
}
|
|
2236
3836
|
};
|
|
2237
3837
|
|
|
2238
|
-
}
|
|
3838
|
+
}).call(this)}).call(this,require('_process'))
|
|
3839
|
+
},{"./is-object":21,"_process":13,"semver":1}],24:[function(require,module,exports){
|
|
2239
3840
|
"use strict";
|
|
2240
3841
|
|
|
2241
|
-
/**
|
|
2242
|
-
* Module dependencies.
|
|
2243
|
-
*/
|
|
2244
3842
|
var utils = require('./utils');
|
|
2245
|
-
/**
|
|
2246
|
-
* Expose `ResponseBase`.
|
|
2247
|
-
*/
|
|
2248
|
-
|
|
2249
3843
|
|
|
2250
3844
|
module.exports = ResponseBase;
|
|
2251
|
-
/**
|
|
2252
|
-
* Initialize a new `ResponseBase`.
|
|
2253
|
-
*
|
|
2254
|
-
* @api public
|
|
2255
|
-
*/
|
|
2256
3845
|
|
|
2257
|
-
function ResponseBase(
|
|
2258
|
-
if (
|
|
3846
|
+
function ResponseBase(object) {
|
|
3847
|
+
if (object) return mixin(object);
|
|
2259
3848
|
}
|
|
2260
|
-
/**
|
|
2261
|
-
* Mixin the prototype properties.
|
|
2262
|
-
*
|
|
2263
|
-
* @param {Object} obj
|
|
2264
|
-
* @return {Object}
|
|
2265
|
-
* @api private
|
|
2266
|
-
*/
|
|
2267
3849
|
|
|
2268
|
-
|
|
2269
|
-
function mixin(obj) {
|
|
3850
|
+
function mixin(object) {
|
|
2270
3851
|
for (var key in ResponseBase.prototype) {
|
|
2271
|
-
if (Object.prototype.hasOwnProperty.call(ResponseBase.prototype, key))
|
|
3852
|
+
if (Object.prototype.hasOwnProperty.call(ResponseBase.prototype, key)) object[key] = ResponseBase.prototype[key];
|
|
2272
3853
|
}
|
|
2273
3854
|
|
|
2274
|
-
return
|
|
3855
|
+
return object;
|
|
2275
3856
|
}
|
|
2276
|
-
/**
|
|
2277
|
-
* Get case-insensitive `field` value.
|
|
2278
|
-
*
|
|
2279
|
-
* @param {String} field
|
|
2280
|
-
* @return {String}
|
|
2281
|
-
* @api public
|
|
2282
|
-
*/
|
|
2283
|
-
|
|
2284
3857
|
|
|
2285
3858
|
ResponseBase.prototype.get = function (field) {
|
|
2286
3859
|
return this.header[field.toLowerCase()];
|
|
2287
3860
|
};
|
|
2288
|
-
/**
|
|
2289
|
-
* Set header related properties:
|
|
2290
|
-
*
|
|
2291
|
-
* - `.type` the content type without params
|
|
2292
|
-
*
|
|
2293
|
-
* A response of "Content-Type: text/plain; charset=utf-8"
|
|
2294
|
-
* will provide you with a `.type` of "text/plain".
|
|
2295
|
-
*
|
|
2296
|
-
* @param {Object} header
|
|
2297
|
-
* @api private
|
|
2298
|
-
*/
|
|
2299
|
-
|
|
2300
3861
|
|
|
2301
3862
|
ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
2302
|
-
// TODO: moar!
|
|
2303
|
-
// TODO: make this a util
|
|
2304
|
-
// content-type
|
|
2305
3863
|
var ct = header['content-type'] || '';
|
|
2306
|
-
this.type = utils.type(ct);
|
|
2307
|
-
|
|
2308
|
-
var params = utils.params(ct);
|
|
3864
|
+
this.type = utils.type(ct);
|
|
3865
|
+
var parameters = utils.params(ct);
|
|
2309
3866
|
|
|
2310
|
-
for (var key in
|
|
2311
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
3867
|
+
for (var key in parameters) {
|
|
3868
|
+
if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
|
|
2312
3869
|
}
|
|
2313
3870
|
|
|
2314
|
-
this.links = {};
|
|
3871
|
+
this.links = {};
|
|
2315
3872
|
|
|
2316
3873
|
try {
|
|
2317
3874
|
if (header.link) {
|
|
2318
3875
|
this.links = utils.parseLinks(header.link);
|
|
2319
3876
|
}
|
|
2320
|
-
} catch (_unused) {
|
|
2321
|
-
|
|
2322
|
-
};
|
|
2323
|
-
/**
|
|
2324
|
-
* Set flags such as `.ok` based on `status`.
|
|
2325
|
-
*
|
|
2326
|
-
* For example a 2xx response will give you a `.ok` of __true__
|
|
2327
|
-
* whereas 5xx will be __false__ and `.error` will be __true__. The
|
|
2328
|
-
* `.clientError` and `.serverError` are also available to be more
|
|
2329
|
-
* specific, and `.statusType` is the class of error ranging from 1..5
|
|
2330
|
-
* sometimes useful for mapping respond colors etc.
|
|
2331
|
-
*
|
|
2332
|
-
* "sugar" properties are also defined for common cases. Currently providing:
|
|
2333
|
-
*
|
|
2334
|
-
* - .noContent
|
|
2335
|
-
* - .badRequest
|
|
2336
|
-
* - .unauthorized
|
|
2337
|
-
* - .notAcceptable
|
|
2338
|
-
* - .notFound
|
|
2339
|
-
*
|
|
2340
|
-
* @param {Number} status
|
|
2341
|
-
* @api private
|
|
2342
|
-
*/
|
|
2343
|
-
|
|
3877
|
+
} catch (_unused) {}
|
|
3878
|
+
};
|
|
2344
3879
|
|
|
2345
3880
|
ResponseBase.prototype._setStatusProperties = function (status) {
|
|
2346
|
-
var type = status / 100
|
|
2347
|
-
|
|
3881
|
+
var type = Math.trunc(status / 100);
|
|
2348
3882
|
this.statusCode = status;
|
|
2349
3883
|
this.status = this.statusCode;
|
|
2350
|
-
this.statusType = type;
|
|
2351
|
-
|
|
3884
|
+
this.statusType = type;
|
|
2352
3885
|
this.info = type === 1;
|
|
2353
3886
|
this.ok = type === 2;
|
|
2354
3887
|
this.redirect = type === 3;
|
|
2355
3888
|
this.clientError = type === 4;
|
|
2356
3889
|
this.serverError = type === 5;
|
|
2357
|
-
this.error = type === 4 || type === 5 ? this.toError() : false;
|
|
2358
|
-
|
|
3890
|
+
this.error = type === 4 || type === 5 ? this.toError() : false;
|
|
2359
3891
|
this.created = status === 201;
|
|
2360
3892
|
this.accepted = status === 202;
|
|
2361
3893
|
this.noContent = status === 204;
|
|
@@ -2367,49 +3899,34 @@ ResponseBase.prototype._setStatusProperties = function (status) {
|
|
|
2367
3899
|
this.unprocessableEntity = status === 422;
|
|
2368
3900
|
};
|
|
2369
3901
|
|
|
2370
|
-
},{"./utils":
|
|
3902
|
+
},{"./utils":25}],25:[function(require,module,exports){
|
|
2371
3903
|
"use strict";
|
|
2372
3904
|
|
|
2373
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
3905
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2374
3906
|
|
|
2375
3907
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2376
3908
|
|
|
2377
3909
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2378
3910
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
* @param {String} str
|
|
2383
|
-
* @return {String}
|
|
2384
|
-
* @api private
|
|
2385
|
-
*/
|
|
2386
|
-
exports.type = function (str) {
|
|
2387
|
-
return str.split(/ *; */).shift();
|
|
2388
|
-
};
|
|
2389
|
-
/**
|
|
2390
|
-
* Return header field parameters.
|
|
2391
|
-
*
|
|
2392
|
-
* @param {String} str
|
|
2393
|
-
* @return {Object}
|
|
2394
|
-
* @api private
|
|
2395
|
-
*/
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
exports.params = function (val) {
|
|
2399
|
-
var obj = {};
|
|
3911
|
+
exports.type = function (string_) {
|
|
3912
|
+
return string_.split(/ *; */).shift();
|
|
3913
|
+
};
|
|
2400
3914
|
|
|
2401
|
-
|
|
3915
|
+
exports.params = function (value) {
|
|
3916
|
+
var object = {};
|
|
3917
|
+
|
|
3918
|
+
var _iterator = _createForOfIteratorHelper(value.split(/ *; */)),
|
|
2402
3919
|
_step;
|
|
2403
3920
|
|
|
2404
3921
|
try {
|
|
2405
3922
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2406
|
-
var
|
|
2407
|
-
var parts =
|
|
3923
|
+
var string_ = _step.value;
|
|
3924
|
+
var parts = string_.split(/ *= */);
|
|
2408
3925
|
var key = parts.shift();
|
|
2409
3926
|
|
|
2410
|
-
var
|
|
3927
|
+
var _value = parts.shift();
|
|
2411
3928
|
|
|
2412
|
-
if (key &&
|
|
3929
|
+
if (key && _value) object[key] = _value;
|
|
2413
3930
|
}
|
|
2414
3931
|
} catch (err) {
|
|
2415
3932
|
_iterator.e(err);
|
|
@@ -2417,30 +3934,22 @@ exports.params = function (val) {
|
|
|
2417
3934
|
_iterator.f();
|
|
2418
3935
|
}
|
|
2419
3936
|
|
|
2420
|
-
return
|
|
3937
|
+
return object;
|
|
2421
3938
|
};
|
|
2422
|
-
/**
|
|
2423
|
-
* Parse Link header fields.
|
|
2424
|
-
*
|
|
2425
|
-
* @param {String} str
|
|
2426
|
-
* @return {Object}
|
|
2427
|
-
* @api private
|
|
2428
|
-
*/
|
|
2429
|
-
|
|
2430
3939
|
|
|
2431
|
-
exports.parseLinks = function (
|
|
2432
|
-
var
|
|
3940
|
+
exports.parseLinks = function (value) {
|
|
3941
|
+
var object = {};
|
|
2433
3942
|
|
|
2434
|
-
var _iterator2 = _createForOfIteratorHelper(
|
|
3943
|
+
var _iterator2 = _createForOfIteratorHelper(value.split(/ *, */)),
|
|
2435
3944
|
_step2;
|
|
2436
3945
|
|
|
2437
3946
|
try {
|
|
2438
3947
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2439
|
-
var
|
|
2440
|
-
var parts =
|
|
3948
|
+
var string_ = _step2.value;
|
|
3949
|
+
var parts = string_.split(/ *; */);
|
|
2441
3950
|
var url = parts[0].slice(1, -1);
|
|
2442
3951
|
var rel = parts[1].split(/ *= */)[1].slice(1, -1);
|
|
2443
|
-
|
|
3952
|
+
object[rel] = url;
|
|
2444
3953
|
}
|
|
2445
3954
|
} catch (err) {
|
|
2446
3955
|
_iterator2.e(err);
|
|
@@ -2448,22 +3957,14 @@ exports.parseLinks = function (val) {
|
|
|
2448
3957
|
_iterator2.f();
|
|
2449
3958
|
}
|
|
2450
3959
|
|
|
2451
|
-
return
|
|
3960
|
+
return object;
|
|
2452
3961
|
};
|
|
2453
|
-
/**
|
|
2454
|
-
* Strip content related fields from `header`.
|
|
2455
|
-
*
|
|
2456
|
-
* @param {Object} header
|
|
2457
|
-
* @return {Object} header
|
|
2458
|
-
* @api private
|
|
2459
|
-
*/
|
|
2460
|
-
|
|
2461
3962
|
|
|
2462
3963
|
exports.cleanHeader = function (header, changesOrigin) {
|
|
2463
3964
|
delete header['content-type'];
|
|
2464
3965
|
delete header['content-length'];
|
|
2465
3966
|
delete header['transfer-encoding'];
|
|
2466
|
-
delete header.host;
|
|
3967
|
+
delete header.host;
|
|
2467
3968
|
|
|
2468
3969
|
if (changesOrigin) {
|
|
2469
3970
|
delete header.authorization;
|
|
@@ -2473,5 +3974,5 @@ exports.cleanHeader = function (header, changesOrigin) {
|
|
|
2473
3974
|
return header;
|
|
2474
3975
|
};
|
|
2475
3976
|
|
|
2476
|
-
},{}]},{},[
|
|
3977
|
+
},{}]},{},[22])(22)
|
|
2477
3978
|
});
|