superagent 3.8.1 → 4.0.0-beta.5

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/superagent.js CHANGED
@@ -1,21 +1,26 @@
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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
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
+ "use strict";
3
+
2
4
  function Agent() {
3
5
  this._defaults = [];
4
6
  }
5
7
 
6
- ["use", "on", "once", "set", "query", "type", "accept", "auth", "withCredentials", "sortQuery", "retry", "ok", "redirects",
7
- "timeout", "buffer", "serialize", "parse", "ca", "key", "pfx", "cert"].forEach(function(fn) {
8
+ ["use", "on", "once", "set", "query", "type", "accept", "auth", "withCredentials", "sortQuery", "retry", "ok", "redirects", "timeout", "buffer", "serialize", "parse", "ca", "key", "pfx", "cert"].forEach(function (fn) {
8
9
  /** Default setting for all requests from this agent */
9
- Agent.prototype[fn] = function(/*varargs*/) {
10
- this._defaults.push({fn:fn, arguments:arguments});
10
+ Agent.prototype[fn] = function () {
11
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
12
+ args[_key] = arguments[_key];
13
+ }
14
+
15
+ this._defaults.push({ fn: fn, args: args });
11
16
  return this;
12
- }
17
+ };
13
18
  });
14
19
 
15
- Agent.prototype._setDefaults = function(req) {
16
- this._defaults.forEach(function(def) {
17
- req[def.fn].apply(req, def.arguments);
18
- });
20
+ Agent.prototype._setDefaults = function (req) {
21
+ this._defaults.forEach(function (def) {
22
+ req[def.fn].apply(req, def.args);
23
+ });
19
24
  };
20
25
 
21
26
  module.exports = Agent;
@@ -31,8 +36,10 @@ module.exports = Agent;
31
36
  * @api private
32
37
  */
33
38
 
39
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
40
+
34
41
  function isObject(obj) {
35
- return null !== obj && 'object' === typeof obj;
42
+ return null !== obj && 'object' === (typeof obj === 'undefined' ? 'undefined' : _typeof(obj));
36
43
  }
37
44
 
38
45
  module.exports = isObject;
@@ -43,6 +50,9 @@ module.exports = isObject;
43
50
  /**
44
51
  * Module of mixed-in functions shared between node and client code
45
52
  */
53
+
54
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
55
+
46
56
  var isObject = require('./is-object');
47
57
 
48
58
  /**
@@ -83,7 +93,7 @@ function mixin(obj) {
83
93
  * @api public
84
94
  */
85
95
 
86
- RequestBase.prototype.clearTimeout = function _clearTimeout(){
96
+ RequestBase.prototype.clearTimeout = function _clearTimeout() {
87
97
  clearTimeout(this._timer);
88
98
  clearTimeout(this._responseTimeoutTimer);
89
99
  delete this._timer;
@@ -100,7 +110,7 @@ RequestBase.prototype.clearTimeout = function _clearTimeout(){
100
110
  * @api public
101
111
  */
102
112
 
103
- RequestBase.prototype.parse = function parse(fn){
113
+ RequestBase.prototype.parse = function parse(fn) {
104
114
  this._parser = fn;
105
115
  return this;
106
116
  };
@@ -123,7 +133,7 @@ RequestBase.prototype.parse = function parse(fn){
123
133
  * @api public
124
134
  */
125
135
 
126
- RequestBase.prototype.responseType = function(val){
136
+ RequestBase.prototype.responseType = function (val) {
127
137
  this._responseType = val;
128
138
  return this;
129
139
  };
@@ -137,7 +147,7 @@ RequestBase.prototype.responseType = function(val){
137
147
  * @api public
138
148
  */
139
149
 
140
- RequestBase.prototype.serialize = function serialize(fn){
150
+ RequestBase.prototype.serialize = function serialize(fn) {
141
151
  this._serializer = fn;
142
152
  return this;
143
153
  };
@@ -155,15 +165,15 @@ RequestBase.prototype.serialize = function serialize(fn){
155
165
  * @api public
156
166
  */
157
167
 
158
- RequestBase.prototype.timeout = function timeout(options){
159
- if (!options || 'object' !== typeof options) {
168
+ RequestBase.prototype.timeout = function timeout(options) {
169
+ if (!options || 'object' !== (typeof options === 'undefined' ? 'undefined' : _typeof(options))) {
160
170
  this._timeout = options;
161
171
  this._responseTimeout = 0;
162
172
  return this;
163
173
  }
164
174
 
165
- for(var option in options) {
166
- switch(option) {
175
+ for (var option in options) {
176
+ switch (option) {
167
177
  case 'deadline':
168
178
  this._timeout = options.deadline;
169
179
  break;
@@ -188,7 +198,7 @@ RequestBase.prototype.timeout = function timeout(options){
188
198
  * @api public
189
199
  */
190
200
 
191
- RequestBase.prototype.retry = function retry(count, fn){
201
+ RequestBase.prototype.retry = function retry(count, fn) {
192
202
  // Default to 1 if no count passed or true
193
203
  if (arguments.length === 0 || count === true) count = 1;
194
204
  if (count <= 0) count = 0;
@@ -198,12 +208,7 @@ RequestBase.prototype.retry = function retry(count, fn){
198
208
  return this;
199
209
  };
200
210
 
201
- var ERROR_CODES = [
202
- 'ECONNRESET',
203
- 'ETIMEDOUT',
204
- 'EADDRINFO',
205
- 'ESOCKETTIMEDOUT'
206
- ];
211
+ var ERROR_CODES = ['ECONNRESET', 'ETIMEDOUT', 'EADDRINFO', 'ESOCKETTIMEDOUT'];
207
212
 
208
213
  /**
209
214
  * Determine if a request should be retried.
@@ -213,7 +218,7 @@ var ERROR_CODES = [
213
218
  * @param {Response} [res]
214
219
  * @returns {Boolean}
215
220
  */
216
- RequestBase.prototype._shouldRetry = function(err, res) {
221
+ RequestBase.prototype._shouldRetry = function (err, res) {
217
222
  if (!this._maxRetries || this._retries++ >= this._maxRetries) {
218
223
  return false;
219
224
  }
@@ -223,7 +228,7 @@ RequestBase.prototype._shouldRetry = function(err, res) {
223
228
  if (override === true) return true;
224
229
  if (override === false) return false;
225
230
  // undefined falls back to defaults
226
- } catch(e) {
231
+ } catch (e) {
227
232
  console.error(e);
228
233
  }
229
234
  }
@@ -244,7 +249,7 @@ RequestBase.prototype._shouldRetry = function(err, res) {
244
249
  * @api private
245
250
  */
246
251
 
247
- RequestBase.prototype._retry = function() {
252
+ RequestBase.prototype._retry = function () {
248
253
 
249
254
  this.clearTimeout();
250
255
 
@@ -274,17 +279,17 @@ RequestBase.prototype.then = function then(resolve, reject) {
274
279
  if (this._endCalled) {
275
280
  console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises");
276
281
  }
277
- this._fullfilledPromise = new Promise(function(innerResolve, innerReject) {
278
- self.end(function(err, res) {
279
- if (err) innerReject(err);
280
- else innerResolve(res);
282
+ this._fullfilledPromise = new Promise(function (innerResolve, innerReject) {
283
+ self.on('error', innerReject);
284
+ self.end(function (err, res) {
285
+ if (err) innerReject(err);else innerResolve(res);
281
286
  });
282
287
  });
283
288
  }
284
289
  return this._fullfilledPromise.then(resolve, reject);
285
290
  };
286
291
 
287
- RequestBase.prototype.catch = function(cb) {
292
+ RequestBase.prototype['catch'] = function (cb) {
288
293
  return this.then(undefined, cb);
289
294
  };
290
295
 
@@ -297,13 +302,13 @@ RequestBase.prototype.use = function use(fn) {
297
302
  return this;
298
303
  };
299
304
 
300
- RequestBase.prototype.ok = function(cb) {
305
+ RequestBase.prototype.ok = function (cb) {
301
306
  if ('function' !== typeof cb) throw Error("Callback required");
302
307
  this._okCallback = cb;
303
308
  return this;
304
309
  };
305
310
 
306
- RequestBase.prototype._isResponseOK = function(res) {
311
+ RequestBase.prototype._isResponseOK = function (res) {
307
312
  if (!res) {
308
313
  return false;
309
314
  }
@@ -324,7 +329,7 @@ RequestBase.prototype._isResponseOK = function(res) {
324
329
  * @api public
325
330
  */
326
331
 
327
- RequestBase.prototype.get = function(field){
332
+ RequestBase.prototype.get = function (field) {
328
333
  return this._header[field.toLowerCase()];
329
334
  };
330
335
 
@@ -363,7 +368,7 @@ RequestBase.prototype.getHeader = RequestBase.prototype.get;
363
368
  * @api public
364
369
  */
365
370
 
366
- RequestBase.prototype.set = function(field, val){
371
+ RequestBase.prototype.set = function (field, val) {
367
372
  if (isObject(field)) {
368
373
  for (var key in field) {
369
374
  this.set(key, field[key]);
@@ -387,7 +392,7 @@ RequestBase.prototype.set = function(field, val){
387
392
  *
388
393
  * @param {String} field
389
394
  */
390
- RequestBase.prototype.unset = function(field){
395
+ RequestBase.prototype.unset = function (field) {
391
396
  delete this._header[field.toLowerCase()];
392
397
  delete this.header[field];
393
398
  return this;
@@ -412,14 +417,14 @@ RequestBase.prototype.unset = function(field){
412
417
  * @return {Request} for chaining
413
418
  * @api public
414
419
  */
415
- RequestBase.prototype.field = function(name, val) {
420
+ RequestBase.prototype.field = function (name, val) {
416
421
  // name should be either a string or an object.
417
422
  if (null === name || undefined === name) {
418
423
  throw new Error('.field(name, val) name can not be empty');
419
424
  }
420
425
 
421
426
  if (this._data) {
422
- console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");
427
+ throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");
423
428
  }
424
429
 
425
430
  if (isObject(name)) {
@@ -453,7 +458,7 @@ RequestBase.prototype.field = function(name, val) {
453
458
  * @return {Request}
454
459
  * @api public
455
460
  */
456
- RequestBase.prototype.abort = function(){
461
+ RequestBase.prototype.abort = function () {
457
462
  if (this._aborted) {
458
463
  return this;
459
464
  }
@@ -465,7 +470,7 @@ RequestBase.prototype.abort = function(){
465
470
  return this;
466
471
  };
467
472
 
468
- RequestBase.prototype._auth = function(user, pass, options, base64Encoder) {
473
+ RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
469
474
  switch (options.type) {
470
475
  case 'basic':
471
476
  this.set('Authorization', 'Basic ' + base64Encoder(user + ':' + pass));
@@ -476,7 +481,8 @@ RequestBase.prototype._auth = function(user, pass, options, base64Encoder) {
476
481
  this.password = pass;
477
482
  break;
478
483
 
479
- case 'bearer': // usage would be .auth(accessToken, { type: 'bearer' })
484
+ case 'bearer':
485
+ // usage would be .auth(accessToken, { type: 'bearer' })
480
486
  this.set('Authorization', 'Bearer ' + user);
481
487
  break;
482
488
  }
@@ -494,7 +500,7 @@ RequestBase.prototype._auth = function(user, pass, options, base64Encoder) {
494
500
  * @api public
495
501
  */
496
502
 
497
- RequestBase.prototype.withCredentials = function(on) {
503
+ RequestBase.prototype.withCredentials = function (on) {
498
504
  // This is browser-only functionality. Node side is no-op.
499
505
  if (on == undefined) on = true;
500
506
  this._withCredentials = on;
@@ -509,7 +515,7 @@ RequestBase.prototype.withCredentials = function(on) {
509
515
  * @api public
510
516
  */
511
517
 
512
- RequestBase.prototype.redirects = function(n){
518
+ RequestBase.prototype.redirects = function (n) {
513
519
  this._maxRedirects = n;
514
520
  return this;
515
521
  };
@@ -521,7 +527,7 @@ RequestBase.prototype.redirects = function(n){
521
527
  * @param {Number} n
522
528
  * @return {Request} for chaining
523
529
  */
524
- RequestBase.prototype.maxResponseSize = function(n){
530
+ RequestBase.prototype.maxResponseSize = function (n) {
525
531
  if ('number' !== typeof n) {
526
532
  throw TypeError("Invalid argument");
527
533
  }
@@ -538,12 +544,12 @@ RequestBase.prototype.maxResponseSize = function(n){
538
544
  * @api public
539
545
  */
540
546
 
541
- RequestBase.prototype.toJSON = function() {
547
+ RequestBase.prototype.toJSON = function () {
542
548
  return {
543
549
  method: this.method,
544
550
  url: this.url,
545
551
  data: this._data,
546
- headers: this._header,
552
+ headers: this._header
547
553
  };
548
554
  };
549
555
 
@@ -587,12 +593,12 @@ RequestBase.prototype.toJSON = function() {
587
593
  * @api public
588
594
  */
589
595
 
590
- RequestBase.prototype.send = function(data){
596
+ RequestBase.prototype.send = function (data) {
591
597
  var isObj = isObject(data);
592
598
  var type = this._header['content-type'];
593
599
 
594
600
  if (this._formData) {
595
- console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
601
+ throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
596
602
  }
597
603
 
598
604
  if (isObj && !this._data) {
@@ -615,9 +621,7 @@ RequestBase.prototype.send = function(data){
615
621
  if (!type) this.type('form');
616
622
  type = this._header['content-type'];
617
623
  if ('application/x-www-form-urlencoded' == type) {
618
- this._data = this._data
619
- ? this._data + '&' + data
620
- : data;
624
+ this._data = this._data ? this._data + '&' + data : data;
621
625
  } else {
622
626
  this._data = (this._data || '') + data;
623
627
  }
@@ -662,7 +666,7 @@ RequestBase.prototype.send = function(data){
662
666
  * @api public
663
667
  */
664
668
 
665
- RequestBase.prototype.sortQuery = function(sort) {
669
+ RequestBase.prototype.sortQuery = function (sort) {
666
670
  // _sort default to true but otherwise can be a function or boolean
667
671
  this._sort = typeof sort === 'undefined' ? true : sort;
668
672
  return this;
@@ -673,7 +677,7 @@ RequestBase.prototype.sortQuery = function(sort) {
673
677
  *
674
678
  * @api private
675
679
  */
676
- RequestBase.prototype._finalizeQueryString = function(){
680
+ RequestBase.prototype._finalizeQueryString = function () {
677
681
  var query = this._query.join('&');
678
682
  if (query) {
679
683
  this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query;
@@ -695,7 +699,9 @@ RequestBase.prototype._finalizeQueryString = function(){
695
699
  };
696
700
 
697
701
  // For backwards compat only
698
- RequestBase.prototype._appendQueryString = function() {console.trace("Unsupported");}
702
+ RequestBase.prototype._appendQueryString = function () {
703
+ console.trace("Unsupported");
704
+ };
699
705
 
700
706
  /**
701
707
  * Invoke callback with timeout error.
@@ -703,7 +709,7 @@ RequestBase.prototype._appendQueryString = function() {console.trace("Unsupporte
703
709
  * @api private
704
710
  */
705
711
 
706
- RequestBase.prototype._timeoutError = function(reason, timeout, errno){
712
+ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
707
713
  if (this._aborted) {
708
714
  return;
709
715
  }
@@ -716,18 +722,18 @@ RequestBase.prototype._timeoutError = function(reason, timeout, errno){
716
722
  this.callback(err);
717
723
  };
718
724
 
719
- RequestBase.prototype._setTimeouts = function() {
725
+ RequestBase.prototype._setTimeouts = function () {
720
726
  var self = this;
721
727
 
722
728
  // deadline
723
729
  if (this._timeout && !this._timer) {
724
- this._timer = setTimeout(function(){
730
+ this._timer = setTimeout(function () {
725
731
  self._timeoutError('Timeout of ', self._timeout, 'ETIME');
726
732
  }, this._timeout);
727
733
  }
728
734
  // response timeout
729
735
  if (this._responseTimeout && !this._responseTimeoutTimer) {
730
- this._responseTimeoutTimer = setTimeout(function(){
736
+ this._responseTimeoutTimer = setTimeout(function () {
731
737
  self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
732
738
  }, this._responseTimeout);
733
739
  }
@@ -781,7 +787,7 @@ function mixin(obj) {
781
787
  * @api public
782
788
  */
783
789
 
784
- ResponseBase.prototype.get = function(field) {
790
+ ResponseBase.prototype.get = function (field) {
785
791
  return this.header[field.toLowerCase()];
786
792
  };
787
793
 
@@ -797,28 +803,28 @@ ResponseBase.prototype.get = function(field) {
797
803
  * @api private
798
804
  */
799
805
 
800
- ResponseBase.prototype._setHeaderProperties = function(header){
801
- // TODO: moar!
802
- // TODO: make this a util
803
-
804
- // content-type
805
- var ct = header['content-type'] || '';
806
- this.type = utils.type(ct);
806
+ ResponseBase.prototype._setHeaderProperties = function (header) {
807
+ // TODO: moar!
808
+ // TODO: make this a util
807
809
 
808
- // params
809
- var params = utils.params(ct);
810
- for (var key in params) this[key] = params[key];
810
+ // content-type
811
+ var ct = header['content-type'] || '';
812
+ this.type = utils.type(ct);
811
813
 
812
- this.links = {};
814
+ // params
815
+ var params = utils.params(ct);
816
+ for (var key in params) {
817
+ this[key] = params[key];
818
+ }this.links = {};
813
819
 
814
- // links
815
- try {
816
- if (header.link) {
817
- this.links = utils.parseLinks(header.link);
818
- }
819
- } catch (err) {
820
- // ignore
820
+ // links
821
+ try {
822
+ if (header.link) {
823
+ this.links = utils.parseLinks(header.link);
821
824
  }
825
+ } catch (err) {
826
+ // ignore
827
+ }
822
828
  };
823
829
 
824
830
  /**
@@ -842,31 +848,31 @@ ResponseBase.prototype._setHeaderProperties = function(header){
842
848
  * @api private
843
849
  */
844
850
 
845
- ResponseBase.prototype._setStatusProperties = function(status){
846
- var type = status / 100 | 0;
847
-
848
- // status / class
849
- this.status = this.statusCode = status;
850
- this.statusType = type;
851
-
852
- // basics
853
- this.info = 1 == type;
854
- this.ok = 2 == type;
855
- this.redirect = 3 == type;
856
- this.clientError = 4 == type;
857
- this.serverError = 5 == type;
858
- this.error = (4 == type || 5 == type)
859
- ? this.toError()
860
- : false;
861
-
862
- // sugar
863
- this.accepted = 202 == status;
864
- this.noContent = 204 == status;
865
- this.badRequest = 400 == status;
866
- this.unauthorized = 401 == status;
867
- this.notAcceptable = 406 == status;
868
- this.forbidden = 403 == status;
869
- this.notFound = 404 == status;
851
+ ResponseBase.prototype._setStatusProperties = function (status) {
852
+ var type = status / 100 | 0;
853
+
854
+ // status / class
855
+ this.status = this.statusCode = status;
856
+ this.statusType = type;
857
+
858
+ // basics
859
+ this.info = 1 == type;
860
+ this.ok = 2 == type;
861
+ this.redirect = 3 == type;
862
+ this.clientError = 4 == type;
863
+ this.serverError = 5 == type;
864
+ this.error = 4 == type || 5 == type ? this.toError() : false;
865
+
866
+ // sugar
867
+ this.created = 201 == status;
868
+ this.accepted = 202 == status;
869
+ this.noContent = 204 == status;
870
+ this.badRequest = 400 == status;
871
+ this.unauthorized = 401 == status;
872
+ this.notAcceptable = 406 == status;
873
+ this.forbidden = 403 == status;
874
+ this.notFound = 404 == status;
875
+ this.unprocessableEntity = 422 == status;
870
876
  };
871
877
 
872
878
  },{"./utils":5}],5:[function(require,module,exports){
@@ -880,7 +886,7 @@ ResponseBase.prototype._setStatusProperties = function(status){
880
886
  * @api private
881
887
  */
882
888
 
883
- exports.type = function(str){
889
+ exports.type = function (str) {
884
890
  return str.split(/ *; */).shift();
885
891
  };
886
892
 
@@ -892,8 +898,8 @@ exports.type = function(str){
892
898
  * @api private
893
899
  */
894
900
 
895
- exports.params = function(str){
896
- return str.split(/ *; */).reduce(function(obj, str){
901
+ exports.params = function (str) {
902
+ return str.split(/ *; */).reduce(function (obj, str) {
897
903
  var parts = str.split(/ *= */);
898
904
  var key = parts.shift();
899
905
  var val = parts.shift();
@@ -911,8 +917,8 @@ exports.params = function(str){
911
917
  * @api private
912
918
  */
913
919
 
914
- exports.parseLinks = function(str){
915
- return str.split(/ *, */).reduce(function(obj, str){
920
+ exports.parseLinks = function (str) {
921
+ return str.split(/ *, */).reduce(function (obj, str) {
916
922
  var parts = str.split(/ *; */);
917
923
  var url = parts[0].slice(1, -1);
918
924
  var rel = parts[1].split(/ *= */)[1].slice(1, -1);
@@ -929,7 +935,7 @@ exports.parseLinks = function(str){
929
935
  * @api private
930
936
  */
931
937
 
932
- exports.cleanHeader = function(header, changesOrigin){
938
+ exports.cleanHeader = function (header, changesOrigin) {
933
939
  delete header['content-type'];
934
940
  delete header['content-length'];
935
941
  delete header['transfer-encoding'];
@@ -1108,18 +1114,25 @@ Emitter.prototype.hasListeners = function(event){
1108
1114
  };
1109
1115
 
1110
1116
  },{}],7:[function(require,module,exports){
1117
+ 'use strict';
1118
+
1119
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1120
+
1111
1121
  /**
1112
1122
  * Root reference for iframes.
1113
1123
  */
1114
1124
 
1115
- var root;
1116
- if (typeof window !== 'undefined') { // Browser window
1125
+ var root = void 0;
1126
+ if (typeof window !== 'undefined') {
1127
+ // Browser window
1117
1128
  root = window;
1118
- } else if (typeof self !== 'undefined') { // Web Worker
1129
+ } else if (typeof self !== 'undefined') {
1130
+ // Web Worker
1119
1131
  root = self;
1120
- } else { // Other environments
1132
+ } else {
1133
+ // Other environments
1121
1134
  console.warn("Using browser-only version of superagent in non-browser environment");
1122
- root = this;
1135
+ root = undefined;
1123
1136
  }
1124
1137
 
1125
1138
  var Emitter = require('component-emitter');
@@ -1132,13 +1145,13 @@ var Agent = require('./agent-base');
1132
1145
  * Noop.
1133
1146
  */
1134
1147
 
1135
- function noop(){};
1148
+ function noop() {};
1136
1149
 
1137
1150
  /**
1138
1151
  * Expose `request`.
1139
1152
  */
1140
1153
 
1141
- var request = exports = module.exports = function(method, url) {
1154
+ var request = exports = module.exports = function (method, url) {
1142
1155
  // callback
1143
1156
  if ('function' == typeof url) {
1144
1157
  return new exports.Request('GET', method).end(url);
@@ -1150,7 +1163,7 @@ var request = exports = module.exports = function(method, url) {
1150
1163
  }
1151
1164
 
1152
1165
  return new exports.Request(method, url);
1153
- }
1166
+ };
1154
1167
 
1155
1168
  exports.Request = Request;
1156
1169
 
@@ -1159,15 +1172,21 @@ exports.Request = Request;
1159
1172
  */
1160
1173
 
1161
1174
  request.getXHR = function () {
1162
- if (root.XMLHttpRequest
1163
- && (!root.location || 'file:' != root.location.protocol
1164
- || !root.ActiveXObject)) {
1165
- return new XMLHttpRequest;
1175
+ if (root.XMLHttpRequest && (!root.location || 'file:' != root.location.protocol || !root.ActiveXObject)) {
1176
+ return new XMLHttpRequest();
1166
1177
  } else {
1167
- try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
1168
- try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}
1169
- try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}
1170
- try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
1178
+ try {
1179
+ return new ActiveXObject('Microsoft.XMLHTTP');
1180
+ } catch (e) {}
1181
+ try {
1182
+ return new ActiveXObject('Msxml2.XMLHTTP.6.0');
1183
+ } catch (e) {}
1184
+ try {
1185
+ return new ActiveXObject('Msxml2.XMLHTTP.3.0');
1186
+ } catch (e) {}
1187
+ try {
1188
+ return new ActiveXObject('Msxml2.XMLHTTP');
1189
+ } catch (e) {}
1171
1190
  }
1172
1191
  throw Error("Browser-only version of superagent could not find XHR");
1173
1192
  };
@@ -1180,9 +1199,11 @@ request.getXHR = function () {
1180
1199
  * @api private
1181
1200
  */
1182
1201
 
1183
- var trim = ''.trim
1184
- ? function(s) { return s.trim(); }
1185
- : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
1202
+ var trim = ''.trim ? function (s) {
1203
+ return s.trim();
1204
+ } : function (s) {
1205
+ return s.replace(/(^\s*|\s*$)/g, '');
1206
+ };
1186
1207
 
1187
1208
  /**
1188
1209
  * Serialize the given `obj`.
@@ -1213,16 +1234,15 @@ function serialize(obj) {
1213
1234
  function pushEncodedKeyValuePair(pairs, key, val) {
1214
1235
  if (val != null) {
1215
1236
  if (Array.isArray(val)) {
1216
- val.forEach(function(v) {
1237
+ val.forEach(function (v) {
1217
1238
  pushEncodedKeyValuePair(pairs, key, v);
1218
1239
  });
1219
1240
  } else if (isObject(val)) {
1220
- for(var subkey in val) {
1241
+ for (var subkey in val) {
1221
1242
  pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]);
1222
1243
  }
1223
1244
  } else {
1224
- pairs.push(encodeURIComponent(key)
1225
- + '=' + encodeURIComponent(val));
1245
+ pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));
1226
1246
  }
1227
1247
  } else if (val === null) {
1228
1248
  pairs.push(encodeURIComponent(key));
@@ -1246,8 +1266,8 @@ request.serializeObject = serialize;
1246
1266
  function parseString(str) {
1247
1267
  var obj = {};
1248
1268
  var pairs = str.split('&');
1249
- var pair;
1250
- var pos;
1269
+ var pair = void 0;
1270
+ var pos = void 0;
1251
1271
 
1252
1272
  for (var i = 0, len = pairs.length; i < len; ++i) {
1253
1273
  pair = pairs[i];
@@ -1255,8 +1275,7 @@ function parseString(str) {
1255
1275
  if (pos == -1) {
1256
1276
  obj[decodeURIComponent(pair)] = '';
1257
1277
  } else {
1258
- obj[decodeURIComponent(pair.slice(0, pos))] =
1259
- decodeURIComponent(pair.slice(pos + 1));
1278
+ obj[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1));
1260
1279
  }
1261
1280
  }
1262
1281
 
@@ -1296,7 +1315,7 @@ request.types = {
1296
1315
 
1297
1316
  request.serialize = {
1298
1317
  'application/x-www-form-urlencoded': serialize,
1299
- 'application/json': JSON.stringify,
1318
+ 'application/json': JSON.stringify
1300
1319
  };
1301
1320
 
1302
1321
  /**
@@ -1310,7 +1329,7 @@ request.serialize = {
1310
1329
 
1311
1330
  request.parse = {
1312
1331
  'application/x-www-form-urlencoded': parseString,
1313
- 'application/json': JSON.parse,
1332
+ 'application/json': JSON.parse
1314
1333
  };
1315
1334
 
1316
1335
  /**
@@ -1325,15 +1344,16 @@ request.parse = {
1325
1344
  function parseHeader(str) {
1326
1345
  var lines = str.split(/\r?\n/);
1327
1346
  var fields = {};
1328
- var index;
1329
- var line;
1330
- var field;
1331
- var val;
1347
+ var index = void 0;
1348
+ var line = void 0;
1349
+ var field = void 0;
1350
+ var val = void 0;
1332
1351
 
1333
1352
  for (var i = 0, len = lines.length; i < len; ++i) {
1334
1353
  line = lines[i];
1335
1354
  index = line.indexOf(':');
1336
- if (index === -1) { // could be empty line, just skip it
1355
+ if (index === -1) {
1356
+ // could be empty line, just skip it
1337
1357
  continue;
1338
1358
  }
1339
1359
  field = line.slice(0, index).toLowerCase();
@@ -1353,7 +1373,10 @@ function parseHeader(str) {
1353
1373
  */
1354
1374
 
1355
1375
  function isJSON(mime) {
1356
- return /[\/+]json\b/.test(mime);
1376
+ // should match /json or +json
1377
+ // but not /json-seq
1378
+ return (/[\/+]json($|[^-\w])/.test(mime)
1379
+ );
1357
1380
  }
1358
1381
 
1359
1382
  /**
@@ -1406,9 +1429,7 @@ function Response(req) {
1406
1429
  this.req = req;
1407
1430
  this.xhr = this.req.xhr;
1408
1431
  // responseText is accessible only if responseType is '' or 'text' and on older browsers
1409
- this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined')
1410
- ? this.xhr.responseText
1411
- : null;
1432
+ this.text = this.req.method != 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;
1412
1433
  this.statusText = this.req.xhr.statusText;
1413
1434
  var status = this.xhr.status;
1414
1435
  // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
@@ -1426,9 +1447,7 @@ function Response(req) {
1426
1447
  if (null === this.text && req._responseType) {
1427
1448
  this.body = this.xhr.response;
1428
1449
  } else {
1429
- this.body = this.req.method != 'HEAD'
1430
- ? this._parseBody(this.text ? this.text : this.xhr.response)
1431
- : null;
1450
+ this.body = this.req.method != 'HEAD' ? this._parseBody(this.text ? this.text : this.xhr.response) : null;
1432
1451
  }
1433
1452
  }
1434
1453
 
@@ -1445,7 +1464,7 @@ ResponseBase(Response.prototype);
1445
1464
  * @api private
1446
1465
  */
1447
1466
 
1448
- Response.prototype._parseBody = function(str) {
1467
+ Response.prototype._parseBody = function (str) {
1449
1468
  var parse = request.parse[this.type];
1450
1469
  if (this.req._parser) {
1451
1470
  return this.req._parser(this, str);
@@ -1453,9 +1472,7 @@ Response.prototype._parseBody = function(str) {
1453
1472
  if (!parse && isJSON(this.type)) {
1454
1473
  parse = request.parse['application/json'];
1455
1474
  }
1456
- return parse && str && (str.length || str instanceof Object)
1457
- ? parse(str)
1458
- : null;
1475
+ return parse && str && (str.length || str instanceof Object) ? parse(str) : null;
1459
1476
  };
1460
1477
 
1461
1478
  /**
@@ -1465,7 +1482,7 @@ Response.prototype._parseBody = function(str) {
1465
1482
  * @api public
1466
1483
  */
1467
1484
 
1468
- Response.prototype.toError = function(){
1485
+ Response.prototype.toError = function () {
1469
1486
  var req = this.req;
1470
1487
  var method = req.method;
1471
1488
  var url = req.url;
@@ -1500,13 +1517,13 @@ function Request(method, url) {
1500
1517
  this.url = url;
1501
1518
  this.header = {}; // preserves header name case
1502
1519
  this._header = {}; // coerces header names to lowercase
1503
- this.on('end', function(){
1520
+ this.on('end', function () {
1504
1521
  var err = null;
1505
1522
  var res = null;
1506
1523
 
1507
1524
  try {
1508
1525
  res = new Response(self);
1509
- } catch(e) {
1526
+ } catch (e) {
1510
1527
  err = new Error('Parser is unable to parse the response');
1511
1528
  err.parse = true;
1512
1529
  err.original = e;
@@ -1527,12 +1544,12 @@ function Request(method, url) {
1527
1544
 
1528
1545
  self.emit('response', res);
1529
1546
 
1530
- var new_err;
1547
+ var new_err = void 0;
1531
1548
  try {
1532
1549
  if (!self._isResponseOK(res)) {
1533
1550
  new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
1534
1551
  }
1535
- } catch(custom_err) {
1552
+ } catch (custom_err) {
1536
1553
  new_err = custom_err; // ok() callback can throw
1537
1554
  }
1538
1555
 
@@ -1577,7 +1594,7 @@ RequestBase(Request.prototype);
1577
1594
  * @api public
1578
1595
  */
1579
1596
 
1580
- Request.prototype.type = function(type){
1597
+ Request.prototype.type = function (type) {
1581
1598
  this.set('Content-Type', request.types[type] || type);
1582
1599
  return this;
1583
1600
  };
@@ -1602,7 +1619,7 @@ Request.prototype.type = function(type){
1602
1619
  * @api public
1603
1620
  */
1604
1621
 
1605
- Request.prototype.accept = function(type){
1622
+ Request.prototype.accept = function (type) {
1606
1623
  this.set('Accept', request.types[type] || type);
1607
1624
  return this;
1608
1625
  };
@@ -1617,19 +1634,20 @@ Request.prototype.accept = function(type){
1617
1634
  * @api public
1618
1635
  */
1619
1636
 
1620
- Request.prototype.auth = function(user, pass, options){
1637
+ Request.prototype.auth = function (user, pass, options) {
1621
1638
  if (1 === arguments.length) pass = '';
1622
- if (typeof pass === 'object' && pass !== null) { // pass is optional and can be replaced with options
1639
+ if ((typeof pass === 'undefined' ? 'undefined' : _typeof(pass)) === 'object' && pass !== null) {
1640
+ // pass is optional and can be replaced with options
1623
1641
  options = pass;
1624
1642
  pass = '';
1625
1643
  }
1626
1644
  if (!options) {
1627
1645
  options = {
1628
- type: 'function' === typeof btoa ? 'basic' : 'auto',
1646
+ type: 'function' === typeof btoa ? 'basic' : 'auto'
1629
1647
  };
1630
1648
  }
1631
1649
 
1632
- var encoder = function(string) {
1650
+ var encoder = function encoder(string) {
1633
1651
  if ('function' === typeof btoa) {
1634
1652
  return btoa(string);
1635
1653
  }
@@ -1653,7 +1671,7 @@ Request.prototype.auth = function(user, pass, options){
1653
1671
  * @api public
1654
1672
  */
1655
1673
 
1656
- Request.prototype.query = function(val){
1674
+ Request.prototype.query = function (val) {
1657
1675
  if ('string' != typeof val) val = serialize(val);
1658
1676
  if (val) this._query.push(val);
1659
1677
  return this;
@@ -1676,7 +1694,7 @@ Request.prototype.query = function(val){
1676
1694
  * @api public
1677
1695
  */
1678
1696
 
1679
- Request.prototype.attach = function(field, file, options){
1697
+ Request.prototype.attach = function (field, file, options) {
1680
1698
  if (file) {
1681
1699
  if (this._data) {
1682
1700
  throw Error("superagent can't mix .send() and .attach()");
@@ -1687,7 +1705,7 @@ Request.prototype.attach = function(field, file, options){
1687
1705
  return this;
1688
1706
  };
1689
1707
 
1690
- Request.prototype._getFormData = function(){
1708
+ Request.prototype._getFormData = function () {
1691
1709
  if (!this._formData) {
1692
1710
  this._formData = new root.FormData();
1693
1711
  }
@@ -1703,7 +1721,7 @@ Request.prototype._getFormData = function(){
1703
1721
  * @api private
1704
1722
  */
1705
1723
 
1706
- Request.prototype.callback = function(err, res){
1724
+ Request.prototype.callback = function (err, res) {
1707
1725
  if (this._shouldRetry(err, res)) {
1708
1726
  return this._retry();
1709
1727
  }
@@ -1725,7 +1743,7 @@ Request.prototype.callback = function(err, res){
1725
1743
  * @api private
1726
1744
  */
1727
1745
 
1728
- Request.prototype.crossDomainError = function(){
1746
+ Request.prototype.crossDomainError = function () {
1729
1747
  var err = 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.');
1730
1748
  err.crossDomain = true;
1731
1749
 
@@ -1737,13 +1755,13 @@ Request.prototype.crossDomainError = function(){
1737
1755
  };
1738
1756
 
1739
1757
  // This only warns, because the request is still likely to work
1740
- Request.prototype.buffer = Request.prototype.ca = Request.prototype.agent = function(){
1758
+ Request.prototype.buffer = Request.prototype.ca = Request.prototype.agent = function () {
1741
1759
  console.warn("This is not supported in browser version of superagent");
1742
1760
  return this;
1743
1761
  };
1744
1762
 
1745
1763
  // This throws, because it can't send/receive data as expected
1746
- Request.prototype.pipe = Request.prototype.write = function(){
1764
+ Request.prototype.pipe = Request.prototype.write = function () {
1747
1765
  throw Error("Streaming is not supported in browser version of superagent");
1748
1766
  };
1749
1767
 
@@ -1757,8 +1775,8 @@ Request.prototype.pipe = Request.prototype.write = function(){
1757
1775
  */
1758
1776
  Request.prototype._isHost = function _isHost(obj) {
1759
1777
  // Native objects stringify to [object File], [object Blob], [object FormData], etc.
1760
- return obj && 'object' === typeof obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]';
1761
- }
1778
+ return obj && 'object' === (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]';
1779
+ };
1762
1780
 
1763
1781
  /**
1764
1782
  * Initiate request, invoking callback `fn(res)`
@@ -1769,7 +1787,7 @@ Request.prototype._isHost = function _isHost(obj) {
1769
1787
  * @api public
1770
1788
  */
1771
1789
 
1772
- Request.prototype.end = function(fn){
1790
+ Request.prototype.end = function (fn) {
1773
1791
  if (this._endCalled) {
1774
1792
  console.warn("Warning: .end() was called twice. This is not supported in superagent");
1775
1793
  }
@@ -1781,18 +1799,20 @@ Request.prototype.end = function(fn){
1781
1799
  // querystring
1782
1800
  this._finalizeQueryString();
1783
1801
 
1784
- return this._end();
1802
+ this._end();
1785
1803
  };
1786
1804
 
1787
- Request.prototype._end = function() {
1805
+ Request.prototype._end = function () {
1806
+ if (this._aborted) return this.callback(Error("The request has been aborted even before .end() was called"));
1807
+
1788
1808
  var self = this;
1789
- var xhr = (this.xhr = request.getXHR());
1809
+ var xhr = this.xhr = request.getXHR();
1790
1810
  var data = this._formData || this._data;
1791
1811
 
1792
1812
  this._setTimeouts();
1793
1813
 
1794
1814
  // state change
1795
- xhr.onreadystatechange = function(){
1815
+ xhr.onreadystatechange = function () {
1796
1816
  var readyState = xhr.readyState;
1797
1817
  if (readyState >= 2 && self._responseTimeoutTimer) {
1798
1818
  clearTimeout(self._responseTimeoutTimer);
@@ -1803,8 +1823,12 @@ Request.prototype._end = function() {
1803
1823
 
1804
1824
  // In IE9, reads to any property (e.g. status) off of an aborted XHR will
1805
1825
  // result in the error "Could not complete the operation due to error c00c023f"
1806
- var status;
1807
- try { status = xhr.status } catch(e) { status = 0; }
1826
+ var status = void 0;
1827
+ try {
1828
+ status = xhr.status;
1829
+ } catch (e) {
1830
+ status = 0;
1831
+ }
1808
1832
 
1809
1833
  if (!status) {
1810
1834
  if (self.timedout || self._aborted) return;
@@ -1814,7 +1838,7 @@ Request.prototype._end = function() {
1814
1838
  };
1815
1839
 
1816
1840
  // progress
1817
- var handleProgress = function(direction, e) {
1841
+ var handleProgress = function handleProgress(direction, e) {
1818
1842
  if (e.total > 0) {
1819
1843
  e.percent = e.loaded / e.total * 100;
1820
1844
  }
@@ -1827,7 +1851,7 @@ Request.prototype._end = function() {
1827
1851
  if (xhr.upload) {
1828
1852
  xhr.upload.onprogress = handleProgress.bind(null, 'upload');
1829
1853
  }
1830
- } catch(e) {
1854
+ } catch (e) {
1831
1855
  // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.
1832
1856
  // Reported here:
1833
1857
  // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context
@@ -1853,19 +1877,18 @@ Request.prototype._end = function() {
1853
1877
  if (!this._formData && 'GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) {
1854
1878
  // serialize stuff
1855
1879
  var contentType = this._header['content-type'];
1856
- var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
1857
- if (!serialize && isJSON(contentType)) {
1858
- serialize = request.serialize['application/json'];
1880
+ var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
1881
+ if (!_serialize && isJSON(contentType)) {
1882
+ _serialize = request.serialize['application/json'];
1859
1883
  }
1860
- if (serialize) data = serialize(data);
1884
+ if (_serialize) data = _serialize(data);
1861
1885
  }
1862
1886
 
1863
1887
  // set header fields
1864
1888
  for (var field in this.header) {
1865
1889
  if (null == this.header[field]) continue;
1866
1890
 
1867
- if (this.header.hasOwnProperty(field))
1868
- xhr.setRequestHeader(field, this.header[field]);
1891
+ if (this.header.hasOwnProperty(field)) xhr.setRequestHeader(field, this.header[field]);
1869
1892
  }
1870
1893
 
1871
1894
  if (this._responseType) {
@@ -1878,15 +1901,14 @@ Request.prototype._end = function() {
1878
1901
  // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing)
1879
1902
  // We need null here if data is undefined
1880
1903
  xhr.send(typeof data !== 'undefined' ? data : null);
1881
- return this;
1882
1904
  };
1883
1905
 
1884
- request.agent = function() {
1906
+ request.agent = function () {
1885
1907
  return new Agent();
1886
1908
  };
1887
1909
 
1888
- ["GET", "POST", "OPTIONS", "PATCH", "PUT", "DELETE"].forEach(function(method) {
1889
- Agent.prototype[method.toLowerCase()] = function(url, fn) {
1910
+ ["GET", "POST", "OPTIONS", "PATCH", "PUT", "DELETE"].forEach(function (method) {
1911
+ Agent.prototype[method.toLowerCase()] = function (url, fn) {
1890
1912
  var req = new request.Request(method, url);
1891
1913
  this._setDefaults(req);
1892
1914
  if (fn) {
@@ -1908,9 +1930,9 @@ Agent.prototype.del = Agent.prototype['delete'];
1908
1930
  * @api public
1909
1931
  */
1910
1932
 
1911
- request.get = function(url, data, fn) {
1933
+ request.get = function (url, data, fn) {
1912
1934
  var req = request('GET', url);
1913
- if ('function' == typeof data) (fn = data), (data = null);
1935
+ if ('function' == typeof data) fn = data, data = null;
1914
1936
  if (data) req.query(data);
1915
1937
  if (fn) req.end(fn);
1916
1938
  return req;
@@ -1926,9 +1948,9 @@ request.get = function(url, data, fn) {
1926
1948
  * @api public
1927
1949
  */
1928
1950
 
1929
- request.head = function(url, data, fn) {
1951
+ request.head = function (url, data, fn) {
1930
1952
  var req = request('HEAD', url);
1931
- if ('function' == typeof data) (fn = data), (data = null);
1953
+ if ('function' == typeof data) fn = data, data = null;
1932
1954
  if (data) req.query(data);
1933
1955
  if (fn) req.end(fn);
1934
1956
  return req;
@@ -1944,9 +1966,9 @@ request.head = function(url, data, fn) {
1944
1966
  * @api public
1945
1967
  */
1946
1968
 
1947
- request.options = function(url, data, fn) {
1969
+ request.options = function (url, data, fn) {
1948
1970
  var req = request('OPTIONS', url);
1949
- if ('function' == typeof data) (fn = data), (data = null);
1971
+ if ('function' == typeof data) fn = data, data = null;
1950
1972
  if (data) req.send(data);
1951
1973
  if (fn) req.end(fn);
1952
1974
  return req;
@@ -1964,7 +1986,7 @@ request.options = function(url, data, fn) {
1964
1986
 
1965
1987
  function del(url, data, fn) {
1966
1988
  var req = request('DELETE', url);
1967
- if ('function' == typeof data) (fn = data), (data = null);
1989
+ if ('function' == typeof data) fn = data, data = null;
1968
1990
  if (data) req.send(data);
1969
1991
  if (fn) req.end(fn);
1970
1992
  return req;
@@ -1983,9 +2005,9 @@ request['delete'] = del;
1983
2005
  * @api public
1984
2006
  */
1985
2007
 
1986
- request.patch = function(url, data, fn) {
2008
+ request.patch = function (url, data, fn) {
1987
2009
  var req = request('PATCH', url);
1988
- if ('function' == typeof data) (fn = data), (data = null);
2010
+ if ('function' == typeof data) fn = data, data = null;
1989
2011
  if (data) req.send(data);
1990
2012
  if (fn) req.end(fn);
1991
2013
  return req;
@@ -2001,9 +2023,9 @@ request.patch = function(url, data, fn) {
2001
2023
  * @api public
2002
2024
  */
2003
2025
 
2004
- request.post = function(url, data, fn) {
2026
+ request.post = function (url, data, fn) {
2005
2027
  var req = request('POST', url);
2006
- if ('function' == typeof data) (fn = data), (data = null);
2028
+ if ('function' == typeof data) fn = data, data = null;
2007
2029
  if (data) req.send(data);
2008
2030
  if (fn) req.end(fn);
2009
2031
  return req;
@@ -2019,13 +2041,13 @@ request.post = function(url, data, fn) {
2019
2041
  * @api public
2020
2042
  */
2021
2043
 
2022
- request.put = function(url, data, fn) {
2044
+ request.put = function (url, data, fn) {
2023
2045
  var req = request('PUT', url);
2024
- if ('function' == typeof data) (fn = data), (data = null);
2046
+ if ('function' == typeof data) fn = data, data = null;
2025
2047
  if (data) req.send(data);
2026
2048
  if (fn) req.end(fn);
2027
2049
  return req;
2028
2050
  };
2029
2051
 
2030
2052
  },{"./agent-base":1,"./is-object":2,"./request-base":3,"./response-base":4,"component-emitter":6}]},{},[7])(7)
2031
- });
2053
+ });