comprodls-sdk 2.63.0 → 2.63.1

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
@@ -17816,181 +17816,167 @@ module.exports = Array.isArray || function (arr) {
17816
17816
  };
17817
17817
 
17818
17818
  },{}],40:[function(require,module,exports){
17819
-
17820
- /**
17821
- * Expose `Emitter`.
17822
- */
17823
-
17824
- if (typeof module !== 'undefined') {
17825
- module.exports = Emitter;
17826
- }
17827
-
17828
- /**
17829
- * Initialize a new `Emitter`.
17830
- *
17831
- * @api public
17832
- */
17833
-
17834
- function Emitter(obj) {
17835
- if (obj) return mixin(obj);
17836
- };
17837
-
17838
- /**
17839
- * Mixin the emitter properties.
17840
- *
17841
- * @param {Object} obj
17842
- * @return {Object}
17843
- * @api private
17844
- */
17845
-
17846
- function mixin(obj) {
17847
- for (var key in Emitter.prototype) {
17848
- obj[key] = Emitter.prototype[key];
17849
- }
17850
- return obj;
17851
- }
17852
-
17853
- /**
17854
- * Listen on the given `event` with `fn`.
17855
- *
17856
- * @param {String} event
17857
- * @param {Function} fn
17858
- * @return {Emitter}
17859
- * @api public
17860
- */
17861
-
17862
- Emitter.prototype.on =
17863
- Emitter.prototype.addEventListener = function(event, fn){
17864
- this._callbacks = this._callbacks || {};
17865
- (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
17866
- .push(fn);
17867
- return this;
17868
- };
17869
-
17870
- /**
17871
- * Adds an `event` listener that will be invoked a single
17872
- * time then automatically removed.
17873
- *
17874
- * @param {String} event
17875
- * @param {Function} fn
17876
- * @return {Emitter}
17877
- * @api public
17878
- */
17879
-
17880
- Emitter.prototype.once = function(event, fn){
17881
- function on() {
17882
- this.off(event, on);
17883
- fn.apply(this, arguments);
17884
- }
17885
-
17886
- on.fn = fn;
17887
- this.on(event, on);
17888
- return this;
17889
- };
17890
-
17891
- /**
17892
- * Remove the given callback for `event` or all
17893
- * registered callbacks.
17894
- *
17895
- * @param {String} event
17896
- * @param {Function} fn
17897
- * @return {Emitter}
17898
- * @api public
17899
- */
17900
-
17901
- Emitter.prototype.off =
17902
- Emitter.prototype.removeListener =
17903
- Emitter.prototype.removeAllListeners =
17904
- Emitter.prototype.removeEventListener = function(event, fn){
17905
- this._callbacks = this._callbacks || {};
17906
-
17907
- // all
17908
- if (0 == arguments.length) {
17909
- this._callbacks = {};
17910
- return this;
17911
- }
17912
-
17913
- // specific event
17914
- var callbacks = this._callbacks['$' + event];
17915
- if (!callbacks) return this;
17916
-
17917
- // remove all handlers
17918
- if (1 == arguments.length) {
17919
- delete this._callbacks['$' + event];
17920
- return this;
17921
- }
17922
-
17923
- // remove specific handler
17924
- var cb;
17925
- for (var i = 0; i < callbacks.length; i++) {
17926
- cb = callbacks[i];
17927
- if (cb === fn || cb.fn === fn) {
17928
- callbacks.splice(i, 1);
17929
- break;
17930
- }
17931
- }
17932
-
17933
- // Remove event specific arrays for event types that no
17934
- // one is subscribed for to avoid memory leak.
17935
- if (callbacks.length === 0) {
17936
- delete this._callbacks['$' + event];
17937
- }
17938
-
17939
- return this;
17940
- };
17941
-
17942
- /**
17943
- * Emit `event` with the given args.
17944
- *
17945
- * @param {String} event
17946
- * @param {Mixed} ...
17947
- * @return {Emitter}
17948
- */
17949
-
17950
- Emitter.prototype.emit = function(event){
17951
- this._callbacks = this._callbacks || {};
17952
-
17953
- var args = new Array(arguments.length - 1)
17954
- , callbacks = this._callbacks['$' + event];
17955
-
17956
- for (var i = 1; i < arguments.length; i++) {
17957
- args[i - 1] = arguments[i];
17958
- }
17959
-
17960
- if (callbacks) {
17961
- callbacks = callbacks.slice(0);
17962
- for (var i = 0, len = callbacks.length; i < len; ++i) {
17963
- callbacks[i].apply(this, args);
17964
- }
17965
- }
17966
-
17967
- return this;
17968
- };
17969
-
17970
- /**
17971
- * Return array of callbacks for `event`.
17972
- *
17973
- * @param {String} event
17974
- * @return {Array}
17975
- * @api public
17976
- */
17977
-
17978
- Emitter.prototype.listeners = function(event){
17979
- this._callbacks = this._callbacks || {};
17980
- return this._callbacks['$' + event] || [];
17981
- };
17982
-
17983
- /**
17984
- * Check if this emitter has `event` handlers.
17985
- *
17986
- * @param {String} event
17987
- * @return {Boolean}
17988
- * @api public
17989
- */
17990
-
17991
- Emitter.prototype.hasListeners = function(event){
17992
- return !! this.listeners(event).length;
17993
- };
17819
+
17820
+ /**
17821
+ * Expose `Emitter`.
17822
+ */
17823
+
17824
+ module.exports = Emitter;
17825
+
17826
+ /**
17827
+ * Initialize a new `Emitter`.
17828
+ *
17829
+ * @api public
17830
+ */
17831
+
17832
+ function Emitter(obj) {
17833
+ if (obj) return mixin(obj);
17834
+ };
17835
+
17836
+ /**
17837
+ * Mixin the emitter properties.
17838
+ *
17839
+ * @param {Object} obj
17840
+ * @return {Object}
17841
+ * @api private
17842
+ */
17843
+
17844
+ function mixin(obj) {
17845
+ for (var key in Emitter.prototype) {
17846
+ obj[key] = Emitter.prototype[key];
17847
+ }
17848
+ return obj;
17849
+ }
17850
+
17851
+ /**
17852
+ * Listen on the given `event` with `fn`.
17853
+ *
17854
+ * @param {String} event
17855
+ * @param {Function} fn
17856
+ * @return {Emitter}
17857
+ * @api public
17858
+ */
17859
+
17860
+ Emitter.prototype.on =
17861
+ Emitter.prototype.addEventListener = function(event, fn){
17862
+ this._callbacks = this._callbacks || {};
17863
+ (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
17864
+ .push(fn);
17865
+ return this;
17866
+ };
17867
+
17868
+ /**
17869
+ * Adds an `event` listener that will be invoked a single
17870
+ * time then automatically removed.
17871
+ *
17872
+ * @param {String} event
17873
+ * @param {Function} fn
17874
+ * @return {Emitter}
17875
+ * @api public
17876
+ */
17877
+
17878
+ Emitter.prototype.once = function(event, fn){
17879
+ function on() {
17880
+ this.off(event, on);
17881
+ fn.apply(this, arguments);
17882
+ }
17883
+
17884
+ on.fn = fn;
17885
+ this.on(event, on);
17886
+ return this;
17887
+ };
17888
+
17889
+ /**
17890
+ * Remove the given callback for `event` or all
17891
+ * registered callbacks.
17892
+ *
17893
+ * @param {String} event
17894
+ * @param {Function} fn
17895
+ * @return {Emitter}
17896
+ * @api public
17897
+ */
17898
+
17899
+ Emitter.prototype.off =
17900
+ Emitter.prototype.removeListener =
17901
+ Emitter.prototype.removeAllListeners =
17902
+ Emitter.prototype.removeEventListener = function(event, fn){
17903
+ this._callbacks = this._callbacks || {};
17904
+
17905
+ // all
17906
+ if (0 == arguments.length) {
17907
+ this._callbacks = {};
17908
+ return this;
17909
+ }
17910
+
17911
+ // specific event
17912
+ var callbacks = this._callbacks['$' + event];
17913
+ if (!callbacks) return this;
17914
+
17915
+ // remove all handlers
17916
+ if (1 == arguments.length) {
17917
+ delete this._callbacks['$' + event];
17918
+ return this;
17919
+ }
17920
+
17921
+ // remove specific handler
17922
+ var cb;
17923
+ for (var i = 0; i < callbacks.length; i++) {
17924
+ cb = callbacks[i];
17925
+ if (cb === fn || cb.fn === fn) {
17926
+ callbacks.splice(i, 1);
17927
+ break;
17928
+ }
17929
+ }
17930
+ return this;
17931
+ };
17932
+
17933
+ /**
17934
+ * Emit `event` with the given args.
17935
+ *
17936
+ * @param {String} event
17937
+ * @param {Mixed} ...
17938
+ * @return {Emitter}
17939
+ */
17940
+
17941
+ Emitter.prototype.emit = function(event){
17942
+ this._callbacks = this._callbacks || {};
17943
+ var args = [].slice.call(arguments, 1)
17944
+ , callbacks = this._callbacks['$' + event];
17945
+
17946
+ if (callbacks) {
17947
+ callbacks = callbacks.slice(0);
17948
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
17949
+ callbacks[i].apply(this, args);
17950
+ }
17951
+ }
17952
+
17953
+ return this;
17954
+ };
17955
+
17956
+ /**
17957
+ * Return array of callbacks for `event`.
17958
+ *
17959
+ * @param {String} event
17960
+ * @return {Array}
17961
+ * @api public
17962
+ */
17963
+
17964
+ Emitter.prototype.listeners = function(event){
17965
+ this._callbacks = this._callbacks || {};
17966
+ return this._callbacks['$' + event] || [];
17967
+ };
17968
+
17969
+ /**
17970
+ * Check if this emitter has `event` handlers.
17971
+ *
17972
+ * @param {String} event
17973
+ * @return {Boolean}
17974
+ * @api public
17975
+ */
17976
+
17977
+ Emitter.prototype.hasListeners = function(event){
17978
+ return !! this.listeners(event).length;
17979
+ };
17994
17980
 
17995
17981
  },{}],41:[function(require,module,exports){
17996
17982
  // Copyright Joyent, Inc. and other Node contributors.
@@ -18296,8 +18282,6 @@ function isUndefined(arg) {
18296
18282
  }
18297
18283
 
18298
18284
  },{}],42:[function(require,module,exports){
18299
- 'use strict';
18300
-
18301
18285
  var hasOwn = Object.prototype.hasOwnProperty;
18302
18286
  var toStr = Object.prototype.toString;
18303
18287
  var defineProperty = Object.defineProperty;
@@ -18312,6 +18296,8 @@ var isArray = function isArray(arr) {
18312
18296
  };
18313
18297
 
18314
18298
  var isPlainObject = function isPlainObject(obj) {
18299
+ 'use strict';
18300
+
18315
18301
  if (!obj || toStr.call(obj) !== '[object Object]') {
18316
18302
  return false;
18317
18303
  }
@@ -18361,6 +18347,8 @@ var getProperty = function getProperty(obj, name) {
18361
18347
  };
18362
18348
 
18363
18349
  module.exports = function extend() {
18350
+ 'use strict';
18351
+
18364
18352
  var options, name, src, copy, copyIsArray, clone;
18365
18353
  var target = arguments[0];
18366
18354
  var i = 1;
@@ -20830,8 +20818,6 @@ function template(string) {
20830
20818
 
20831
20819
  var Emitter = require('emitter');
20832
20820
  var reduce = require('reduce');
20833
- var requestBase = require('./request-base');
20834
- var isObject = require('./is-object');
20835
20821
 
20836
20822
  /**
20837
20823
  * Root reference for iframes.
@@ -20853,10 +20839,28 @@ if (typeof window !== 'undefined') { // Browser window
20853
20839
  function noop(){};
20854
20840
 
20855
20841
  /**
20856
- * Expose `request`.
20842
+ * Check if `obj` is a host object,
20843
+ * we don't want to serialize these :)
20844
+ *
20845
+ * TODO: future proof, move to compoent land
20846
+ *
20847
+ * @param {Object} obj
20848
+ * @return {Boolean}
20849
+ * @api private
20857
20850
  */
20858
20851
 
20859
- var request = module.exports = require('./request').bind(null, Request);
20852
+ function isHost(obj) {
20853
+ var str = {}.toString.call(obj);
20854
+
20855
+ switch (str) {
20856
+ case '[object File]':
20857
+ case '[object Blob]':
20858
+ case '[object FormData]':
20859
+ return true;
20860
+ default:
20861
+ return false;
20862
+ }
20863
+ }
20860
20864
 
20861
20865
  /**
20862
20866
  * Determine XHR.
@@ -20888,6 +20892,18 @@ var trim = ''.trim
20888
20892
  ? function(s) { return s.trim(); }
20889
20893
  : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
20890
20894
 
20895
+ /**
20896
+ * Check if `obj` is an object.
20897
+ *
20898
+ * @param {Object} obj
20899
+ * @return {Boolean}
20900
+ * @api private
20901
+ */
20902
+
20903
+ function isObject(obj) {
20904
+ return obj === Object(obj);
20905
+ }
20906
+
20891
20907
  /**
20892
20908
  * Serialize the given `obj`.
20893
20909
  *
@@ -20902,8 +20918,8 @@ function serialize(obj) {
20902
20918
  for (var key in obj) {
20903
20919
  if (null != obj[key]) {
20904
20920
  pushEncodedKeyValuePair(pairs, key, obj[key]);
20905
- }
20906
- }
20921
+ }
20922
+ }
20907
20923
  return pairs.join('&');
20908
20924
  }
20909
20925
 
@@ -20921,11 +20937,6 @@ function pushEncodedKeyValuePair(pairs, key, val) {
20921
20937
  return val.forEach(function(v) {
20922
20938
  pushEncodedKeyValuePair(pairs, key, v);
20923
20939
  });
20924
- } else if (isObject(val)) {
20925
- for(var subkey in val) {
20926
- pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]);
20927
- }
20928
- return;
20929
20940
  }
20930
20941
  pairs.push(encodeURIComponent(key)
20931
20942
  + '=' + encodeURIComponent(val));
@@ -20948,18 +20959,13 @@ function pushEncodedKeyValuePair(pairs, key, val) {
20948
20959
  function parseString(str) {
20949
20960
  var obj = {};
20950
20961
  var pairs = str.split('&');
20962
+ var parts;
20951
20963
  var pair;
20952
- var pos;
20953
20964
 
20954
20965
  for (var i = 0, len = pairs.length; i < len; ++i) {
20955
20966
  pair = pairs[i];
20956
- pos = pair.indexOf('=');
20957
- if (pos == -1) {
20958
- obj[decodeURIComponent(pair)] = '';
20959
- } else {
20960
- obj[decodeURIComponent(pair.slice(0, pos))] =
20961
- decodeURIComponent(pair.slice(pos + 1));
20962
- }
20967
+ parts = pair.split('=');
20968
+ obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
20963
20969
  }
20964
20970
 
20965
20971
  return obj;
@@ -21143,15 +21149,15 @@ function Response(req, options) {
21143
21149
  ? this.xhr.responseText
21144
21150
  : null;
21145
21151
  this.statusText = this.req.xhr.statusText;
21146
- this._setStatusProperties(this.xhr.status);
21152
+ this.setStatusProperties(this.xhr.status);
21147
21153
  this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());
21148
21154
  // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
21149
21155
  // getResponseHeader still works. so we get content-type even if getting
21150
21156
  // other headers fails.
21151
21157
  this.header['content-type'] = this.xhr.getResponseHeader('content-type');
21152
- this._setHeaderProperties(this.header);
21158
+ this.setHeaderProperties(this.header);
21153
21159
  this.body = this.req.method != 'HEAD'
21154
- ? this._parseBody(this.text ? this.text : this.xhr.response)
21160
+ ? this.parseBody(this.text ? this.text : this.xhr.response)
21155
21161
  : null;
21156
21162
  }
21157
21163
 
@@ -21179,7 +21185,7 @@ Response.prototype.get = function(field){
21179
21185
  * @api private
21180
21186
  */
21181
21187
 
21182
- Response.prototype._setHeaderProperties = function(header){
21188
+ Response.prototype.setHeaderProperties = function(header){
21183
21189
  // content-type
21184
21190
  var ct = this.header['content-type'] || '';
21185
21191
  this.type = type(ct);
@@ -21200,11 +21206,8 @@ Response.prototype._setHeaderProperties = function(header){
21200
21206
  * @api private
21201
21207
  */
21202
21208
 
21203
- Response.prototype._parseBody = function(str){
21209
+ Response.prototype.parseBody = function(str){
21204
21210
  var parse = request.parse[this.type];
21205
- if (!parse && isJSON(this.type)) {
21206
- parse = request.parse['application/json'];
21207
- }
21208
21211
  return parse && str && (str.length || str instanceof Object)
21209
21212
  ? parse(str)
21210
21213
  : null;
@@ -21231,7 +21234,7 @@ Response.prototype._parseBody = function(str){
21231
21234
  * @api private
21232
21235
  */
21233
21236
 
21234
- Response.prototype._setStatusProperties = function(status){
21237
+ Response.prototype.setStatusProperties = function(status){
21235
21238
  // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
21236
21239
  if (status === 1223) {
21237
21240
  status = 204;
@@ -21299,11 +21302,12 @@ request.Response = Response;
21299
21302
 
21300
21303
  function Request(method, url) {
21301
21304
  var self = this;
21305
+ Emitter.call(this);
21302
21306
  this._query = this._query || [];
21303
21307
  this.method = method;
21304
21308
  this.url = url;
21305
- this.header = {}; // preserves header name case
21306
- this._header = {}; // coerces header names to lowercase
21309
+ this.header = {};
21310
+ this._header = {};
21307
21311
  this.on('end', function(){
21308
21312
  var err = null;
21309
21313
  var res = null;
@@ -21316,8 +21320,6 @@ function Request(method, url) {
21316
21320
  err.original = e;
21317
21321
  // issue #675: return the raw response if the response parsing fails
21318
21322
  err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;
21319
- // issue #876: return the http status code if the response parsing fails
21320
- err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;
21321
21323
  return self.callback(err);
21322
21324
  }
21323
21325
 
@@ -21327,88 +21329,190 @@ function Request(method, url) {
21327
21329
  return self.callback(err, res);
21328
21330
  }
21329
21331
 
21330
- try {
21331
- if (res.status >= 200 && res.status < 300) {
21332
- return self.callback(err, res);
21333
- }
21332
+ if (res.status >= 200 && res.status < 300) {
21333
+ return self.callback(err, res);
21334
+ }
21334
21335
 
21335
- var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21336
- new_err.original = err;
21337
- new_err.response = res;
21338
- new_err.status = res.status;
21336
+ var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21337
+ new_err.original = err;
21338
+ new_err.response = res;
21339
+ new_err.status = res.status;
21339
21340
 
21340
- self.callback(new_err, res);
21341
- } catch(e) {
21342
- self.callback(e); // #985 touching res may cause INVALID_STATE_ERR on old Android
21343
- }
21341
+ self.callback(new_err, res);
21344
21342
  });
21345
21343
  }
21346
21344
 
21347
21345
  /**
21348
- * Mixin `Emitter` and `requestBase`.
21346
+ * Mixin `Emitter`.
21349
21347
  */
21350
21348
 
21351
21349
  Emitter(Request.prototype);
21352
- for (var key in requestBase) {
21353
- Request.prototype[key] = requestBase[key];
21350
+
21351
+ /**
21352
+ * Allow for extension
21353
+ */
21354
+
21355
+ Request.prototype.use = function(fn) {
21356
+ fn(this);
21357
+ return this;
21354
21358
  }
21355
21359
 
21356
21360
  /**
21357
- * Set Content-Type to `type`, mapping values from `request.types`.
21358
- *
21359
- * Examples:
21360
- *
21361
- * superagent.types.xml = 'application/xml';
21362
- *
21363
- * request.post('/')
21364
- * .type('xml')
21365
- * .send(xmlstring)
21366
- * .end(callback);
21367
- *
21368
- * request.post('/')
21369
- * .type('application/xml')
21370
- * .send(xmlstring)
21371
- * .end(callback);
21361
+ * Set timeout to `ms`.
21372
21362
  *
21373
- * @param {String} type
21363
+ * @param {Number} ms
21374
21364
  * @return {Request} for chaining
21375
21365
  * @api public
21376
21366
  */
21377
21367
 
21378
- Request.prototype.type = function(type){
21379
- this.set('Content-Type', request.types[type] || type);
21368
+ Request.prototype.timeout = function(ms){
21369
+ this._timeout = ms;
21380
21370
  return this;
21381
21371
  };
21382
21372
 
21383
21373
  /**
21384
- * Set responseType to `val`. Presently valid responseTypes are 'blob' and
21385
- * 'arraybuffer'.
21386
- *
21387
- * Examples:
21388
- *
21389
- * req.get('/')
21390
- * .responseType('blob')
21391
- * .end(callback);
21374
+ * Clear previous timeout.
21392
21375
  *
21393
- * @param {String} val
21394
21376
  * @return {Request} for chaining
21395
21377
  * @api public
21396
21378
  */
21397
21379
 
21398
- Request.prototype.responseType = function(val){
21399
- this._responseType = val;
21380
+ Request.prototype.clearTimeout = function(){
21381
+ this._timeout = 0;
21382
+ clearTimeout(this._timer);
21400
21383
  return this;
21401
21384
  };
21402
21385
 
21403
21386
  /**
21404
- * Set Accept to `type`, mapping values from `request.types`.
21405
- *
21406
- * Examples:
21407
- *
21408
- * superagent.types.json = 'application/json';
21387
+ * Abort the request, and clear potential timeout.
21409
21388
  *
21410
- * request.get('/agent')
21411
- * .accept('json')
21389
+ * @return {Request}
21390
+ * @api public
21391
+ */
21392
+
21393
+ Request.prototype.abort = function(){
21394
+ if (this.aborted) return;
21395
+ this.aborted = true;
21396
+ this.xhr.abort();
21397
+ this.clearTimeout();
21398
+ this.emit('abort');
21399
+ return this;
21400
+ };
21401
+
21402
+ /**
21403
+ * Set header `field` to `val`, or multiple fields with one object.
21404
+ *
21405
+ * Examples:
21406
+ *
21407
+ * req.get('/')
21408
+ * .set('Accept', 'application/json')
21409
+ * .set('X-API-Key', 'foobar')
21410
+ * .end(callback);
21411
+ *
21412
+ * req.get('/')
21413
+ * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
21414
+ * .end(callback);
21415
+ *
21416
+ * @param {String|Object} field
21417
+ * @param {String} val
21418
+ * @return {Request} for chaining
21419
+ * @api public
21420
+ */
21421
+
21422
+ Request.prototype.set = function(field, val){
21423
+ if (isObject(field)) {
21424
+ for (var key in field) {
21425
+ this.set(key, field[key]);
21426
+ }
21427
+ return this;
21428
+ }
21429
+ this._header[field.toLowerCase()] = val;
21430
+ this.header[field] = val;
21431
+ return this;
21432
+ };
21433
+
21434
+ /**
21435
+ * Remove header `field`.
21436
+ *
21437
+ * Example:
21438
+ *
21439
+ * req.get('/')
21440
+ * .unset('User-Agent')
21441
+ * .end(callback);
21442
+ *
21443
+ * @param {String} field
21444
+ * @return {Request} for chaining
21445
+ * @api public
21446
+ */
21447
+
21448
+ Request.prototype.unset = function(field){
21449
+ delete this._header[field.toLowerCase()];
21450
+ delete this.header[field];
21451
+ return this;
21452
+ };
21453
+
21454
+ /**
21455
+ * Get case-insensitive header `field` value.
21456
+ *
21457
+ * @param {String} field
21458
+ * @return {String}
21459
+ * @api private
21460
+ */
21461
+
21462
+ Request.prototype.getHeader = function(field){
21463
+ return this._header[field.toLowerCase()];
21464
+ };
21465
+
21466
+ /**
21467
+ * Set Content-Type to `type`, mapping values from `request.types`.
21468
+ *
21469
+ * Examples:
21470
+ *
21471
+ * superagent.types.xml = 'application/xml';
21472
+ *
21473
+ * request.post('/')
21474
+ * .type('xml')
21475
+ * .send(xmlstring)
21476
+ * .end(callback);
21477
+ *
21478
+ * request.post('/')
21479
+ * .type('application/xml')
21480
+ * .send(xmlstring)
21481
+ * .end(callback);
21482
+ *
21483
+ * @param {String} type
21484
+ * @return {Request} for chaining
21485
+ * @api public
21486
+ */
21487
+
21488
+ Request.prototype.type = function(type){
21489
+ this.set('Content-Type', request.types[type] || type);
21490
+ return this;
21491
+ };
21492
+
21493
+ /**
21494
+ * Force given parser
21495
+ *
21496
+ * Sets the body parser no matter type.
21497
+ *
21498
+ * @param {Function}
21499
+ * @api public
21500
+ */
21501
+
21502
+ Request.prototype.parse = function(fn){
21503
+ this._parser = fn;
21504
+ return this;
21505
+ };
21506
+
21507
+ /**
21508
+ * Set Accept to `type`, mapping values from `request.types`.
21509
+ *
21510
+ * Examples:
21511
+ *
21512
+ * superagent.types.json = 'application/json';
21513
+ *
21514
+ * request.get('/agent')
21515
+ * .accept('json')
21412
21516
  * .end(callback);
21413
21517
  *
21414
21518
  * request.get('/agent')
@@ -21430,29 +21534,13 @@ Request.prototype.accept = function(type){
21430
21534
  *
21431
21535
  * @param {String} user
21432
21536
  * @param {String} pass
21433
- * @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic')
21434
21537
  * @return {Request} for chaining
21435
21538
  * @api public
21436
21539
  */
21437
21540
 
21438
- Request.prototype.auth = function(user, pass, options){
21439
- if (!options) {
21440
- options = {
21441
- type: 'basic'
21442
- }
21443
- }
21444
-
21445
- switch (options.type) {
21446
- case 'basic':
21447
- var str = btoa(user + ':' + pass);
21448
- this.set('Authorization', 'Basic ' + str);
21449
- break;
21450
-
21451
- case 'auto':
21452
- this.username = user;
21453
- this.password = pass;
21454
- break;
21455
- }
21541
+ Request.prototype.auth = function(user, pass){
21542
+ var str = btoa(user + ':' + pass);
21543
+ this.set('Authorization', 'Basic ' + str);
21456
21544
  return this;
21457
21545
  };
21458
21546
 
@@ -21476,13 +21564,35 @@ Request.prototype.query = function(val){
21476
21564
  return this;
21477
21565
  };
21478
21566
 
21567
+ /**
21568
+ * Write the field `name` and `val` for "multipart/form-data"
21569
+ * request bodies.
21570
+ *
21571
+ * ``` js
21572
+ * request.post('/upload')
21573
+ * .field('foo', 'bar')
21574
+ * .end(callback);
21575
+ * ```
21576
+ *
21577
+ * @param {String} name
21578
+ * @param {String|Blob|File} val
21579
+ * @return {Request} for chaining
21580
+ * @api public
21581
+ */
21582
+
21583
+ Request.prototype.field = function(name, val){
21584
+ if (!this._formData) this._formData = new root.FormData();
21585
+ this._formData.append(name, val);
21586
+ return this;
21587
+ };
21588
+
21479
21589
  /**
21480
21590
  * Queue the given `file` as an attachment to the specified `field`,
21481
21591
  * with optional `filename`.
21482
21592
  *
21483
21593
  * ``` js
21484
21594
  * request.post('/upload')
21485
- * .attach('content', new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
21595
+ * .attach(new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
21486
21596
  * .end(callback);
21487
21597
  * ```
21488
21598
  *
@@ -21494,15 +21604,77 @@ Request.prototype.query = function(val){
21494
21604
  */
21495
21605
 
21496
21606
  Request.prototype.attach = function(field, file, filename){
21497
- this._getFormData().append(field, file, filename || file.name);
21607
+ if (!this._formData) this._formData = new root.FormData();
21608
+ this._formData.append(field, file, filename || file.name);
21498
21609
  return this;
21499
21610
  };
21500
21611
 
21501
- Request.prototype._getFormData = function(){
21502
- if (!this._formData) {
21503
- this._formData = new root.FormData();
21612
+ /**
21613
+ * Send `data` as the request body, defaulting the `.type()` to "json" when
21614
+ * an object is given.
21615
+ *
21616
+ * Examples:
21617
+ *
21618
+ * // manual json
21619
+ * request.post('/user')
21620
+ * .type('json')
21621
+ * .send('{"name":"tj"}')
21622
+ * .end(callback)
21623
+ *
21624
+ * // auto json
21625
+ * request.post('/user')
21626
+ * .send({ name: 'tj' })
21627
+ * .end(callback)
21628
+ *
21629
+ * // manual x-www-form-urlencoded
21630
+ * request.post('/user')
21631
+ * .type('form')
21632
+ * .send('name=tj')
21633
+ * .end(callback)
21634
+ *
21635
+ * // auto x-www-form-urlencoded
21636
+ * request.post('/user')
21637
+ * .type('form')
21638
+ * .send({ name: 'tj' })
21639
+ * .end(callback)
21640
+ *
21641
+ * // defaults to x-www-form-urlencoded
21642
+ * request.post('/user')
21643
+ * .send('name=tobi')
21644
+ * .send('species=ferret')
21645
+ * .end(callback)
21646
+ *
21647
+ * @param {String|Object} data
21648
+ * @return {Request} for chaining
21649
+ * @api public
21650
+ */
21651
+
21652
+ Request.prototype.send = function(data){
21653
+ var obj = isObject(data);
21654
+ var type = this.getHeader('Content-Type');
21655
+
21656
+ // merge
21657
+ if (obj && isObject(this._data)) {
21658
+ for (var key in data) {
21659
+ this._data[key] = data[key];
21660
+ }
21661
+ } else if ('string' == typeof data) {
21662
+ if (!type) this.type('form');
21663
+ type = this.getHeader('Content-Type');
21664
+ if ('application/x-www-form-urlencoded' == type) {
21665
+ this._data = this._data
21666
+ ? this._data + '&' + data
21667
+ : data;
21668
+ } else {
21669
+ this._data = (this._data || '') + data;
21670
+ }
21671
+ } else {
21672
+ this._data = data;
21504
21673
  }
21505
- return this._formData;
21674
+
21675
+ if (!obj || isHost(data)) return this;
21676
+ if (!type) this.type('json');
21677
+ return this;
21506
21678
  };
21507
21679
 
21508
21680
  /**
@@ -21543,7 +21715,7 @@ Request.prototype.crossDomainError = function(){
21543
21715
  * @api private
21544
21716
  */
21545
21717
 
21546
- Request.prototype._timeoutError = function(){
21718
+ Request.prototype.timeoutError = function(){
21547
21719
  var timeout = this._timeout;
21548
21720
  var err = new Error('timeout of ' + timeout + 'ms exceeded');
21549
21721
  err.timeout = timeout;
@@ -21551,18 +21723,19 @@ Request.prototype._timeoutError = function(){
21551
21723
  };
21552
21724
 
21553
21725
  /**
21554
- * Compose querystring to append to req.url
21726
+ * Enable transmission of cookies with x-domain requests.
21555
21727
  *
21556
- * @api private
21728
+ * Note that for this to work the origin must not be
21729
+ * using "Access-Control-Allow-Origin" with a wildcard,
21730
+ * and also must set "Access-Control-Allow-Credentials"
21731
+ * to "true".
21732
+ *
21733
+ * @api public
21557
21734
  */
21558
21735
 
21559
- Request.prototype._appendQueryString = function(){
21560
- var query = this._query.join('&');
21561
- if (query) {
21562
- this.url += ~this.url.indexOf('?')
21563
- ? '&' + query
21564
- : '?' + query;
21565
- }
21736
+ Request.prototype.withCredentials = function(){
21737
+ this._withCredentials = true;
21738
+ return this;
21566
21739
  };
21567
21740
 
21568
21741
  /**
@@ -21577,6 +21750,7 @@ Request.prototype._appendQueryString = function(){
21577
21750
  Request.prototype.end = function(fn){
21578
21751
  var self = this;
21579
21752
  var xhr = this.xhr = request.getXHR();
21753
+ var query = this._query.join('&');
21580
21754
  var timeout = this._timeout;
21581
21755
  var data = this._formData || this._data;
21582
21756
 
@@ -21593,8 +21767,8 @@ Request.prototype.end = function(fn){
21593
21767
  try { status = xhr.status } catch(e) { status = 0; }
21594
21768
 
21595
21769
  if (0 == status) {
21596
- if (self.timedout) return self._timeoutError();
21597
- if (self._aborted) return;
21770
+ if (self.timedout) return self.timeoutError();
21771
+ if (self.aborted) return;
21598
21772
  return self.crossDomainError();
21599
21773
  }
21600
21774
  self.emit('end');
@@ -21630,23 +21804,24 @@ Request.prototype.end = function(fn){
21630
21804
  }
21631
21805
 
21632
21806
  // querystring
21633
- this._appendQueryString();
21807
+ if (query) {
21808
+ query = request.serializeObject(query);
21809
+ this.url += ~this.url.indexOf('?')
21810
+ ? '&' + query
21811
+ : '?' + query;
21812
+ }
21634
21813
 
21635
21814
  // initiate request
21636
- if (this.username && this.password) {
21637
- xhr.open(this.method, this.url, true, this.username, this.password);
21638
- } else {
21639
- xhr.open(this.method, this.url, true);
21640
- }
21815
+ xhr.open(this.method, this.url, true);
21641
21816
 
21642
21817
  // CORS
21643
21818
  if (this._withCredentials) xhr.withCredentials = true;
21644
21819
 
21645
21820
  // body
21646
- if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) {
21821
+ if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
21647
21822
  // serialize stuff
21648
- var contentType = this._header['content-type'];
21649
- var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
21823
+ var contentType = this.getHeader('Content-Type');
21824
+ var serialize = this._parser || request.serialize[contentType ? contentType.split(';')[0] : ''];
21650
21825
  if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json'];
21651
21826
  if (serialize) data = serialize(data);
21652
21827
  }
@@ -21657,10 +21832,6 @@ Request.prototype.end = function(fn){
21657
21832
  xhr.setRequestHeader(field, this.header[field]);
21658
21833
  }
21659
21834
 
21660
- if (this._responseType) {
21661
- xhr.responseType = this._responseType;
21662
- }
21663
-
21664
21835
  // send stuff
21665
21836
  this.emit('request', this);
21666
21837
 
@@ -21670,6 +21841,19 @@ Request.prototype.end = function(fn){
21670
21841
  return this;
21671
21842
  };
21672
21843
 
21844
+ /**
21845
+ * Faux promise support
21846
+ *
21847
+ * @param {Function} fulfill
21848
+ * @param {Function} reject
21849
+ * @return {Request}
21850
+ */
21851
+
21852
+ Request.prototype.then = function (fulfill, reject) {
21853
+ return this.end(function(err, res) {
21854
+ err ? reject(err) : fulfill(res);
21855
+ });
21856
+ }
21673
21857
 
21674
21858
  /**
21675
21859
  * Expose `Request`.
@@ -21677,6 +21861,35 @@ Request.prototype.end = function(fn){
21677
21861
 
21678
21862
  request.Request = Request;
21679
21863
 
21864
+ /**
21865
+ * Issue a request:
21866
+ *
21867
+ * Examples:
21868
+ *
21869
+ * request('GET', '/users').end(callback)
21870
+ * request('/users').end(callback)
21871
+ * request('/users', callback)
21872
+ *
21873
+ * @param {String} method
21874
+ * @param {String|Function} url or callback
21875
+ * @return {Request}
21876
+ * @api public
21877
+ */
21878
+
21879
+ function request(method, url) {
21880
+ // callback
21881
+ if ('function' == typeof url) {
21882
+ return new Request('GET', method).end(url);
21883
+ }
21884
+
21885
+ // url first
21886
+ if (1 == arguments.length) {
21887
+ return new Request('GET', method);
21888
+ }
21889
+
21890
+ return new Request(method, url);
21891
+ }
21892
+
21680
21893
  /**
21681
21894
  * GET `url` with optional callback `fn(res)`.
21682
21895
  *
@@ -21714,25 +21927,7 @@ request.head = function(url, data, fn){
21714
21927
  };
21715
21928
 
21716
21929
  /**
21717
- * OPTIONS query to `url` with optional callback `fn(res)`.
21718
- *
21719
- * @param {String} url
21720
- * @param {Mixed|Function} data or fn
21721
- * @param {Function} fn
21722
- * @return {Request}
21723
- * @api public
21724
- */
21725
-
21726
- request.options = function(url, data, fn){
21727
- var req = request('OPTIONS', url);
21728
- if ('function' == typeof data) fn = data, data = null;
21729
- if (data) req.send(data);
21730
- if (fn) req.end(fn);
21731
- return req;
21732
- };
21733
-
21734
- /**
21735
- * DELETE `url` with optional callback `fn(res)`.
21930
+ * DELETE `url` with optional callback `fn(res)`.
21736
21931
  *
21737
21932
  * @param {String} url
21738
21933
  * @param {Function} fn
@@ -21803,404 +21998,13 @@ request.put = function(url, data, fn){
21803
21998
  return req;
21804
21999
  };
21805
22000
 
21806
- },{"./is-object":50,"./request":52,"./request-base":51,"emitter":40,"reduce":47}],50:[function(require,module,exports){
21807
- /**
21808
- * Check if `obj` is an object.
21809
- *
21810
- * @param {Object} obj
21811
- * @return {Boolean}
21812
- * @api private
21813
- */
21814
-
21815
- function isObject(obj) {
21816
- return null !== obj && 'object' === typeof obj;
21817
- }
21818
-
21819
- module.exports = isObject;
21820
-
21821
- },{}],51:[function(require,module,exports){
21822
- /**
21823
- * Module of mixed-in functions shared between node and client code
21824
- */
21825
- var isObject = require('./is-object');
21826
-
21827
- /**
21828
- * Clear previous timeout.
21829
- *
21830
- * @return {Request} for chaining
21831
- * @api public
21832
- */
21833
-
21834
- exports.clearTimeout = function _clearTimeout(){
21835
- this._timeout = 0;
21836
- clearTimeout(this._timer);
21837
- return this;
21838
- };
21839
-
21840
- /**
21841
- * Override default response body parser
21842
- *
21843
- * This function will be called to convert incoming data into request.body
21844
- *
21845
- * @param {Function}
21846
- * @api public
21847
- */
21848
-
21849
- exports.parse = function parse(fn){
21850
- this._parser = fn;
21851
- return this;
21852
- };
21853
-
21854
- /**
21855
- * Override default request body serializer
21856
- *
21857
- * This function will be called to convert data set via .send or .attach into payload to send
21858
- *
21859
- * @param {Function}
21860
- * @api public
21861
- */
21862
-
21863
- exports.serialize = function serialize(fn){
21864
- this._serializer = fn;
21865
- return this;
21866
- };
21867
-
21868
22001
  /**
21869
- * Set timeout to `ms`.
21870
- *
21871
- * @param {Number} ms
21872
- * @return {Request} for chaining
21873
- * @api public
21874
- */
21875
-
21876
- exports.timeout = function timeout(ms){
21877
- this._timeout = ms;
21878
- return this;
21879
- };
21880
-
21881
- /**
21882
- * Promise support
21883
- *
21884
- * @param {Function} resolve
21885
- * @param {Function} reject
21886
- * @return {Request}
21887
- */
21888
-
21889
- exports.then = function then(resolve, reject) {
21890
- if (!this._fullfilledPromise) {
21891
- var self = this;
21892
- this._fullfilledPromise = new Promise(function(innerResolve, innerReject){
21893
- self.end(function(err, res){
21894
- if (err) innerReject(err); else innerResolve(res);
21895
- });
21896
- });
21897
- }
21898
- return this._fullfilledPromise.then(resolve, reject);
21899
- }
21900
-
21901
- /**
21902
- * Allow for extension
21903
- */
21904
-
21905
- exports.use = function use(fn) {
21906
- fn(this);
21907
- return this;
21908
- }
21909
-
21910
-
21911
- /**
21912
- * Get request header `field`.
21913
- * Case-insensitive.
21914
- *
21915
- * @param {String} field
21916
- * @return {String}
21917
- * @api public
21918
- */
21919
-
21920
- exports.get = function(field){
21921
- return this._header[field.toLowerCase()];
21922
- };
21923
-
21924
- /**
21925
- * Get case-insensitive header `field` value.
21926
- * This is a deprecated internal API. Use `.get(field)` instead.
21927
- *
21928
- * (getHeader is no longer used internally by the superagent code base)
21929
- *
21930
- * @param {String} field
21931
- * @return {String}
21932
- * @api private
21933
- * @deprecated
21934
- */
21935
-
21936
- exports.getHeader = exports.get;
21937
-
21938
- /**
21939
- * Set header `field` to `val`, or multiple fields with one object.
21940
- * Case-insensitive.
21941
- *
21942
- * Examples:
21943
- *
21944
- * req.get('/')
21945
- * .set('Accept', 'application/json')
21946
- * .set('X-API-Key', 'foobar')
21947
- * .end(callback);
21948
- *
21949
- * req.get('/')
21950
- * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
21951
- * .end(callback);
21952
- *
21953
- * @param {String|Object} field
21954
- * @param {String} val
21955
- * @return {Request} for chaining
21956
- * @api public
21957
- */
21958
-
21959
- exports.set = function(field, val){
21960
- if (isObject(field)) {
21961
- for (var key in field) {
21962
- this.set(key, field[key]);
21963
- }
21964
- return this;
21965
- }
21966
- this._header[field.toLowerCase()] = val;
21967
- this.header[field] = val;
21968
- return this;
21969
- };
21970
-
21971
- /**
21972
- * Remove header `field`.
21973
- * Case-insensitive.
21974
- *
21975
- * Example:
21976
- *
21977
- * req.get('/')
21978
- * .unset('User-Agent')
21979
- * .end(callback);
21980
- *
21981
- * @param {String} field
21982
- */
21983
- exports.unset = function(field){
21984
- delete this._header[field.toLowerCase()];
21985
- delete this.header[field];
21986
- return this;
21987
- };
21988
-
21989
- /**
21990
- * Write the field `name` and `val` for "multipart/form-data"
21991
- * request bodies.
21992
- *
21993
- * ``` js
21994
- * request.post('/upload')
21995
- * .field('foo', 'bar')
21996
- * .end(callback);
21997
- * ```
21998
- *
21999
- * @param {String} name
22000
- * @param {String|Blob|File|Buffer|fs.ReadStream} val
22001
- * @return {Request} for chaining
22002
- * @api public
22003
- */
22004
- exports.field = function(name, val) {
22005
- this._getFormData().append(name, val);
22006
- return this;
22007
- };
22008
-
22009
- /**
22010
- * Abort the request, and clear potential timeout.
22011
- *
22012
- * @return {Request}
22013
- * @api public
22014
- */
22015
- exports.abort = function(){
22016
- if (this._aborted) {
22017
- return this;
22018
- }
22019
- this._aborted = true;
22020
- this.xhr && this.xhr.abort(); // browser
22021
- this.req && this.req.abort(); // node
22022
- this.clearTimeout();
22023
- this.emit('abort');
22024
- return this;
22025
- };
22026
-
22027
- /**
22028
- * Enable transmission of cookies with x-domain requests.
22029
- *
22030
- * Note that for this to work the origin must not be
22031
- * using "Access-Control-Allow-Origin" with a wildcard,
22032
- * and also must set "Access-Control-Allow-Credentials"
22033
- * to "true".
22034
- *
22035
- * @api public
22036
- */
22037
-
22038
- exports.withCredentials = function(){
22039
- // This is browser-only functionality. Node side is no-op.
22040
- this._withCredentials = true;
22041
- return this;
22042
- };
22043
-
22044
- /**
22045
- * Set the max redirects to `n`. Does noting in browser XHR implementation.
22046
- *
22047
- * @param {Number} n
22048
- * @return {Request} for chaining
22049
- * @api public
22050
- */
22051
-
22052
- exports.redirects = function(n){
22053
- this._maxRedirects = n;
22054
- return this;
22055
- };
22056
-
22057
- /**
22058
- * Convert to a plain javascript object (not JSON string) of scalar properties.
22059
- * Note as this method is designed to return a useful non-this value,
22060
- * it cannot be chained.
22061
- *
22062
- * @return {Object} describing method, url, and data of this request
22063
- * @api public
22064
- */
22065
-
22066
- exports.toJSON = function(){
22067
- return {
22068
- method: this.method,
22069
- url: this.url,
22070
- data: this._data
22071
- };
22072
- };
22073
-
22074
- /**
22075
- * Check if `obj` is a host object,
22076
- * we don't want to serialize these :)
22077
- *
22078
- * TODO: future proof, move to compoent land
22079
- *
22080
- * @param {Object} obj
22081
- * @return {Boolean}
22082
- * @api private
22083
- */
22084
-
22085
- exports._isHost = function _isHost(obj) {
22086
- var str = {}.toString.call(obj);
22087
-
22088
- switch (str) {
22089
- case '[object File]':
22090
- case '[object Blob]':
22091
- case '[object FormData]':
22092
- return true;
22093
- default:
22094
- return false;
22095
- }
22096
- }
22097
-
22098
- /**
22099
- * Send `data` as the request body, defaulting the `.type()` to "json" when
22100
- * an object is given.
22101
- *
22102
- * Examples:
22103
- *
22104
- * // manual json
22105
- * request.post('/user')
22106
- * .type('json')
22107
- * .send('{"name":"tj"}')
22108
- * .end(callback)
22109
- *
22110
- * // auto json
22111
- * request.post('/user')
22112
- * .send({ name: 'tj' })
22113
- * .end(callback)
22114
- *
22115
- * // manual x-www-form-urlencoded
22116
- * request.post('/user')
22117
- * .type('form')
22118
- * .send('name=tj')
22119
- * .end(callback)
22120
- *
22121
- * // auto x-www-form-urlencoded
22122
- * request.post('/user')
22123
- * .type('form')
22124
- * .send({ name: 'tj' })
22125
- * .end(callback)
22126
- *
22127
- * // defaults to x-www-form-urlencoded
22128
- * request.post('/user')
22129
- * .send('name=tobi')
22130
- * .send('species=ferret')
22131
- * .end(callback)
22132
- *
22133
- * @param {String|Object} data
22134
- * @return {Request} for chaining
22135
- * @api public
22136
- */
22137
-
22138
- exports.send = function(data){
22139
- var obj = isObject(data);
22140
- var type = this._header['content-type'];
22141
-
22142
- // merge
22143
- if (obj && isObject(this._data)) {
22144
- for (var key in data) {
22145
- this._data[key] = data[key];
22146
- }
22147
- } else if ('string' == typeof data) {
22148
- // default to x-www-form-urlencoded
22149
- if (!type) this.type('form');
22150
- type = this._header['content-type'];
22151
- if ('application/x-www-form-urlencoded' == type) {
22152
- this._data = this._data
22153
- ? this._data + '&' + data
22154
- : data;
22155
- } else {
22156
- this._data = (this._data || '') + data;
22157
- }
22158
- } else {
22159
- this._data = data;
22160
- }
22161
-
22162
- if (!obj || this._isHost(data)) return this;
22163
-
22164
- // default to json
22165
- if (!type) this.type('json');
22166
- return this;
22167
- };
22168
-
22169
- },{"./is-object":50}],52:[function(require,module,exports){
22170
- // The node and browser modules expose versions of this with the
22171
- // appropriate constructor function bound as first argument
22172
- /**
22173
- * Issue a request:
22174
- *
22175
- * Examples:
22176
- *
22177
- * request('GET', '/users').end(callback)
22178
- * request('/users').end(callback)
22179
- * request('/users', callback)
22180
- *
22181
- * @param {String} method
22182
- * @param {String|Function} url or callback
22183
- * @return {Request}
22184
- * @api public
22002
+ * Expose `request`.
22185
22003
  */
22186
22004
 
22187
- function request(RequestConstructor, method, url) {
22188
- // callback
22189
- if ('function' == typeof url) {
22190
- return new RequestConstructor('GET', method).end(url);
22191
- }
22192
-
22193
- // url first
22194
- if (2 == arguments.length) {
22195
- return new RequestConstructor('GET', method);
22196
- }
22197
-
22198
- return new RequestConstructor(method, url);
22199
- }
22200
-
22201
22005
  module.exports = request;
22202
22006
 
22203
- },{}],53:[function(require,module,exports){
22007
+ },{"emitter":40,"reduce":47}],50:[function(require,module,exports){
22204
22008
  /*!
22205
22009
  * validate.js 0.9.0
22206
22010
  *