comprodls-sdk 2.59.0 → 2.60.0

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.
@@ -1143,7 +1143,7 @@ validator.validators.contains = function(value, options) {
1143
1143
  }
1144
1144
  }
1145
1145
  };
1146
- },{"./errors":7,"validate.js":53}],10:[function(require,module,exports){
1146
+ },{"./errors":7,"validate.js":50}],10:[function(require,module,exports){
1147
1147
  /*************************************************************************
1148
1148
  *
1149
1149
  * COMPRO CONFIDENTIAL
@@ -17757,181 +17757,167 @@ module.exports = Array.isArray || function (arr) {
17757
17757
  };
17758
17758
 
17759
17759
  },{}],40:[function(require,module,exports){
17760
-
17761
- /**
17762
- * Expose `Emitter`.
17763
- */
17764
-
17765
- if (typeof module !== 'undefined') {
17766
- module.exports = Emitter;
17767
- }
17768
-
17769
- /**
17770
- * Initialize a new `Emitter`.
17771
- *
17772
- * @api public
17773
- */
17774
-
17775
- function Emitter(obj) {
17776
- if (obj) return mixin(obj);
17777
- };
17778
-
17779
- /**
17780
- * Mixin the emitter properties.
17781
- *
17782
- * @param {Object} obj
17783
- * @return {Object}
17784
- * @api private
17785
- */
17786
-
17787
- function mixin(obj) {
17788
- for (var key in Emitter.prototype) {
17789
- obj[key] = Emitter.prototype[key];
17790
- }
17791
- return obj;
17792
- }
17793
-
17794
- /**
17795
- * Listen on the given `event` with `fn`.
17796
- *
17797
- * @param {String} event
17798
- * @param {Function} fn
17799
- * @return {Emitter}
17800
- * @api public
17801
- */
17802
-
17803
- Emitter.prototype.on =
17804
- Emitter.prototype.addEventListener = function(event, fn){
17805
- this._callbacks = this._callbacks || {};
17806
- (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
17807
- .push(fn);
17808
- return this;
17809
- };
17810
-
17811
- /**
17812
- * Adds an `event` listener that will be invoked a single
17813
- * time then automatically removed.
17814
- *
17815
- * @param {String} event
17816
- * @param {Function} fn
17817
- * @return {Emitter}
17818
- * @api public
17819
- */
17820
-
17821
- Emitter.prototype.once = function(event, fn){
17822
- function on() {
17823
- this.off(event, on);
17824
- fn.apply(this, arguments);
17825
- }
17826
-
17827
- on.fn = fn;
17828
- this.on(event, on);
17829
- return this;
17830
- };
17831
-
17832
- /**
17833
- * Remove the given callback for `event` or all
17834
- * registered callbacks.
17835
- *
17836
- * @param {String} event
17837
- * @param {Function} fn
17838
- * @return {Emitter}
17839
- * @api public
17840
- */
17841
-
17842
- Emitter.prototype.off =
17843
- Emitter.prototype.removeListener =
17844
- Emitter.prototype.removeAllListeners =
17845
- Emitter.prototype.removeEventListener = function(event, fn){
17846
- this._callbacks = this._callbacks || {};
17847
-
17848
- // all
17849
- if (0 == arguments.length) {
17850
- this._callbacks = {};
17851
- return this;
17852
- }
17853
-
17854
- // specific event
17855
- var callbacks = this._callbacks['$' + event];
17856
- if (!callbacks) return this;
17857
-
17858
- // remove all handlers
17859
- if (1 == arguments.length) {
17860
- delete this._callbacks['$' + event];
17861
- return this;
17862
- }
17863
-
17864
- // remove specific handler
17865
- var cb;
17866
- for (var i = 0; i < callbacks.length; i++) {
17867
- cb = callbacks[i];
17868
- if (cb === fn || cb.fn === fn) {
17869
- callbacks.splice(i, 1);
17870
- break;
17871
- }
17872
- }
17873
-
17874
- // Remove event specific arrays for event types that no
17875
- // one is subscribed for to avoid memory leak.
17876
- if (callbacks.length === 0) {
17877
- delete this._callbacks['$' + event];
17878
- }
17879
-
17880
- return this;
17881
- };
17882
-
17883
- /**
17884
- * Emit `event` with the given args.
17885
- *
17886
- * @param {String} event
17887
- * @param {Mixed} ...
17888
- * @return {Emitter}
17889
- */
17890
-
17891
- Emitter.prototype.emit = function(event){
17892
- this._callbacks = this._callbacks || {};
17893
-
17894
- var args = new Array(arguments.length - 1)
17895
- , callbacks = this._callbacks['$' + event];
17896
-
17897
- for (var i = 1; i < arguments.length; i++) {
17898
- args[i - 1] = arguments[i];
17899
- }
17900
-
17901
- if (callbacks) {
17902
- callbacks = callbacks.slice(0);
17903
- for (var i = 0, len = callbacks.length; i < len; ++i) {
17904
- callbacks[i].apply(this, args);
17905
- }
17906
- }
17907
-
17908
- return this;
17909
- };
17910
-
17911
- /**
17912
- * Return array of callbacks for `event`.
17913
- *
17914
- * @param {String} event
17915
- * @return {Array}
17916
- * @api public
17917
- */
17918
-
17919
- Emitter.prototype.listeners = function(event){
17920
- this._callbacks = this._callbacks || {};
17921
- return this._callbacks['$' + event] || [];
17922
- };
17923
-
17924
- /**
17925
- * Check if this emitter has `event` handlers.
17926
- *
17927
- * @param {String} event
17928
- * @return {Boolean}
17929
- * @api public
17930
- */
17931
-
17932
- Emitter.prototype.hasListeners = function(event){
17933
- return !! this.listeners(event).length;
17934
- };
17760
+
17761
+ /**
17762
+ * Expose `Emitter`.
17763
+ */
17764
+
17765
+ module.exports = Emitter;
17766
+
17767
+ /**
17768
+ * Initialize a new `Emitter`.
17769
+ *
17770
+ * @api public
17771
+ */
17772
+
17773
+ function Emitter(obj) {
17774
+ if (obj) return mixin(obj);
17775
+ };
17776
+
17777
+ /**
17778
+ * Mixin the emitter properties.
17779
+ *
17780
+ * @param {Object} obj
17781
+ * @return {Object}
17782
+ * @api private
17783
+ */
17784
+
17785
+ function mixin(obj) {
17786
+ for (var key in Emitter.prototype) {
17787
+ obj[key] = Emitter.prototype[key];
17788
+ }
17789
+ return obj;
17790
+ }
17791
+
17792
+ /**
17793
+ * Listen on the given `event` with `fn`.
17794
+ *
17795
+ * @param {String} event
17796
+ * @param {Function} fn
17797
+ * @return {Emitter}
17798
+ * @api public
17799
+ */
17800
+
17801
+ Emitter.prototype.on =
17802
+ Emitter.prototype.addEventListener = function(event, fn){
17803
+ this._callbacks = this._callbacks || {};
17804
+ (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
17805
+ .push(fn);
17806
+ return this;
17807
+ };
17808
+
17809
+ /**
17810
+ * Adds an `event` listener that will be invoked a single
17811
+ * time then automatically removed.
17812
+ *
17813
+ * @param {String} event
17814
+ * @param {Function} fn
17815
+ * @return {Emitter}
17816
+ * @api public
17817
+ */
17818
+
17819
+ Emitter.prototype.once = function(event, fn){
17820
+ function on() {
17821
+ this.off(event, on);
17822
+ fn.apply(this, arguments);
17823
+ }
17824
+
17825
+ on.fn = fn;
17826
+ this.on(event, on);
17827
+ return this;
17828
+ };
17829
+
17830
+ /**
17831
+ * Remove the given callback for `event` or all
17832
+ * registered callbacks.
17833
+ *
17834
+ * @param {String} event
17835
+ * @param {Function} fn
17836
+ * @return {Emitter}
17837
+ * @api public
17838
+ */
17839
+
17840
+ Emitter.prototype.off =
17841
+ Emitter.prototype.removeListener =
17842
+ Emitter.prototype.removeAllListeners =
17843
+ Emitter.prototype.removeEventListener = function(event, fn){
17844
+ this._callbacks = this._callbacks || {};
17845
+
17846
+ // all
17847
+ if (0 == arguments.length) {
17848
+ this._callbacks = {};
17849
+ return this;
17850
+ }
17851
+
17852
+ // specific event
17853
+ var callbacks = this._callbacks['$' + event];
17854
+ if (!callbacks) return this;
17855
+
17856
+ // remove all handlers
17857
+ if (1 == arguments.length) {
17858
+ delete this._callbacks['$' + event];
17859
+ return this;
17860
+ }
17861
+
17862
+ // remove specific handler
17863
+ var cb;
17864
+ for (var i = 0; i < callbacks.length; i++) {
17865
+ cb = callbacks[i];
17866
+ if (cb === fn || cb.fn === fn) {
17867
+ callbacks.splice(i, 1);
17868
+ break;
17869
+ }
17870
+ }
17871
+ return this;
17872
+ };
17873
+
17874
+ /**
17875
+ * Emit `event` with the given args.
17876
+ *
17877
+ * @param {String} event
17878
+ * @param {Mixed} ...
17879
+ * @return {Emitter}
17880
+ */
17881
+
17882
+ Emitter.prototype.emit = function(event){
17883
+ this._callbacks = this._callbacks || {};
17884
+ var args = [].slice.call(arguments, 1)
17885
+ , callbacks = this._callbacks['$' + event];
17886
+
17887
+ if (callbacks) {
17888
+ callbacks = callbacks.slice(0);
17889
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
17890
+ callbacks[i].apply(this, args);
17891
+ }
17892
+ }
17893
+
17894
+ return this;
17895
+ };
17896
+
17897
+ /**
17898
+ * Return array of callbacks for `event`.
17899
+ *
17900
+ * @param {String} event
17901
+ * @return {Array}
17902
+ * @api public
17903
+ */
17904
+
17905
+ Emitter.prototype.listeners = function(event){
17906
+ this._callbacks = this._callbacks || {};
17907
+ return this._callbacks['$' + event] || [];
17908
+ };
17909
+
17910
+ /**
17911
+ * Check if this emitter has `event` handlers.
17912
+ *
17913
+ * @param {String} event
17914
+ * @return {Boolean}
17915
+ * @api public
17916
+ */
17917
+
17918
+ Emitter.prototype.hasListeners = function(event){
17919
+ return !! this.listeners(event).length;
17920
+ };
17935
17921
 
17936
17922
  },{}],41:[function(require,module,exports){
17937
17923
  // Copyright Joyent, Inc. and other Node contributors.
@@ -18237,8 +18223,6 @@ function isUndefined(arg) {
18237
18223
  }
18238
18224
 
18239
18225
  },{}],42:[function(require,module,exports){
18240
- 'use strict';
18241
-
18242
18226
  var hasOwn = Object.prototype.hasOwnProperty;
18243
18227
  var toStr = Object.prototype.toString;
18244
18228
  var defineProperty = Object.defineProperty;
@@ -18253,6 +18237,8 @@ var isArray = function isArray(arr) {
18253
18237
  };
18254
18238
 
18255
18239
  var isPlainObject = function isPlainObject(obj) {
18240
+ 'use strict';
18241
+
18256
18242
  if (!obj || toStr.call(obj) !== '[object Object]') {
18257
18243
  return false;
18258
18244
  }
@@ -18302,6 +18288,8 @@ var getProperty = function getProperty(obj, name) {
18302
18288
  };
18303
18289
 
18304
18290
  module.exports = function extend() {
18291
+ 'use strict';
18292
+
18305
18293
  var options, name, src, copy, copyIsArray, clone;
18306
18294
  var target = arguments[0];
18307
18295
  var i = 1;
@@ -20771,8 +20759,6 @@ function template(string) {
20771
20759
 
20772
20760
  var Emitter = require('emitter');
20773
20761
  var reduce = require('reduce');
20774
- var requestBase = require('./request-base');
20775
- var isObject = require('./is-object');
20776
20762
 
20777
20763
  /**
20778
20764
  * Root reference for iframes.
@@ -20794,10 +20780,28 @@ if (typeof window !== 'undefined') { // Browser window
20794
20780
  function noop(){};
20795
20781
 
20796
20782
  /**
20797
- * Expose `request`.
20783
+ * Check if `obj` is a host object,
20784
+ * we don't want to serialize these :)
20785
+ *
20786
+ * TODO: future proof, move to compoent land
20787
+ *
20788
+ * @param {Object} obj
20789
+ * @return {Boolean}
20790
+ * @api private
20798
20791
  */
20799
20792
 
20800
- var request = module.exports = require('./request').bind(null, Request);
20793
+ function isHost(obj) {
20794
+ var str = {}.toString.call(obj);
20795
+
20796
+ switch (str) {
20797
+ case '[object File]':
20798
+ case '[object Blob]':
20799
+ case '[object FormData]':
20800
+ return true;
20801
+ default:
20802
+ return false;
20803
+ }
20804
+ }
20801
20805
 
20802
20806
  /**
20803
20807
  * Determine XHR.
@@ -20829,6 +20833,18 @@ var trim = ''.trim
20829
20833
  ? function(s) { return s.trim(); }
20830
20834
  : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
20831
20835
 
20836
+ /**
20837
+ * Check if `obj` is an object.
20838
+ *
20839
+ * @param {Object} obj
20840
+ * @return {Boolean}
20841
+ * @api private
20842
+ */
20843
+
20844
+ function isObject(obj) {
20845
+ return obj === Object(obj);
20846
+ }
20847
+
20832
20848
  /**
20833
20849
  * Serialize the given `obj`.
20834
20850
  *
@@ -20843,8 +20859,8 @@ function serialize(obj) {
20843
20859
  for (var key in obj) {
20844
20860
  if (null != obj[key]) {
20845
20861
  pushEncodedKeyValuePair(pairs, key, obj[key]);
20846
- }
20847
- }
20862
+ }
20863
+ }
20848
20864
  return pairs.join('&');
20849
20865
  }
20850
20866
 
@@ -20862,11 +20878,6 @@ function pushEncodedKeyValuePair(pairs, key, val) {
20862
20878
  return val.forEach(function(v) {
20863
20879
  pushEncodedKeyValuePair(pairs, key, v);
20864
20880
  });
20865
- } else if (isObject(val)) {
20866
- for(var subkey in val) {
20867
- pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]);
20868
- }
20869
- return;
20870
20881
  }
20871
20882
  pairs.push(encodeURIComponent(key)
20872
20883
  + '=' + encodeURIComponent(val));
@@ -20889,18 +20900,13 @@ function pushEncodedKeyValuePair(pairs, key, val) {
20889
20900
  function parseString(str) {
20890
20901
  var obj = {};
20891
20902
  var pairs = str.split('&');
20903
+ var parts;
20892
20904
  var pair;
20893
- var pos;
20894
20905
 
20895
20906
  for (var i = 0, len = pairs.length; i < len; ++i) {
20896
20907
  pair = pairs[i];
20897
- pos = pair.indexOf('=');
20898
- if (pos == -1) {
20899
- obj[decodeURIComponent(pair)] = '';
20900
- } else {
20901
- obj[decodeURIComponent(pair.slice(0, pos))] =
20902
- decodeURIComponent(pair.slice(pos + 1));
20903
- }
20908
+ parts = pair.split('=');
20909
+ obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
20904
20910
  }
20905
20911
 
20906
20912
  return obj;
@@ -21084,15 +21090,15 @@ function Response(req, options) {
21084
21090
  ? this.xhr.responseText
21085
21091
  : null;
21086
21092
  this.statusText = this.req.xhr.statusText;
21087
- this._setStatusProperties(this.xhr.status);
21093
+ this.setStatusProperties(this.xhr.status);
21088
21094
  this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());
21089
21095
  // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
21090
21096
  // getResponseHeader still works. so we get content-type even if getting
21091
21097
  // other headers fails.
21092
21098
  this.header['content-type'] = this.xhr.getResponseHeader('content-type');
21093
- this._setHeaderProperties(this.header);
21099
+ this.setHeaderProperties(this.header);
21094
21100
  this.body = this.req.method != 'HEAD'
21095
- ? this._parseBody(this.text ? this.text : this.xhr.response)
21101
+ ? this.parseBody(this.text ? this.text : this.xhr.response)
21096
21102
  : null;
21097
21103
  }
21098
21104
 
@@ -21120,7 +21126,7 @@ Response.prototype.get = function(field){
21120
21126
  * @api private
21121
21127
  */
21122
21128
 
21123
- Response.prototype._setHeaderProperties = function(header){
21129
+ Response.prototype.setHeaderProperties = function(header){
21124
21130
  // content-type
21125
21131
  var ct = this.header['content-type'] || '';
21126
21132
  this.type = type(ct);
@@ -21141,11 +21147,8 @@ Response.prototype._setHeaderProperties = function(header){
21141
21147
  * @api private
21142
21148
  */
21143
21149
 
21144
- Response.prototype._parseBody = function(str){
21150
+ Response.prototype.parseBody = function(str){
21145
21151
  var parse = request.parse[this.type];
21146
- if (!parse && isJSON(this.type)) {
21147
- parse = request.parse['application/json'];
21148
- }
21149
21152
  return parse && str && (str.length || str instanceof Object)
21150
21153
  ? parse(str)
21151
21154
  : null;
@@ -21172,7 +21175,7 @@ Response.prototype._parseBody = function(str){
21172
21175
  * @api private
21173
21176
  */
21174
21177
 
21175
- Response.prototype._setStatusProperties = function(status){
21178
+ Response.prototype.setStatusProperties = function(status){
21176
21179
  // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
21177
21180
  if (status === 1223) {
21178
21181
  status = 204;
@@ -21240,11 +21243,12 @@ request.Response = Response;
21240
21243
 
21241
21244
  function Request(method, url) {
21242
21245
  var self = this;
21246
+ Emitter.call(this);
21243
21247
  this._query = this._query || [];
21244
21248
  this.method = method;
21245
21249
  this.url = url;
21246
- this.header = {}; // preserves header name case
21247
- this._header = {}; // coerces header names to lowercase
21250
+ this.header = {};
21251
+ this._header = {};
21248
21252
  this.on('end', function(){
21249
21253
  var err = null;
21250
21254
  var res = null;
@@ -21257,8 +21261,6 @@ function Request(method, url) {
21257
21261
  err.original = e;
21258
21262
  // issue #675: return the raw response if the response parsing fails
21259
21263
  err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;
21260
- // issue #876: return the http status code if the response parsing fails
21261
- err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;
21262
21264
  return self.callback(err);
21263
21265
  }
21264
21266
 
@@ -21268,88 +21270,190 @@ function Request(method, url) {
21268
21270
  return self.callback(err, res);
21269
21271
  }
21270
21272
 
21271
- try {
21272
- if (res.status >= 200 && res.status < 300) {
21273
- return self.callback(err, res);
21274
- }
21273
+ if (res.status >= 200 && res.status < 300) {
21274
+ return self.callback(err, res);
21275
+ }
21275
21276
 
21276
- var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21277
- new_err.original = err;
21278
- new_err.response = res;
21279
- new_err.status = res.status;
21277
+ var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21278
+ new_err.original = err;
21279
+ new_err.response = res;
21280
+ new_err.status = res.status;
21280
21281
 
21281
- self.callback(new_err, res);
21282
- } catch(e) {
21283
- self.callback(e); // #985 touching res may cause INVALID_STATE_ERR on old Android
21284
- }
21282
+ self.callback(new_err, res);
21285
21283
  });
21286
21284
  }
21287
21285
 
21288
21286
  /**
21289
- * Mixin `Emitter` and `requestBase`.
21287
+ * Mixin `Emitter`.
21290
21288
  */
21291
21289
 
21292
21290
  Emitter(Request.prototype);
21293
- for (var key in requestBase) {
21294
- Request.prototype[key] = requestBase[key];
21291
+
21292
+ /**
21293
+ * Allow for extension
21294
+ */
21295
+
21296
+ Request.prototype.use = function(fn) {
21297
+ fn(this);
21298
+ return this;
21295
21299
  }
21296
21300
 
21297
21301
  /**
21298
- * Set Content-Type to `type`, mapping values from `request.types`.
21299
- *
21300
- * Examples:
21301
- *
21302
- * superagent.types.xml = 'application/xml';
21303
- *
21304
- * request.post('/')
21305
- * .type('xml')
21306
- * .send(xmlstring)
21307
- * .end(callback);
21308
- *
21309
- * request.post('/')
21310
- * .type('application/xml')
21311
- * .send(xmlstring)
21312
- * .end(callback);
21302
+ * Set timeout to `ms`.
21313
21303
  *
21314
- * @param {String} type
21304
+ * @param {Number} ms
21315
21305
  * @return {Request} for chaining
21316
21306
  * @api public
21317
21307
  */
21318
21308
 
21319
- Request.prototype.type = function(type){
21320
- this.set('Content-Type', request.types[type] || type);
21309
+ Request.prototype.timeout = function(ms){
21310
+ this._timeout = ms;
21321
21311
  return this;
21322
21312
  };
21323
21313
 
21324
21314
  /**
21325
- * Set responseType to `val`. Presently valid responseTypes are 'blob' and
21326
- * 'arraybuffer'.
21327
- *
21328
- * Examples:
21329
- *
21330
- * req.get('/')
21331
- * .responseType('blob')
21332
- * .end(callback);
21315
+ * Clear previous timeout.
21333
21316
  *
21334
- * @param {String} val
21335
21317
  * @return {Request} for chaining
21336
21318
  * @api public
21337
21319
  */
21338
21320
 
21339
- Request.prototype.responseType = function(val){
21340
- this._responseType = val;
21321
+ Request.prototype.clearTimeout = function(){
21322
+ this._timeout = 0;
21323
+ clearTimeout(this._timer);
21341
21324
  return this;
21342
21325
  };
21343
21326
 
21344
21327
  /**
21345
- * Set Accept to `type`, mapping values from `request.types`.
21346
- *
21347
- * Examples:
21348
- *
21349
- * superagent.types.json = 'application/json';
21328
+ * Abort the request, and clear potential timeout.
21350
21329
  *
21351
- * request.get('/agent')
21352
- * .accept('json')
21330
+ * @return {Request}
21331
+ * @api public
21332
+ */
21333
+
21334
+ Request.prototype.abort = function(){
21335
+ if (this.aborted) return;
21336
+ this.aborted = true;
21337
+ this.xhr.abort();
21338
+ this.clearTimeout();
21339
+ this.emit('abort');
21340
+ return this;
21341
+ };
21342
+
21343
+ /**
21344
+ * Set header `field` to `val`, or multiple fields with one object.
21345
+ *
21346
+ * Examples:
21347
+ *
21348
+ * req.get('/')
21349
+ * .set('Accept', 'application/json')
21350
+ * .set('X-API-Key', 'foobar')
21351
+ * .end(callback);
21352
+ *
21353
+ * req.get('/')
21354
+ * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
21355
+ * .end(callback);
21356
+ *
21357
+ * @param {String|Object} field
21358
+ * @param {String} val
21359
+ * @return {Request} for chaining
21360
+ * @api public
21361
+ */
21362
+
21363
+ Request.prototype.set = function(field, val){
21364
+ if (isObject(field)) {
21365
+ for (var key in field) {
21366
+ this.set(key, field[key]);
21367
+ }
21368
+ return this;
21369
+ }
21370
+ this._header[field.toLowerCase()] = val;
21371
+ this.header[field] = val;
21372
+ return this;
21373
+ };
21374
+
21375
+ /**
21376
+ * Remove header `field`.
21377
+ *
21378
+ * Example:
21379
+ *
21380
+ * req.get('/')
21381
+ * .unset('User-Agent')
21382
+ * .end(callback);
21383
+ *
21384
+ * @param {String} field
21385
+ * @return {Request} for chaining
21386
+ * @api public
21387
+ */
21388
+
21389
+ Request.prototype.unset = function(field){
21390
+ delete this._header[field.toLowerCase()];
21391
+ delete this.header[field];
21392
+ return this;
21393
+ };
21394
+
21395
+ /**
21396
+ * Get case-insensitive header `field` value.
21397
+ *
21398
+ * @param {String} field
21399
+ * @return {String}
21400
+ * @api private
21401
+ */
21402
+
21403
+ Request.prototype.getHeader = function(field){
21404
+ return this._header[field.toLowerCase()];
21405
+ };
21406
+
21407
+ /**
21408
+ * Set Content-Type to `type`, mapping values from `request.types`.
21409
+ *
21410
+ * Examples:
21411
+ *
21412
+ * superagent.types.xml = 'application/xml';
21413
+ *
21414
+ * request.post('/')
21415
+ * .type('xml')
21416
+ * .send(xmlstring)
21417
+ * .end(callback);
21418
+ *
21419
+ * request.post('/')
21420
+ * .type('application/xml')
21421
+ * .send(xmlstring)
21422
+ * .end(callback);
21423
+ *
21424
+ * @param {String} type
21425
+ * @return {Request} for chaining
21426
+ * @api public
21427
+ */
21428
+
21429
+ Request.prototype.type = function(type){
21430
+ this.set('Content-Type', request.types[type] || type);
21431
+ return this;
21432
+ };
21433
+
21434
+ /**
21435
+ * Force given parser
21436
+ *
21437
+ * Sets the body parser no matter type.
21438
+ *
21439
+ * @param {Function}
21440
+ * @api public
21441
+ */
21442
+
21443
+ Request.prototype.parse = function(fn){
21444
+ this._parser = fn;
21445
+ return this;
21446
+ };
21447
+
21448
+ /**
21449
+ * Set Accept to `type`, mapping values from `request.types`.
21450
+ *
21451
+ * Examples:
21452
+ *
21453
+ * superagent.types.json = 'application/json';
21454
+ *
21455
+ * request.get('/agent')
21456
+ * .accept('json')
21353
21457
  * .end(callback);
21354
21458
  *
21355
21459
  * request.get('/agent')
@@ -21371,29 +21475,13 @@ Request.prototype.accept = function(type){
21371
21475
  *
21372
21476
  * @param {String} user
21373
21477
  * @param {String} pass
21374
- * @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic')
21375
21478
  * @return {Request} for chaining
21376
21479
  * @api public
21377
21480
  */
21378
21481
 
21379
- Request.prototype.auth = function(user, pass, options){
21380
- if (!options) {
21381
- options = {
21382
- type: 'basic'
21383
- }
21384
- }
21385
-
21386
- switch (options.type) {
21387
- case 'basic':
21388
- var str = btoa(user + ':' + pass);
21389
- this.set('Authorization', 'Basic ' + str);
21390
- break;
21391
-
21392
- case 'auto':
21393
- this.username = user;
21394
- this.password = pass;
21395
- break;
21396
- }
21482
+ Request.prototype.auth = function(user, pass){
21483
+ var str = btoa(user + ':' + pass);
21484
+ this.set('Authorization', 'Basic ' + str);
21397
21485
  return this;
21398
21486
  };
21399
21487
 
@@ -21417,13 +21505,35 @@ Request.prototype.query = function(val){
21417
21505
  return this;
21418
21506
  };
21419
21507
 
21508
+ /**
21509
+ * Write the field `name` and `val` for "multipart/form-data"
21510
+ * request bodies.
21511
+ *
21512
+ * ``` js
21513
+ * request.post('/upload')
21514
+ * .field('foo', 'bar')
21515
+ * .end(callback);
21516
+ * ```
21517
+ *
21518
+ * @param {String} name
21519
+ * @param {String|Blob|File} val
21520
+ * @return {Request} for chaining
21521
+ * @api public
21522
+ */
21523
+
21524
+ Request.prototype.field = function(name, val){
21525
+ if (!this._formData) this._formData = new root.FormData();
21526
+ this._formData.append(name, val);
21527
+ return this;
21528
+ };
21529
+
21420
21530
  /**
21421
21531
  * Queue the given `file` as an attachment to the specified `field`,
21422
21532
  * with optional `filename`.
21423
21533
  *
21424
21534
  * ``` js
21425
21535
  * request.post('/upload')
21426
- * .attach('content', new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
21536
+ * .attach(new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
21427
21537
  * .end(callback);
21428
21538
  * ```
21429
21539
  *
@@ -21435,15 +21545,77 @@ Request.prototype.query = function(val){
21435
21545
  */
21436
21546
 
21437
21547
  Request.prototype.attach = function(field, file, filename){
21438
- this._getFormData().append(field, file, filename || file.name);
21548
+ if (!this._formData) this._formData = new root.FormData();
21549
+ this._formData.append(field, file, filename || file.name);
21439
21550
  return this;
21440
21551
  };
21441
21552
 
21442
- Request.prototype._getFormData = function(){
21443
- if (!this._formData) {
21444
- this._formData = new root.FormData();
21553
+ /**
21554
+ * Send `data` as the request body, defaulting the `.type()` to "json" when
21555
+ * an object is given.
21556
+ *
21557
+ * Examples:
21558
+ *
21559
+ * // manual json
21560
+ * request.post('/user')
21561
+ * .type('json')
21562
+ * .send('{"name":"tj"}')
21563
+ * .end(callback)
21564
+ *
21565
+ * // auto json
21566
+ * request.post('/user')
21567
+ * .send({ name: 'tj' })
21568
+ * .end(callback)
21569
+ *
21570
+ * // manual x-www-form-urlencoded
21571
+ * request.post('/user')
21572
+ * .type('form')
21573
+ * .send('name=tj')
21574
+ * .end(callback)
21575
+ *
21576
+ * // auto x-www-form-urlencoded
21577
+ * request.post('/user')
21578
+ * .type('form')
21579
+ * .send({ name: 'tj' })
21580
+ * .end(callback)
21581
+ *
21582
+ * // defaults to x-www-form-urlencoded
21583
+ * request.post('/user')
21584
+ * .send('name=tobi')
21585
+ * .send('species=ferret')
21586
+ * .end(callback)
21587
+ *
21588
+ * @param {String|Object} data
21589
+ * @return {Request} for chaining
21590
+ * @api public
21591
+ */
21592
+
21593
+ Request.prototype.send = function(data){
21594
+ var obj = isObject(data);
21595
+ var type = this.getHeader('Content-Type');
21596
+
21597
+ // merge
21598
+ if (obj && isObject(this._data)) {
21599
+ for (var key in data) {
21600
+ this._data[key] = data[key];
21601
+ }
21602
+ } else if ('string' == typeof data) {
21603
+ if (!type) this.type('form');
21604
+ type = this.getHeader('Content-Type');
21605
+ if ('application/x-www-form-urlencoded' == type) {
21606
+ this._data = this._data
21607
+ ? this._data + '&' + data
21608
+ : data;
21609
+ } else {
21610
+ this._data = (this._data || '') + data;
21611
+ }
21612
+ } else {
21613
+ this._data = data;
21445
21614
  }
21446
- return this._formData;
21615
+
21616
+ if (!obj || isHost(data)) return this;
21617
+ if (!type) this.type('json');
21618
+ return this;
21447
21619
  };
21448
21620
 
21449
21621
  /**
@@ -21484,7 +21656,7 @@ Request.prototype.crossDomainError = function(){
21484
21656
  * @api private
21485
21657
  */
21486
21658
 
21487
- Request.prototype._timeoutError = function(){
21659
+ Request.prototype.timeoutError = function(){
21488
21660
  var timeout = this._timeout;
21489
21661
  var err = new Error('timeout of ' + timeout + 'ms exceeded');
21490
21662
  err.timeout = timeout;
@@ -21492,18 +21664,19 @@ Request.prototype._timeoutError = function(){
21492
21664
  };
21493
21665
 
21494
21666
  /**
21495
- * Compose querystring to append to req.url
21667
+ * Enable transmission of cookies with x-domain requests.
21496
21668
  *
21497
- * @api private
21669
+ * Note that for this to work the origin must not be
21670
+ * using "Access-Control-Allow-Origin" with a wildcard,
21671
+ * and also must set "Access-Control-Allow-Credentials"
21672
+ * to "true".
21673
+ *
21674
+ * @api public
21498
21675
  */
21499
21676
 
21500
- Request.prototype._appendQueryString = function(){
21501
- var query = this._query.join('&');
21502
- if (query) {
21503
- this.url += ~this.url.indexOf('?')
21504
- ? '&' + query
21505
- : '?' + query;
21506
- }
21677
+ Request.prototype.withCredentials = function(){
21678
+ this._withCredentials = true;
21679
+ return this;
21507
21680
  };
21508
21681
 
21509
21682
  /**
@@ -21518,6 +21691,7 @@ Request.prototype._appendQueryString = function(){
21518
21691
  Request.prototype.end = function(fn){
21519
21692
  var self = this;
21520
21693
  var xhr = this.xhr = request.getXHR();
21694
+ var query = this._query.join('&');
21521
21695
  var timeout = this._timeout;
21522
21696
  var data = this._formData || this._data;
21523
21697
 
@@ -21534,8 +21708,8 @@ Request.prototype.end = function(fn){
21534
21708
  try { status = xhr.status } catch(e) { status = 0; }
21535
21709
 
21536
21710
  if (0 == status) {
21537
- if (self.timedout) return self._timeoutError();
21538
- if (self._aborted) return;
21711
+ if (self.timedout) return self.timeoutError();
21712
+ if (self.aborted) return;
21539
21713
  return self.crossDomainError();
21540
21714
  }
21541
21715
  self.emit('end');
@@ -21571,23 +21745,24 @@ Request.prototype.end = function(fn){
21571
21745
  }
21572
21746
 
21573
21747
  // querystring
21574
- this._appendQueryString();
21748
+ if (query) {
21749
+ query = request.serializeObject(query);
21750
+ this.url += ~this.url.indexOf('?')
21751
+ ? '&' + query
21752
+ : '?' + query;
21753
+ }
21575
21754
 
21576
21755
  // initiate request
21577
- if (this.username && this.password) {
21578
- xhr.open(this.method, this.url, true, this.username, this.password);
21579
- } else {
21580
- xhr.open(this.method, this.url, true);
21581
- }
21756
+ xhr.open(this.method, this.url, true);
21582
21757
 
21583
21758
  // CORS
21584
21759
  if (this._withCredentials) xhr.withCredentials = true;
21585
21760
 
21586
21761
  // body
21587
- if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) {
21762
+ if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
21588
21763
  // serialize stuff
21589
- var contentType = this._header['content-type'];
21590
- var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
21764
+ var contentType = this.getHeader('Content-Type');
21765
+ var serialize = this._parser || request.serialize[contentType ? contentType.split(';')[0] : ''];
21591
21766
  if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json'];
21592
21767
  if (serialize) data = serialize(data);
21593
21768
  }
@@ -21598,10 +21773,6 @@ Request.prototype.end = function(fn){
21598
21773
  xhr.setRequestHeader(field, this.header[field]);
21599
21774
  }
21600
21775
 
21601
- if (this._responseType) {
21602
- xhr.responseType = this._responseType;
21603
- }
21604
-
21605
21776
  // send stuff
21606
21777
  this.emit('request', this);
21607
21778
 
@@ -21611,6 +21782,19 @@ Request.prototype.end = function(fn){
21611
21782
  return this;
21612
21783
  };
21613
21784
 
21785
+ /**
21786
+ * Faux promise support
21787
+ *
21788
+ * @param {Function} fulfill
21789
+ * @param {Function} reject
21790
+ * @return {Request}
21791
+ */
21792
+
21793
+ Request.prototype.then = function (fulfill, reject) {
21794
+ return this.end(function(err, res) {
21795
+ err ? reject(err) : fulfill(res);
21796
+ });
21797
+ }
21614
21798
 
21615
21799
  /**
21616
21800
  * Expose `Request`.
@@ -21618,6 +21802,35 @@ Request.prototype.end = function(fn){
21618
21802
 
21619
21803
  request.Request = Request;
21620
21804
 
21805
+ /**
21806
+ * Issue a request:
21807
+ *
21808
+ * Examples:
21809
+ *
21810
+ * request('GET', '/users').end(callback)
21811
+ * request('/users').end(callback)
21812
+ * request('/users', callback)
21813
+ *
21814
+ * @param {String} method
21815
+ * @param {String|Function} url or callback
21816
+ * @return {Request}
21817
+ * @api public
21818
+ */
21819
+
21820
+ function request(method, url) {
21821
+ // callback
21822
+ if ('function' == typeof url) {
21823
+ return new Request('GET', method).end(url);
21824
+ }
21825
+
21826
+ // url first
21827
+ if (1 == arguments.length) {
21828
+ return new Request('GET', method);
21829
+ }
21830
+
21831
+ return new Request(method, url);
21832
+ }
21833
+
21621
21834
  /**
21622
21835
  * GET `url` with optional callback `fn(res)`.
21623
21836
  *
@@ -21655,25 +21868,7 @@ request.head = function(url, data, fn){
21655
21868
  };
21656
21869
 
21657
21870
  /**
21658
- * OPTIONS query to `url` with optional callback `fn(res)`.
21659
- *
21660
- * @param {String} url
21661
- * @param {Mixed|Function} data or fn
21662
- * @param {Function} fn
21663
- * @return {Request}
21664
- * @api public
21665
- */
21666
-
21667
- request.options = function(url, data, fn){
21668
- var req = request('OPTIONS', url);
21669
- if ('function' == typeof data) fn = data, data = null;
21670
- if (data) req.send(data);
21671
- if (fn) req.end(fn);
21672
- return req;
21673
- };
21674
-
21675
- /**
21676
- * DELETE `url` with optional callback `fn(res)`.
21871
+ * DELETE `url` with optional callback `fn(res)`.
21677
21872
  *
21678
21873
  * @param {String} url
21679
21874
  * @param {Function} fn
@@ -21744,404 +21939,13 @@ request.put = function(url, data, fn){
21744
21939
  return req;
21745
21940
  };
21746
21941
 
21747
- },{"./is-object":50,"./request":52,"./request-base":51,"emitter":40,"reduce":47}],50:[function(require,module,exports){
21748
- /**
21749
- * Check if `obj` is an object.
21750
- *
21751
- * @param {Object} obj
21752
- * @return {Boolean}
21753
- * @api private
21754
- */
21755
-
21756
- function isObject(obj) {
21757
- return null !== obj && 'object' === typeof obj;
21758
- }
21759
-
21760
- module.exports = isObject;
21761
-
21762
- },{}],51:[function(require,module,exports){
21763
- /**
21764
- * Module of mixed-in functions shared between node and client code
21765
- */
21766
- var isObject = require('./is-object');
21767
-
21768
- /**
21769
- * Clear previous timeout.
21770
- *
21771
- * @return {Request} for chaining
21772
- * @api public
21773
- */
21774
-
21775
- exports.clearTimeout = function _clearTimeout(){
21776
- this._timeout = 0;
21777
- clearTimeout(this._timer);
21778
- return this;
21779
- };
21780
-
21781
- /**
21782
- * Override default response body parser
21783
- *
21784
- * This function will be called to convert incoming data into request.body
21785
- *
21786
- * @param {Function}
21787
- * @api public
21788
- */
21789
-
21790
- exports.parse = function parse(fn){
21791
- this._parser = fn;
21792
- return this;
21793
- };
21794
-
21795
- /**
21796
- * Override default request body serializer
21797
- *
21798
- * This function will be called to convert data set via .send or .attach into payload to send
21799
- *
21800
- * @param {Function}
21801
- * @api public
21802
- */
21803
-
21804
- exports.serialize = function serialize(fn){
21805
- this._serializer = fn;
21806
- return this;
21807
- };
21808
-
21809
21942
  /**
21810
- * Set timeout to `ms`.
21811
- *
21812
- * @param {Number} ms
21813
- * @return {Request} for chaining
21814
- * @api public
21815
- */
21816
-
21817
- exports.timeout = function timeout(ms){
21818
- this._timeout = ms;
21819
- return this;
21820
- };
21821
-
21822
- /**
21823
- * Promise support
21824
- *
21825
- * @param {Function} resolve
21826
- * @param {Function} reject
21827
- * @return {Request}
21828
- */
21829
-
21830
- exports.then = function then(resolve, reject) {
21831
- if (!this._fullfilledPromise) {
21832
- var self = this;
21833
- this._fullfilledPromise = new Promise(function(innerResolve, innerReject){
21834
- self.end(function(err, res){
21835
- if (err) innerReject(err); else innerResolve(res);
21836
- });
21837
- });
21838
- }
21839
- return this._fullfilledPromise.then(resolve, reject);
21840
- }
21841
-
21842
- /**
21843
- * Allow for extension
21844
- */
21845
-
21846
- exports.use = function use(fn) {
21847
- fn(this);
21848
- return this;
21849
- }
21850
-
21851
-
21852
- /**
21853
- * Get request header `field`.
21854
- * Case-insensitive.
21855
- *
21856
- * @param {String} field
21857
- * @return {String}
21858
- * @api public
21859
- */
21860
-
21861
- exports.get = function(field){
21862
- return this._header[field.toLowerCase()];
21863
- };
21864
-
21865
- /**
21866
- * Get case-insensitive header `field` value.
21867
- * This is a deprecated internal API. Use `.get(field)` instead.
21868
- *
21869
- * (getHeader is no longer used internally by the superagent code base)
21870
- *
21871
- * @param {String} field
21872
- * @return {String}
21873
- * @api private
21874
- * @deprecated
21875
- */
21876
-
21877
- exports.getHeader = exports.get;
21878
-
21879
- /**
21880
- * Set header `field` to `val`, or multiple fields with one object.
21881
- * Case-insensitive.
21882
- *
21883
- * Examples:
21884
- *
21885
- * req.get('/')
21886
- * .set('Accept', 'application/json')
21887
- * .set('X-API-Key', 'foobar')
21888
- * .end(callback);
21889
- *
21890
- * req.get('/')
21891
- * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
21892
- * .end(callback);
21893
- *
21894
- * @param {String|Object} field
21895
- * @param {String} val
21896
- * @return {Request} for chaining
21897
- * @api public
21898
- */
21899
-
21900
- exports.set = function(field, val){
21901
- if (isObject(field)) {
21902
- for (var key in field) {
21903
- this.set(key, field[key]);
21904
- }
21905
- return this;
21906
- }
21907
- this._header[field.toLowerCase()] = val;
21908
- this.header[field] = val;
21909
- return this;
21910
- };
21911
-
21912
- /**
21913
- * Remove header `field`.
21914
- * Case-insensitive.
21915
- *
21916
- * Example:
21917
- *
21918
- * req.get('/')
21919
- * .unset('User-Agent')
21920
- * .end(callback);
21921
- *
21922
- * @param {String} field
21923
- */
21924
- exports.unset = function(field){
21925
- delete this._header[field.toLowerCase()];
21926
- delete this.header[field];
21927
- return this;
21928
- };
21929
-
21930
- /**
21931
- * Write the field `name` and `val` for "multipart/form-data"
21932
- * request bodies.
21933
- *
21934
- * ``` js
21935
- * request.post('/upload')
21936
- * .field('foo', 'bar')
21937
- * .end(callback);
21938
- * ```
21939
- *
21940
- * @param {String} name
21941
- * @param {String|Blob|File|Buffer|fs.ReadStream} val
21942
- * @return {Request} for chaining
21943
- * @api public
21944
- */
21945
- exports.field = function(name, val) {
21946
- this._getFormData().append(name, val);
21947
- return this;
21948
- };
21949
-
21950
- /**
21951
- * Abort the request, and clear potential timeout.
21952
- *
21953
- * @return {Request}
21954
- * @api public
21955
- */
21956
- exports.abort = function(){
21957
- if (this._aborted) {
21958
- return this;
21959
- }
21960
- this._aborted = true;
21961
- this.xhr && this.xhr.abort(); // browser
21962
- this.req && this.req.abort(); // node
21963
- this.clearTimeout();
21964
- this.emit('abort');
21965
- return this;
21966
- };
21967
-
21968
- /**
21969
- * Enable transmission of cookies with x-domain requests.
21970
- *
21971
- * Note that for this to work the origin must not be
21972
- * using "Access-Control-Allow-Origin" with a wildcard,
21973
- * and also must set "Access-Control-Allow-Credentials"
21974
- * to "true".
21975
- *
21976
- * @api public
21977
- */
21978
-
21979
- exports.withCredentials = function(){
21980
- // This is browser-only functionality. Node side is no-op.
21981
- this._withCredentials = true;
21982
- return this;
21983
- };
21984
-
21985
- /**
21986
- * Set the max redirects to `n`. Does noting in browser XHR implementation.
21987
- *
21988
- * @param {Number} n
21989
- * @return {Request} for chaining
21990
- * @api public
21991
- */
21992
-
21993
- exports.redirects = function(n){
21994
- this._maxRedirects = n;
21995
- return this;
21996
- };
21997
-
21998
- /**
21999
- * Convert to a plain javascript object (not JSON string) of scalar properties.
22000
- * Note as this method is designed to return a useful non-this value,
22001
- * it cannot be chained.
22002
- *
22003
- * @return {Object} describing method, url, and data of this request
22004
- * @api public
22005
- */
22006
-
22007
- exports.toJSON = function(){
22008
- return {
22009
- method: this.method,
22010
- url: this.url,
22011
- data: this._data
22012
- };
22013
- };
22014
-
22015
- /**
22016
- * Check if `obj` is a host object,
22017
- * we don't want to serialize these :)
22018
- *
22019
- * TODO: future proof, move to compoent land
22020
- *
22021
- * @param {Object} obj
22022
- * @return {Boolean}
22023
- * @api private
22024
- */
22025
-
22026
- exports._isHost = function _isHost(obj) {
22027
- var str = {}.toString.call(obj);
22028
-
22029
- switch (str) {
22030
- case '[object File]':
22031
- case '[object Blob]':
22032
- case '[object FormData]':
22033
- return true;
22034
- default:
22035
- return false;
22036
- }
22037
- }
22038
-
22039
- /**
22040
- * Send `data` as the request body, defaulting the `.type()` to "json" when
22041
- * an object is given.
22042
- *
22043
- * Examples:
22044
- *
22045
- * // manual json
22046
- * request.post('/user')
22047
- * .type('json')
22048
- * .send('{"name":"tj"}')
22049
- * .end(callback)
22050
- *
22051
- * // auto json
22052
- * request.post('/user')
22053
- * .send({ name: 'tj' })
22054
- * .end(callback)
22055
- *
22056
- * // manual x-www-form-urlencoded
22057
- * request.post('/user')
22058
- * .type('form')
22059
- * .send('name=tj')
22060
- * .end(callback)
22061
- *
22062
- * // auto x-www-form-urlencoded
22063
- * request.post('/user')
22064
- * .type('form')
22065
- * .send({ name: 'tj' })
22066
- * .end(callback)
22067
- *
22068
- * // defaults to x-www-form-urlencoded
22069
- * request.post('/user')
22070
- * .send('name=tobi')
22071
- * .send('species=ferret')
22072
- * .end(callback)
22073
- *
22074
- * @param {String|Object} data
22075
- * @return {Request} for chaining
22076
- * @api public
22077
- */
22078
-
22079
- exports.send = function(data){
22080
- var obj = isObject(data);
22081
- var type = this._header['content-type'];
22082
-
22083
- // merge
22084
- if (obj && isObject(this._data)) {
22085
- for (var key in data) {
22086
- this._data[key] = data[key];
22087
- }
22088
- } else if ('string' == typeof data) {
22089
- // default to x-www-form-urlencoded
22090
- if (!type) this.type('form');
22091
- type = this._header['content-type'];
22092
- if ('application/x-www-form-urlencoded' == type) {
22093
- this._data = this._data
22094
- ? this._data + '&' + data
22095
- : data;
22096
- } else {
22097
- this._data = (this._data || '') + data;
22098
- }
22099
- } else {
22100
- this._data = data;
22101
- }
22102
-
22103
- if (!obj || this._isHost(data)) return this;
22104
-
22105
- // default to json
22106
- if (!type) this.type('json');
22107
- return this;
22108
- };
22109
-
22110
- },{"./is-object":50}],52:[function(require,module,exports){
22111
- // The node and browser modules expose versions of this with the
22112
- // appropriate constructor function bound as first argument
22113
- /**
22114
- * Issue a request:
22115
- *
22116
- * Examples:
22117
- *
22118
- * request('GET', '/users').end(callback)
22119
- * request('/users').end(callback)
22120
- * request('/users', callback)
22121
- *
22122
- * @param {String} method
22123
- * @param {String|Function} url or callback
22124
- * @return {Request}
22125
- * @api public
21943
+ * Expose `request`.
22126
21944
  */
22127
21945
 
22128
- function request(RequestConstructor, method, url) {
22129
- // callback
22130
- if ('function' == typeof url) {
22131
- return new RequestConstructor('GET', method).end(url);
22132
- }
22133
-
22134
- // url first
22135
- if (2 == arguments.length) {
22136
- return new RequestConstructor('GET', method);
22137
- }
22138
-
22139
- return new RequestConstructor(method, url);
22140
- }
22141
-
22142
21946
  module.exports = request;
22143
21947
 
22144
- },{}],53:[function(require,module,exports){
21948
+ },{"emitter":40,"reduce":47}],50:[function(require,module,exports){
22145
21949
  /*!
22146
21950
  * validate.js 0.9.0
22147
21951
  *