comprodls-sdk 2.67.1 → 2.68.0-development

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.
@@ -1150,7 +1150,7 @@ validator.validators.contains = function(value, options) {
1150
1150
  }
1151
1151
  }
1152
1152
  };
1153
- },{"./errors":7,"validate.js":53}],10:[function(require,module,exports){
1153
+ },{"./errors":7,"validate.js":50}],10:[function(require,module,exports){
1154
1154
  /*************************************************************************
1155
1155
  *
1156
1156
  * COMPRO CONFIDENTIAL
@@ -18210,181 +18210,167 @@ module.exports = Array.isArray || function (arr) {
18210
18210
  };
18211
18211
 
18212
18212
  },{}],40:[function(require,module,exports){
18213
-
18214
- /**
18215
- * Expose `Emitter`.
18216
- */
18217
-
18218
- if (typeof module !== 'undefined') {
18219
- module.exports = Emitter;
18220
- }
18221
-
18222
- /**
18223
- * Initialize a new `Emitter`.
18224
- *
18225
- * @api public
18226
- */
18227
-
18228
- function Emitter(obj) {
18229
- if (obj) return mixin(obj);
18230
- };
18231
-
18232
- /**
18233
- * Mixin the emitter properties.
18234
- *
18235
- * @param {Object} obj
18236
- * @return {Object}
18237
- * @api private
18238
- */
18239
-
18240
- function mixin(obj) {
18241
- for (var key in Emitter.prototype) {
18242
- obj[key] = Emitter.prototype[key];
18243
- }
18244
- return obj;
18245
- }
18246
-
18247
- /**
18248
- * Listen on the given `event` with `fn`.
18249
- *
18250
- * @param {String} event
18251
- * @param {Function} fn
18252
- * @return {Emitter}
18253
- * @api public
18254
- */
18255
-
18256
- Emitter.prototype.on =
18257
- Emitter.prototype.addEventListener = function(event, fn){
18258
- this._callbacks = this._callbacks || {};
18259
- (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
18260
- .push(fn);
18261
- return this;
18262
- };
18263
-
18264
- /**
18265
- * Adds an `event` listener that will be invoked a single
18266
- * time then automatically removed.
18267
- *
18268
- * @param {String} event
18269
- * @param {Function} fn
18270
- * @return {Emitter}
18271
- * @api public
18272
- */
18273
-
18274
- Emitter.prototype.once = function(event, fn){
18275
- function on() {
18276
- this.off(event, on);
18277
- fn.apply(this, arguments);
18278
- }
18279
-
18280
- on.fn = fn;
18281
- this.on(event, on);
18282
- return this;
18283
- };
18284
-
18285
- /**
18286
- * Remove the given callback for `event` or all
18287
- * registered callbacks.
18288
- *
18289
- * @param {String} event
18290
- * @param {Function} fn
18291
- * @return {Emitter}
18292
- * @api public
18293
- */
18294
-
18295
- Emitter.prototype.off =
18296
- Emitter.prototype.removeListener =
18297
- Emitter.prototype.removeAllListeners =
18298
- Emitter.prototype.removeEventListener = function(event, fn){
18299
- this._callbacks = this._callbacks || {};
18300
-
18301
- // all
18302
- if (0 == arguments.length) {
18303
- this._callbacks = {};
18304
- return this;
18305
- }
18306
-
18307
- // specific event
18308
- var callbacks = this._callbacks['$' + event];
18309
- if (!callbacks) return this;
18310
-
18311
- // remove all handlers
18312
- if (1 == arguments.length) {
18313
- delete this._callbacks['$' + event];
18314
- return this;
18315
- }
18316
-
18317
- // remove specific handler
18318
- var cb;
18319
- for (var i = 0; i < callbacks.length; i++) {
18320
- cb = callbacks[i];
18321
- if (cb === fn || cb.fn === fn) {
18322
- callbacks.splice(i, 1);
18323
- break;
18324
- }
18325
- }
18326
-
18327
- // Remove event specific arrays for event types that no
18328
- // one is subscribed for to avoid memory leak.
18329
- if (callbacks.length === 0) {
18330
- delete this._callbacks['$' + event];
18331
- }
18332
-
18333
- return this;
18334
- };
18335
-
18336
- /**
18337
- * Emit `event` with the given args.
18338
- *
18339
- * @param {String} event
18340
- * @param {Mixed} ...
18341
- * @return {Emitter}
18342
- */
18343
-
18344
- Emitter.prototype.emit = function(event){
18345
- this._callbacks = this._callbacks || {};
18346
-
18347
- var args = new Array(arguments.length - 1)
18348
- , callbacks = this._callbacks['$' + event];
18349
-
18350
- for (var i = 1; i < arguments.length; i++) {
18351
- args[i - 1] = arguments[i];
18352
- }
18353
-
18354
- if (callbacks) {
18355
- callbacks = callbacks.slice(0);
18356
- for (var i = 0, len = callbacks.length; i < len; ++i) {
18357
- callbacks[i].apply(this, args);
18358
- }
18359
- }
18360
-
18361
- return this;
18362
- };
18363
-
18364
- /**
18365
- * Return array of callbacks for `event`.
18366
- *
18367
- * @param {String} event
18368
- * @return {Array}
18369
- * @api public
18370
- */
18371
-
18372
- Emitter.prototype.listeners = function(event){
18373
- this._callbacks = this._callbacks || {};
18374
- return this._callbacks['$' + event] || [];
18375
- };
18376
-
18377
- /**
18378
- * Check if this emitter has `event` handlers.
18379
- *
18380
- * @param {String} event
18381
- * @return {Boolean}
18382
- * @api public
18383
- */
18384
-
18385
- Emitter.prototype.hasListeners = function(event){
18386
- return !! this.listeners(event).length;
18387
- };
18213
+
18214
+ /**
18215
+ * Expose `Emitter`.
18216
+ */
18217
+
18218
+ module.exports = Emitter;
18219
+
18220
+ /**
18221
+ * Initialize a new `Emitter`.
18222
+ *
18223
+ * @api public
18224
+ */
18225
+
18226
+ function Emitter(obj) {
18227
+ if (obj) return mixin(obj);
18228
+ };
18229
+
18230
+ /**
18231
+ * Mixin the emitter properties.
18232
+ *
18233
+ * @param {Object} obj
18234
+ * @return {Object}
18235
+ * @api private
18236
+ */
18237
+
18238
+ function mixin(obj) {
18239
+ for (var key in Emitter.prototype) {
18240
+ obj[key] = Emitter.prototype[key];
18241
+ }
18242
+ return obj;
18243
+ }
18244
+
18245
+ /**
18246
+ * Listen on the given `event` with `fn`.
18247
+ *
18248
+ * @param {String} event
18249
+ * @param {Function} fn
18250
+ * @return {Emitter}
18251
+ * @api public
18252
+ */
18253
+
18254
+ Emitter.prototype.on =
18255
+ Emitter.prototype.addEventListener = function(event, fn){
18256
+ this._callbacks = this._callbacks || {};
18257
+ (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
18258
+ .push(fn);
18259
+ return this;
18260
+ };
18261
+
18262
+ /**
18263
+ * Adds an `event` listener that will be invoked a single
18264
+ * time then automatically removed.
18265
+ *
18266
+ * @param {String} event
18267
+ * @param {Function} fn
18268
+ * @return {Emitter}
18269
+ * @api public
18270
+ */
18271
+
18272
+ Emitter.prototype.once = function(event, fn){
18273
+ function on() {
18274
+ this.off(event, on);
18275
+ fn.apply(this, arguments);
18276
+ }
18277
+
18278
+ on.fn = fn;
18279
+ this.on(event, on);
18280
+ return this;
18281
+ };
18282
+
18283
+ /**
18284
+ * Remove the given callback for `event` or all
18285
+ * registered callbacks.
18286
+ *
18287
+ * @param {String} event
18288
+ * @param {Function} fn
18289
+ * @return {Emitter}
18290
+ * @api public
18291
+ */
18292
+
18293
+ Emitter.prototype.off =
18294
+ Emitter.prototype.removeListener =
18295
+ Emitter.prototype.removeAllListeners =
18296
+ Emitter.prototype.removeEventListener = function(event, fn){
18297
+ this._callbacks = this._callbacks || {};
18298
+
18299
+ // all
18300
+ if (0 == arguments.length) {
18301
+ this._callbacks = {};
18302
+ return this;
18303
+ }
18304
+
18305
+ // specific event
18306
+ var callbacks = this._callbacks['$' + event];
18307
+ if (!callbacks) return this;
18308
+
18309
+ // remove all handlers
18310
+ if (1 == arguments.length) {
18311
+ delete this._callbacks['$' + event];
18312
+ return this;
18313
+ }
18314
+
18315
+ // remove specific handler
18316
+ var cb;
18317
+ for (var i = 0; i < callbacks.length; i++) {
18318
+ cb = callbacks[i];
18319
+ if (cb === fn || cb.fn === fn) {
18320
+ callbacks.splice(i, 1);
18321
+ break;
18322
+ }
18323
+ }
18324
+ return this;
18325
+ };
18326
+
18327
+ /**
18328
+ * Emit `event` with the given args.
18329
+ *
18330
+ * @param {String} event
18331
+ * @param {Mixed} ...
18332
+ * @return {Emitter}
18333
+ */
18334
+
18335
+ Emitter.prototype.emit = function(event){
18336
+ this._callbacks = this._callbacks || {};
18337
+ var args = [].slice.call(arguments, 1)
18338
+ , callbacks = this._callbacks['$' + event];
18339
+
18340
+ if (callbacks) {
18341
+ callbacks = callbacks.slice(0);
18342
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
18343
+ callbacks[i].apply(this, args);
18344
+ }
18345
+ }
18346
+
18347
+ return this;
18348
+ };
18349
+
18350
+ /**
18351
+ * Return array of callbacks for `event`.
18352
+ *
18353
+ * @param {String} event
18354
+ * @return {Array}
18355
+ * @api public
18356
+ */
18357
+
18358
+ Emitter.prototype.listeners = function(event){
18359
+ this._callbacks = this._callbacks || {};
18360
+ return this._callbacks['$' + event] || [];
18361
+ };
18362
+
18363
+ /**
18364
+ * Check if this emitter has `event` handlers.
18365
+ *
18366
+ * @param {String} event
18367
+ * @return {Boolean}
18368
+ * @api public
18369
+ */
18370
+
18371
+ Emitter.prototype.hasListeners = function(event){
18372
+ return !! this.listeners(event).length;
18373
+ };
18388
18374
 
18389
18375
  },{}],41:[function(require,module,exports){
18390
18376
  // Copyright Joyent, Inc. and other Node contributors.
@@ -18690,8 +18676,6 @@ function isUndefined(arg) {
18690
18676
  }
18691
18677
 
18692
18678
  },{}],42:[function(require,module,exports){
18693
- 'use strict';
18694
-
18695
18679
  var hasOwn = Object.prototype.hasOwnProperty;
18696
18680
  var toStr = Object.prototype.toString;
18697
18681
  var defineProperty = Object.defineProperty;
@@ -18706,6 +18690,8 @@ var isArray = function isArray(arr) {
18706
18690
  };
18707
18691
 
18708
18692
  var isPlainObject = function isPlainObject(obj) {
18693
+ 'use strict';
18694
+
18709
18695
  if (!obj || toStr.call(obj) !== '[object Object]') {
18710
18696
  return false;
18711
18697
  }
@@ -18755,6 +18741,8 @@ var getProperty = function getProperty(obj, name) {
18755
18741
  };
18756
18742
 
18757
18743
  module.exports = function extend() {
18744
+ 'use strict';
18745
+
18758
18746
  var options, name, src, copy, copyIsArray, clone;
18759
18747
  var target = arguments[0];
18760
18748
  var i = 1;
@@ -21224,8 +21212,6 @@ function template(string) {
21224
21212
 
21225
21213
  var Emitter = require('emitter');
21226
21214
  var reduce = require('reduce');
21227
- var requestBase = require('./request-base');
21228
- var isObject = require('./is-object');
21229
21215
 
21230
21216
  /**
21231
21217
  * Root reference for iframes.
@@ -21247,10 +21233,28 @@ if (typeof window !== 'undefined') { // Browser window
21247
21233
  function noop(){};
21248
21234
 
21249
21235
  /**
21250
- * Expose `request`.
21236
+ * Check if `obj` is a host object,
21237
+ * we don't want to serialize these :)
21238
+ *
21239
+ * TODO: future proof, move to compoent land
21240
+ *
21241
+ * @param {Object} obj
21242
+ * @return {Boolean}
21243
+ * @api private
21251
21244
  */
21252
21245
 
21253
- var request = module.exports = require('./request').bind(null, Request);
21246
+ function isHost(obj) {
21247
+ var str = {}.toString.call(obj);
21248
+
21249
+ switch (str) {
21250
+ case '[object File]':
21251
+ case '[object Blob]':
21252
+ case '[object FormData]':
21253
+ return true;
21254
+ default:
21255
+ return false;
21256
+ }
21257
+ }
21254
21258
 
21255
21259
  /**
21256
21260
  * Determine XHR.
@@ -21282,6 +21286,18 @@ var trim = ''.trim
21282
21286
  ? function(s) { return s.trim(); }
21283
21287
  : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
21284
21288
 
21289
+ /**
21290
+ * Check if `obj` is an object.
21291
+ *
21292
+ * @param {Object} obj
21293
+ * @return {Boolean}
21294
+ * @api private
21295
+ */
21296
+
21297
+ function isObject(obj) {
21298
+ return obj === Object(obj);
21299
+ }
21300
+
21285
21301
  /**
21286
21302
  * Serialize the given `obj`.
21287
21303
  *
@@ -21296,8 +21312,8 @@ function serialize(obj) {
21296
21312
  for (var key in obj) {
21297
21313
  if (null != obj[key]) {
21298
21314
  pushEncodedKeyValuePair(pairs, key, obj[key]);
21299
- }
21300
- }
21315
+ }
21316
+ }
21301
21317
  return pairs.join('&');
21302
21318
  }
21303
21319
 
@@ -21315,11 +21331,6 @@ function pushEncodedKeyValuePair(pairs, key, val) {
21315
21331
  return val.forEach(function(v) {
21316
21332
  pushEncodedKeyValuePair(pairs, key, v);
21317
21333
  });
21318
- } else if (isObject(val)) {
21319
- for(var subkey in val) {
21320
- pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]);
21321
- }
21322
- return;
21323
21334
  }
21324
21335
  pairs.push(encodeURIComponent(key)
21325
21336
  + '=' + encodeURIComponent(val));
@@ -21342,18 +21353,13 @@ function pushEncodedKeyValuePair(pairs, key, val) {
21342
21353
  function parseString(str) {
21343
21354
  var obj = {};
21344
21355
  var pairs = str.split('&');
21356
+ var parts;
21345
21357
  var pair;
21346
- var pos;
21347
21358
 
21348
21359
  for (var i = 0, len = pairs.length; i < len; ++i) {
21349
21360
  pair = pairs[i];
21350
- pos = pair.indexOf('=');
21351
- if (pos == -1) {
21352
- obj[decodeURIComponent(pair)] = '';
21353
- } else {
21354
- obj[decodeURIComponent(pair.slice(0, pos))] =
21355
- decodeURIComponent(pair.slice(pos + 1));
21356
- }
21361
+ parts = pair.split('=');
21362
+ obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
21357
21363
  }
21358
21364
 
21359
21365
  return obj;
@@ -21537,15 +21543,15 @@ function Response(req, options) {
21537
21543
  ? this.xhr.responseText
21538
21544
  : null;
21539
21545
  this.statusText = this.req.xhr.statusText;
21540
- this._setStatusProperties(this.xhr.status);
21546
+ this.setStatusProperties(this.xhr.status);
21541
21547
  this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());
21542
21548
  // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
21543
21549
  // getResponseHeader still works. so we get content-type even if getting
21544
21550
  // other headers fails.
21545
21551
  this.header['content-type'] = this.xhr.getResponseHeader('content-type');
21546
- this._setHeaderProperties(this.header);
21552
+ this.setHeaderProperties(this.header);
21547
21553
  this.body = this.req.method != 'HEAD'
21548
- ? this._parseBody(this.text ? this.text : this.xhr.response)
21554
+ ? this.parseBody(this.text ? this.text : this.xhr.response)
21549
21555
  : null;
21550
21556
  }
21551
21557
 
@@ -21573,7 +21579,7 @@ Response.prototype.get = function(field){
21573
21579
  * @api private
21574
21580
  */
21575
21581
 
21576
- Response.prototype._setHeaderProperties = function(header){
21582
+ Response.prototype.setHeaderProperties = function(header){
21577
21583
  // content-type
21578
21584
  var ct = this.header['content-type'] || '';
21579
21585
  this.type = type(ct);
@@ -21594,11 +21600,8 @@ Response.prototype._setHeaderProperties = function(header){
21594
21600
  * @api private
21595
21601
  */
21596
21602
 
21597
- Response.prototype._parseBody = function(str){
21603
+ Response.prototype.parseBody = function(str){
21598
21604
  var parse = request.parse[this.type];
21599
- if (!parse && isJSON(this.type)) {
21600
- parse = request.parse['application/json'];
21601
- }
21602
21605
  return parse && str && (str.length || str instanceof Object)
21603
21606
  ? parse(str)
21604
21607
  : null;
@@ -21625,7 +21628,7 @@ Response.prototype._parseBody = function(str){
21625
21628
  * @api private
21626
21629
  */
21627
21630
 
21628
- Response.prototype._setStatusProperties = function(status){
21631
+ Response.prototype.setStatusProperties = function(status){
21629
21632
  // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
21630
21633
  if (status === 1223) {
21631
21634
  status = 204;
@@ -21693,11 +21696,12 @@ request.Response = Response;
21693
21696
 
21694
21697
  function Request(method, url) {
21695
21698
  var self = this;
21699
+ Emitter.call(this);
21696
21700
  this._query = this._query || [];
21697
21701
  this.method = method;
21698
21702
  this.url = url;
21699
- this.header = {}; // preserves header name case
21700
- this._header = {}; // coerces header names to lowercase
21703
+ this.header = {};
21704
+ this._header = {};
21701
21705
  this.on('end', function(){
21702
21706
  var err = null;
21703
21707
  var res = null;
@@ -21710,8 +21714,6 @@ function Request(method, url) {
21710
21714
  err.original = e;
21711
21715
  // issue #675: return the raw response if the response parsing fails
21712
21716
  err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;
21713
- // issue #876: return the http status code if the response parsing fails
21714
- err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;
21715
21717
  return self.callback(err);
21716
21718
  }
21717
21719
 
@@ -21721,88 +21723,190 @@ function Request(method, url) {
21721
21723
  return self.callback(err, res);
21722
21724
  }
21723
21725
 
21724
- try {
21725
- if (res.status >= 200 && res.status < 300) {
21726
- return self.callback(err, res);
21727
- }
21726
+ if (res.status >= 200 && res.status < 300) {
21727
+ return self.callback(err, res);
21728
+ }
21728
21729
 
21729
- var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21730
- new_err.original = err;
21731
- new_err.response = res;
21732
- new_err.status = res.status;
21730
+ var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21731
+ new_err.original = err;
21732
+ new_err.response = res;
21733
+ new_err.status = res.status;
21733
21734
 
21734
- self.callback(new_err, res);
21735
- } catch(e) {
21736
- self.callback(e); // #985 touching res may cause INVALID_STATE_ERR on old Android
21737
- }
21735
+ self.callback(new_err, res);
21738
21736
  });
21739
21737
  }
21740
21738
 
21741
21739
  /**
21742
- * Mixin `Emitter` and `requestBase`.
21740
+ * Mixin `Emitter`.
21743
21741
  */
21744
21742
 
21745
21743
  Emitter(Request.prototype);
21746
- for (var key in requestBase) {
21747
- Request.prototype[key] = requestBase[key];
21744
+
21745
+ /**
21746
+ * Allow for extension
21747
+ */
21748
+
21749
+ Request.prototype.use = function(fn) {
21750
+ fn(this);
21751
+ return this;
21748
21752
  }
21749
21753
 
21750
21754
  /**
21751
- * Set Content-Type to `type`, mapping values from `request.types`.
21752
- *
21753
- * Examples:
21754
- *
21755
- * superagent.types.xml = 'application/xml';
21756
- *
21757
- * request.post('/')
21758
- * .type('xml')
21759
- * .send(xmlstring)
21760
- * .end(callback);
21761
- *
21762
- * request.post('/')
21763
- * .type('application/xml')
21764
- * .send(xmlstring)
21765
- * .end(callback);
21755
+ * Set timeout to `ms`.
21766
21756
  *
21767
- * @param {String} type
21757
+ * @param {Number} ms
21768
21758
  * @return {Request} for chaining
21769
21759
  * @api public
21770
21760
  */
21771
21761
 
21772
- Request.prototype.type = function(type){
21773
- this.set('Content-Type', request.types[type] || type);
21762
+ Request.prototype.timeout = function(ms){
21763
+ this._timeout = ms;
21774
21764
  return this;
21775
21765
  };
21776
21766
 
21777
21767
  /**
21778
- * Set responseType to `val`. Presently valid responseTypes are 'blob' and
21779
- * 'arraybuffer'.
21780
- *
21781
- * Examples:
21782
- *
21783
- * req.get('/')
21784
- * .responseType('blob')
21785
- * .end(callback);
21768
+ * Clear previous timeout.
21786
21769
  *
21787
- * @param {String} val
21788
21770
  * @return {Request} for chaining
21789
21771
  * @api public
21790
21772
  */
21791
21773
 
21792
- Request.prototype.responseType = function(val){
21793
- this._responseType = val;
21774
+ Request.prototype.clearTimeout = function(){
21775
+ this._timeout = 0;
21776
+ clearTimeout(this._timer);
21794
21777
  return this;
21795
21778
  };
21796
21779
 
21797
21780
  /**
21798
- * Set Accept to `type`, mapping values from `request.types`.
21799
- *
21800
- * Examples:
21801
- *
21802
- * superagent.types.json = 'application/json';
21781
+ * Abort the request, and clear potential timeout.
21803
21782
  *
21804
- * request.get('/agent')
21805
- * .accept('json')
21783
+ * @return {Request}
21784
+ * @api public
21785
+ */
21786
+
21787
+ Request.prototype.abort = function(){
21788
+ if (this.aborted) return;
21789
+ this.aborted = true;
21790
+ this.xhr.abort();
21791
+ this.clearTimeout();
21792
+ this.emit('abort');
21793
+ return this;
21794
+ };
21795
+
21796
+ /**
21797
+ * Set header `field` to `val`, or multiple fields with one object.
21798
+ *
21799
+ * Examples:
21800
+ *
21801
+ * req.get('/')
21802
+ * .set('Accept', 'application/json')
21803
+ * .set('X-API-Key', 'foobar')
21804
+ * .end(callback);
21805
+ *
21806
+ * req.get('/')
21807
+ * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
21808
+ * .end(callback);
21809
+ *
21810
+ * @param {String|Object} field
21811
+ * @param {String} val
21812
+ * @return {Request} for chaining
21813
+ * @api public
21814
+ */
21815
+
21816
+ Request.prototype.set = function(field, val){
21817
+ if (isObject(field)) {
21818
+ for (var key in field) {
21819
+ this.set(key, field[key]);
21820
+ }
21821
+ return this;
21822
+ }
21823
+ this._header[field.toLowerCase()] = val;
21824
+ this.header[field] = val;
21825
+ return this;
21826
+ };
21827
+
21828
+ /**
21829
+ * Remove header `field`.
21830
+ *
21831
+ * Example:
21832
+ *
21833
+ * req.get('/')
21834
+ * .unset('User-Agent')
21835
+ * .end(callback);
21836
+ *
21837
+ * @param {String} field
21838
+ * @return {Request} for chaining
21839
+ * @api public
21840
+ */
21841
+
21842
+ Request.prototype.unset = function(field){
21843
+ delete this._header[field.toLowerCase()];
21844
+ delete this.header[field];
21845
+ return this;
21846
+ };
21847
+
21848
+ /**
21849
+ * Get case-insensitive header `field` value.
21850
+ *
21851
+ * @param {String} field
21852
+ * @return {String}
21853
+ * @api private
21854
+ */
21855
+
21856
+ Request.prototype.getHeader = function(field){
21857
+ return this._header[field.toLowerCase()];
21858
+ };
21859
+
21860
+ /**
21861
+ * Set Content-Type to `type`, mapping values from `request.types`.
21862
+ *
21863
+ * Examples:
21864
+ *
21865
+ * superagent.types.xml = 'application/xml';
21866
+ *
21867
+ * request.post('/')
21868
+ * .type('xml')
21869
+ * .send(xmlstring)
21870
+ * .end(callback);
21871
+ *
21872
+ * request.post('/')
21873
+ * .type('application/xml')
21874
+ * .send(xmlstring)
21875
+ * .end(callback);
21876
+ *
21877
+ * @param {String} type
21878
+ * @return {Request} for chaining
21879
+ * @api public
21880
+ */
21881
+
21882
+ Request.prototype.type = function(type){
21883
+ this.set('Content-Type', request.types[type] || type);
21884
+ return this;
21885
+ };
21886
+
21887
+ /**
21888
+ * Force given parser
21889
+ *
21890
+ * Sets the body parser no matter type.
21891
+ *
21892
+ * @param {Function}
21893
+ * @api public
21894
+ */
21895
+
21896
+ Request.prototype.parse = function(fn){
21897
+ this._parser = fn;
21898
+ return this;
21899
+ };
21900
+
21901
+ /**
21902
+ * Set Accept to `type`, mapping values from `request.types`.
21903
+ *
21904
+ * Examples:
21905
+ *
21906
+ * superagent.types.json = 'application/json';
21907
+ *
21908
+ * request.get('/agent')
21909
+ * .accept('json')
21806
21910
  * .end(callback);
21807
21911
  *
21808
21912
  * request.get('/agent')
@@ -21824,29 +21928,13 @@ Request.prototype.accept = function(type){
21824
21928
  *
21825
21929
  * @param {String} user
21826
21930
  * @param {String} pass
21827
- * @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic')
21828
21931
  * @return {Request} for chaining
21829
21932
  * @api public
21830
21933
  */
21831
21934
 
21832
- Request.prototype.auth = function(user, pass, options){
21833
- if (!options) {
21834
- options = {
21835
- type: 'basic'
21836
- }
21837
- }
21838
-
21839
- switch (options.type) {
21840
- case 'basic':
21841
- var str = btoa(user + ':' + pass);
21842
- this.set('Authorization', 'Basic ' + str);
21843
- break;
21844
-
21845
- case 'auto':
21846
- this.username = user;
21847
- this.password = pass;
21848
- break;
21849
- }
21935
+ Request.prototype.auth = function(user, pass){
21936
+ var str = btoa(user + ':' + pass);
21937
+ this.set('Authorization', 'Basic ' + str);
21850
21938
  return this;
21851
21939
  };
21852
21940
 
@@ -21870,13 +21958,35 @@ Request.prototype.query = function(val){
21870
21958
  return this;
21871
21959
  };
21872
21960
 
21961
+ /**
21962
+ * Write the field `name` and `val` for "multipart/form-data"
21963
+ * request bodies.
21964
+ *
21965
+ * ``` js
21966
+ * request.post('/upload')
21967
+ * .field('foo', 'bar')
21968
+ * .end(callback);
21969
+ * ```
21970
+ *
21971
+ * @param {String} name
21972
+ * @param {String|Blob|File} val
21973
+ * @return {Request} for chaining
21974
+ * @api public
21975
+ */
21976
+
21977
+ Request.prototype.field = function(name, val){
21978
+ if (!this._formData) this._formData = new root.FormData();
21979
+ this._formData.append(name, val);
21980
+ return this;
21981
+ };
21982
+
21873
21983
  /**
21874
21984
  * Queue the given `file` as an attachment to the specified `field`,
21875
21985
  * with optional `filename`.
21876
21986
  *
21877
21987
  * ``` js
21878
21988
  * request.post('/upload')
21879
- * .attach('content', new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
21989
+ * .attach(new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
21880
21990
  * .end(callback);
21881
21991
  * ```
21882
21992
  *
@@ -21888,15 +21998,77 @@ Request.prototype.query = function(val){
21888
21998
  */
21889
21999
 
21890
22000
  Request.prototype.attach = function(field, file, filename){
21891
- this._getFormData().append(field, file, filename || file.name);
22001
+ if (!this._formData) this._formData = new root.FormData();
22002
+ this._formData.append(field, file, filename || file.name);
21892
22003
  return this;
21893
22004
  };
21894
22005
 
21895
- Request.prototype._getFormData = function(){
21896
- if (!this._formData) {
21897
- this._formData = new root.FormData();
22006
+ /**
22007
+ * Send `data` as the request body, defaulting the `.type()` to "json" when
22008
+ * an object is given.
22009
+ *
22010
+ * Examples:
22011
+ *
22012
+ * // manual json
22013
+ * request.post('/user')
22014
+ * .type('json')
22015
+ * .send('{"name":"tj"}')
22016
+ * .end(callback)
22017
+ *
22018
+ * // auto json
22019
+ * request.post('/user')
22020
+ * .send({ name: 'tj' })
22021
+ * .end(callback)
22022
+ *
22023
+ * // manual x-www-form-urlencoded
22024
+ * request.post('/user')
22025
+ * .type('form')
22026
+ * .send('name=tj')
22027
+ * .end(callback)
22028
+ *
22029
+ * // auto x-www-form-urlencoded
22030
+ * request.post('/user')
22031
+ * .type('form')
22032
+ * .send({ name: 'tj' })
22033
+ * .end(callback)
22034
+ *
22035
+ * // defaults to x-www-form-urlencoded
22036
+ * request.post('/user')
22037
+ * .send('name=tobi')
22038
+ * .send('species=ferret')
22039
+ * .end(callback)
22040
+ *
22041
+ * @param {String|Object} data
22042
+ * @return {Request} for chaining
22043
+ * @api public
22044
+ */
22045
+
22046
+ Request.prototype.send = function(data){
22047
+ var obj = isObject(data);
22048
+ var type = this.getHeader('Content-Type');
22049
+
22050
+ // merge
22051
+ if (obj && isObject(this._data)) {
22052
+ for (var key in data) {
22053
+ this._data[key] = data[key];
22054
+ }
22055
+ } else if ('string' == typeof data) {
22056
+ if (!type) this.type('form');
22057
+ type = this.getHeader('Content-Type');
22058
+ if ('application/x-www-form-urlencoded' == type) {
22059
+ this._data = this._data
22060
+ ? this._data + '&' + data
22061
+ : data;
22062
+ } else {
22063
+ this._data = (this._data || '') + data;
22064
+ }
22065
+ } else {
22066
+ this._data = data;
21898
22067
  }
21899
- return this._formData;
22068
+
22069
+ if (!obj || isHost(data)) return this;
22070
+ if (!type) this.type('json');
22071
+ return this;
21900
22072
  };
21901
22073
 
21902
22074
  /**
@@ -21937,7 +22109,7 @@ Request.prototype.crossDomainError = function(){
21937
22109
  * @api private
21938
22110
  */
21939
22111
 
21940
- Request.prototype._timeoutError = function(){
22112
+ Request.prototype.timeoutError = function(){
21941
22113
  var timeout = this._timeout;
21942
22114
  var err = new Error('timeout of ' + timeout + 'ms exceeded');
21943
22115
  err.timeout = timeout;
@@ -21945,18 +22117,19 @@ Request.prototype._timeoutError = function(){
21945
22117
  };
21946
22118
 
21947
22119
  /**
21948
- * Compose querystring to append to req.url
22120
+ * Enable transmission of cookies with x-domain requests.
21949
22121
  *
21950
- * @api private
22122
+ * Note that for this to work the origin must not be
22123
+ * using "Access-Control-Allow-Origin" with a wildcard,
22124
+ * and also must set "Access-Control-Allow-Credentials"
22125
+ * to "true".
22126
+ *
22127
+ * @api public
21951
22128
  */
21952
22129
 
21953
- Request.prototype._appendQueryString = function(){
21954
- var query = this._query.join('&');
21955
- if (query) {
21956
- this.url += ~this.url.indexOf('?')
21957
- ? '&' + query
21958
- : '?' + query;
21959
- }
22130
+ Request.prototype.withCredentials = function(){
22131
+ this._withCredentials = true;
22132
+ return this;
21960
22133
  };
21961
22134
 
21962
22135
  /**
@@ -21971,6 +22144,7 @@ Request.prototype._appendQueryString = function(){
21971
22144
  Request.prototype.end = function(fn){
21972
22145
  var self = this;
21973
22146
  var xhr = this.xhr = request.getXHR();
22147
+ var query = this._query.join('&');
21974
22148
  var timeout = this._timeout;
21975
22149
  var data = this._formData || this._data;
21976
22150
 
@@ -21987,8 +22161,8 @@ Request.prototype.end = function(fn){
21987
22161
  try { status = xhr.status } catch(e) { status = 0; }
21988
22162
 
21989
22163
  if (0 == status) {
21990
- if (self.timedout) return self._timeoutError();
21991
- if (self._aborted) return;
22164
+ if (self.timedout) return self.timeoutError();
22165
+ if (self.aborted) return;
21992
22166
  return self.crossDomainError();
21993
22167
  }
21994
22168
  self.emit('end');
@@ -22024,23 +22198,24 @@ Request.prototype.end = function(fn){
22024
22198
  }
22025
22199
 
22026
22200
  // querystring
22027
- this._appendQueryString();
22201
+ if (query) {
22202
+ query = request.serializeObject(query);
22203
+ this.url += ~this.url.indexOf('?')
22204
+ ? '&' + query
22205
+ : '?' + query;
22206
+ }
22028
22207
 
22029
22208
  // initiate request
22030
- if (this.username && this.password) {
22031
- xhr.open(this.method, this.url, true, this.username, this.password);
22032
- } else {
22033
- xhr.open(this.method, this.url, true);
22034
- }
22209
+ xhr.open(this.method, this.url, true);
22035
22210
 
22036
22211
  // CORS
22037
22212
  if (this._withCredentials) xhr.withCredentials = true;
22038
22213
 
22039
22214
  // body
22040
- if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) {
22215
+ if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
22041
22216
  // serialize stuff
22042
- var contentType = this._header['content-type'];
22043
- var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
22217
+ var contentType = this.getHeader('Content-Type');
22218
+ var serialize = this._parser || request.serialize[contentType ? contentType.split(';')[0] : ''];
22044
22219
  if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json'];
22045
22220
  if (serialize) data = serialize(data);
22046
22221
  }
@@ -22051,10 +22226,6 @@ Request.prototype.end = function(fn){
22051
22226
  xhr.setRequestHeader(field, this.header[field]);
22052
22227
  }
22053
22228
 
22054
- if (this._responseType) {
22055
- xhr.responseType = this._responseType;
22056
- }
22057
-
22058
22229
  // send stuff
22059
22230
  this.emit('request', this);
22060
22231
 
@@ -22064,6 +22235,19 @@ Request.prototype.end = function(fn){
22064
22235
  return this;
22065
22236
  };
22066
22237
 
22238
+ /**
22239
+ * Faux promise support
22240
+ *
22241
+ * @param {Function} fulfill
22242
+ * @param {Function} reject
22243
+ * @return {Request}
22244
+ */
22245
+
22246
+ Request.prototype.then = function (fulfill, reject) {
22247
+ return this.end(function(err, res) {
22248
+ err ? reject(err) : fulfill(res);
22249
+ });
22250
+ }
22067
22251
 
22068
22252
  /**
22069
22253
  * Expose `Request`.
@@ -22071,6 +22255,35 @@ Request.prototype.end = function(fn){
22071
22255
 
22072
22256
  request.Request = Request;
22073
22257
 
22258
+ /**
22259
+ * Issue a request:
22260
+ *
22261
+ * Examples:
22262
+ *
22263
+ * request('GET', '/users').end(callback)
22264
+ * request('/users').end(callback)
22265
+ * request('/users', callback)
22266
+ *
22267
+ * @param {String} method
22268
+ * @param {String|Function} url or callback
22269
+ * @return {Request}
22270
+ * @api public
22271
+ */
22272
+
22273
+ function request(method, url) {
22274
+ // callback
22275
+ if ('function' == typeof url) {
22276
+ return new Request('GET', method).end(url);
22277
+ }
22278
+
22279
+ // url first
22280
+ if (1 == arguments.length) {
22281
+ return new Request('GET', method);
22282
+ }
22283
+
22284
+ return new Request(method, url);
22285
+ }
22286
+
22074
22287
  /**
22075
22288
  * GET `url` with optional callback `fn(res)`.
22076
22289
  *
@@ -22108,25 +22321,7 @@ request.head = function(url, data, fn){
22108
22321
  };
22109
22322
 
22110
22323
  /**
22111
- * OPTIONS query to `url` with optional callback `fn(res)`.
22112
- *
22113
- * @param {String} url
22114
- * @param {Mixed|Function} data or fn
22115
- * @param {Function} fn
22116
- * @return {Request}
22117
- * @api public
22118
- */
22119
-
22120
- request.options = function(url, data, fn){
22121
- var req = request('OPTIONS', url);
22122
- if ('function' == typeof data) fn = data, data = null;
22123
- if (data) req.send(data);
22124
- if (fn) req.end(fn);
22125
- return req;
22126
- };
22127
-
22128
- /**
22129
- * DELETE `url` with optional callback `fn(res)`.
22324
+ * DELETE `url` with optional callback `fn(res)`.
22130
22325
  *
22131
22326
  * @param {String} url
22132
22327
  * @param {Function} fn
@@ -22197,404 +22392,13 @@ request.put = function(url, data, fn){
22197
22392
  return req;
22198
22393
  };
22199
22394
 
22200
- },{"./is-object":50,"./request":52,"./request-base":51,"emitter":40,"reduce":47}],50:[function(require,module,exports){
22201
- /**
22202
- * Check if `obj` is an object.
22203
- *
22204
- * @param {Object} obj
22205
- * @return {Boolean}
22206
- * @api private
22207
- */
22208
-
22209
- function isObject(obj) {
22210
- return null !== obj && 'object' === typeof obj;
22211
- }
22212
-
22213
- module.exports = isObject;
22214
-
22215
- },{}],51:[function(require,module,exports){
22216
- /**
22217
- * Module of mixed-in functions shared between node and client code
22218
- */
22219
- var isObject = require('./is-object');
22220
-
22221
- /**
22222
- * Clear previous timeout.
22223
- *
22224
- * @return {Request} for chaining
22225
- * @api public
22226
- */
22227
-
22228
- exports.clearTimeout = function _clearTimeout(){
22229
- this._timeout = 0;
22230
- clearTimeout(this._timer);
22231
- return this;
22232
- };
22233
-
22234
- /**
22235
- * Override default response body parser
22236
- *
22237
- * This function will be called to convert incoming data into request.body
22238
- *
22239
- * @param {Function}
22240
- * @api public
22241
- */
22242
-
22243
- exports.parse = function parse(fn){
22244
- this._parser = fn;
22245
- return this;
22246
- };
22247
-
22248
- /**
22249
- * Override default request body serializer
22250
- *
22251
- * This function will be called to convert data set via .send or .attach into payload to send
22252
- *
22253
- * @param {Function}
22254
- * @api public
22255
- */
22256
-
22257
- exports.serialize = function serialize(fn){
22258
- this._serializer = fn;
22259
- return this;
22260
- };
22261
-
22262
22395
  /**
22263
- * Set timeout to `ms`.
22264
- *
22265
- * @param {Number} ms
22266
- * @return {Request} for chaining
22267
- * @api public
22268
- */
22269
-
22270
- exports.timeout = function timeout(ms){
22271
- this._timeout = ms;
22272
- return this;
22273
- };
22274
-
22275
- /**
22276
- * Promise support
22277
- *
22278
- * @param {Function} resolve
22279
- * @param {Function} reject
22280
- * @return {Request}
22281
- */
22282
-
22283
- exports.then = function then(resolve, reject) {
22284
- if (!this._fullfilledPromise) {
22285
- var self = this;
22286
- this._fullfilledPromise = new Promise(function(innerResolve, innerReject){
22287
- self.end(function(err, res){
22288
- if (err) innerReject(err); else innerResolve(res);
22289
- });
22290
- });
22291
- }
22292
- return this._fullfilledPromise.then(resolve, reject);
22293
- }
22294
-
22295
- /**
22296
- * Allow for extension
22297
- */
22298
-
22299
- exports.use = function use(fn) {
22300
- fn(this);
22301
- return this;
22302
- }
22303
-
22304
-
22305
- /**
22306
- * Get request header `field`.
22307
- * Case-insensitive.
22308
- *
22309
- * @param {String} field
22310
- * @return {String}
22311
- * @api public
22312
- */
22313
-
22314
- exports.get = function(field){
22315
- return this._header[field.toLowerCase()];
22316
- };
22317
-
22318
- /**
22319
- * Get case-insensitive header `field` value.
22320
- * This is a deprecated internal API. Use `.get(field)` instead.
22321
- *
22322
- * (getHeader is no longer used internally by the superagent code base)
22323
- *
22324
- * @param {String} field
22325
- * @return {String}
22326
- * @api private
22327
- * @deprecated
22328
- */
22329
-
22330
- exports.getHeader = exports.get;
22331
-
22332
- /**
22333
- * Set header `field` to `val`, or multiple fields with one object.
22334
- * Case-insensitive.
22335
- *
22336
- * Examples:
22337
- *
22338
- * req.get('/')
22339
- * .set('Accept', 'application/json')
22340
- * .set('X-API-Key', 'foobar')
22341
- * .end(callback);
22342
- *
22343
- * req.get('/')
22344
- * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
22345
- * .end(callback);
22346
- *
22347
- * @param {String|Object} field
22348
- * @param {String} val
22349
- * @return {Request} for chaining
22350
- * @api public
22351
- */
22352
-
22353
- exports.set = function(field, val){
22354
- if (isObject(field)) {
22355
- for (var key in field) {
22356
- this.set(key, field[key]);
22357
- }
22358
- return this;
22359
- }
22360
- this._header[field.toLowerCase()] = val;
22361
- this.header[field] = val;
22362
- return this;
22363
- };
22364
-
22365
- /**
22366
- * Remove header `field`.
22367
- * Case-insensitive.
22368
- *
22369
- * Example:
22370
- *
22371
- * req.get('/')
22372
- * .unset('User-Agent')
22373
- * .end(callback);
22374
- *
22375
- * @param {String} field
22376
- */
22377
- exports.unset = function(field){
22378
- delete this._header[field.toLowerCase()];
22379
- delete this.header[field];
22380
- return this;
22381
- };
22382
-
22383
- /**
22384
- * Write the field `name` and `val` for "multipart/form-data"
22385
- * request bodies.
22386
- *
22387
- * ``` js
22388
- * request.post('/upload')
22389
- * .field('foo', 'bar')
22390
- * .end(callback);
22391
- * ```
22392
- *
22393
- * @param {String} name
22394
- * @param {String|Blob|File|Buffer|fs.ReadStream} val
22395
- * @return {Request} for chaining
22396
- * @api public
22397
- */
22398
- exports.field = function(name, val) {
22399
- this._getFormData().append(name, val);
22400
- return this;
22401
- };
22402
-
22403
- /**
22404
- * Abort the request, and clear potential timeout.
22405
- *
22406
- * @return {Request}
22407
- * @api public
22408
- */
22409
- exports.abort = function(){
22410
- if (this._aborted) {
22411
- return this;
22412
- }
22413
- this._aborted = true;
22414
- this.xhr && this.xhr.abort(); // browser
22415
- this.req && this.req.abort(); // node
22416
- this.clearTimeout();
22417
- this.emit('abort');
22418
- return this;
22419
- };
22420
-
22421
- /**
22422
- * Enable transmission of cookies with x-domain requests.
22423
- *
22424
- * Note that for this to work the origin must not be
22425
- * using "Access-Control-Allow-Origin" with a wildcard,
22426
- * and also must set "Access-Control-Allow-Credentials"
22427
- * to "true".
22428
- *
22429
- * @api public
22430
- */
22431
-
22432
- exports.withCredentials = function(){
22433
- // This is browser-only functionality. Node side is no-op.
22434
- this._withCredentials = true;
22435
- return this;
22436
- };
22437
-
22438
- /**
22439
- * Set the max redirects to `n`. Does noting in browser XHR implementation.
22440
- *
22441
- * @param {Number} n
22442
- * @return {Request} for chaining
22443
- * @api public
22444
- */
22445
-
22446
- exports.redirects = function(n){
22447
- this._maxRedirects = n;
22448
- return this;
22449
- };
22450
-
22451
- /**
22452
- * Convert to a plain javascript object (not JSON string) of scalar properties.
22453
- * Note as this method is designed to return a useful non-this value,
22454
- * it cannot be chained.
22455
- *
22456
- * @return {Object} describing method, url, and data of this request
22457
- * @api public
22458
- */
22459
-
22460
- exports.toJSON = function(){
22461
- return {
22462
- method: this.method,
22463
- url: this.url,
22464
- data: this._data
22465
- };
22466
- };
22467
-
22468
- /**
22469
- * Check if `obj` is a host object,
22470
- * we don't want to serialize these :)
22471
- *
22472
- * TODO: future proof, move to compoent land
22473
- *
22474
- * @param {Object} obj
22475
- * @return {Boolean}
22476
- * @api private
22477
- */
22478
-
22479
- exports._isHost = function _isHost(obj) {
22480
- var str = {}.toString.call(obj);
22481
-
22482
- switch (str) {
22483
- case '[object File]':
22484
- case '[object Blob]':
22485
- case '[object FormData]':
22486
- return true;
22487
- default:
22488
- return false;
22489
- }
22490
- }
22491
-
22492
- /**
22493
- * Send `data` as the request body, defaulting the `.type()` to "json" when
22494
- * an object is given.
22495
- *
22496
- * Examples:
22497
- *
22498
- * // manual json
22499
- * request.post('/user')
22500
- * .type('json')
22501
- * .send('{"name":"tj"}')
22502
- * .end(callback)
22503
- *
22504
- * // auto json
22505
- * request.post('/user')
22506
- * .send({ name: 'tj' })
22507
- * .end(callback)
22508
- *
22509
- * // manual x-www-form-urlencoded
22510
- * request.post('/user')
22511
- * .type('form')
22512
- * .send('name=tj')
22513
- * .end(callback)
22514
- *
22515
- * // auto x-www-form-urlencoded
22516
- * request.post('/user')
22517
- * .type('form')
22518
- * .send({ name: 'tj' })
22519
- * .end(callback)
22520
- *
22521
- * // defaults to x-www-form-urlencoded
22522
- * request.post('/user')
22523
- * .send('name=tobi')
22524
- * .send('species=ferret')
22525
- * .end(callback)
22526
- *
22527
- * @param {String|Object} data
22528
- * @return {Request} for chaining
22529
- * @api public
22530
- */
22531
-
22532
- exports.send = function(data){
22533
- var obj = isObject(data);
22534
- var type = this._header['content-type'];
22535
-
22536
- // merge
22537
- if (obj && isObject(this._data)) {
22538
- for (var key in data) {
22539
- this._data[key] = data[key];
22540
- }
22541
- } else if ('string' == typeof data) {
22542
- // default to x-www-form-urlencoded
22543
- if (!type) this.type('form');
22544
- type = this._header['content-type'];
22545
- if ('application/x-www-form-urlencoded' == type) {
22546
- this._data = this._data
22547
- ? this._data + '&' + data
22548
- : data;
22549
- } else {
22550
- this._data = (this._data || '') + data;
22551
- }
22552
- } else {
22553
- this._data = data;
22554
- }
22555
-
22556
- if (!obj || this._isHost(data)) return this;
22557
-
22558
- // default to json
22559
- if (!type) this.type('json');
22560
- return this;
22561
- };
22562
-
22563
- },{"./is-object":50}],52:[function(require,module,exports){
22564
- // The node and browser modules expose versions of this with the
22565
- // appropriate constructor function bound as first argument
22566
- /**
22567
- * Issue a request:
22568
- *
22569
- * Examples:
22570
- *
22571
- * request('GET', '/users').end(callback)
22572
- * request('/users').end(callback)
22573
- * request('/users', callback)
22574
- *
22575
- * @param {String} method
22576
- * @param {String|Function} url or callback
22577
- * @return {Request}
22578
- * @api public
22396
+ * Expose `request`.
22579
22397
  */
22580
22398
 
22581
- function request(RequestConstructor, method, url) {
22582
- // callback
22583
- if ('function' == typeof url) {
22584
- return new RequestConstructor('GET', method).end(url);
22585
- }
22586
-
22587
- // url first
22588
- if (2 == arguments.length) {
22589
- return new RequestConstructor('GET', method);
22590
- }
22591
-
22592
- return new RequestConstructor(method, url);
22593
- }
22594
-
22595
22399
  module.exports = request;
22596
22400
 
22597
- },{}],53:[function(require,module,exports){
22401
+ },{"emitter":40,"reduce":47}],50:[function(require,module,exports){
22598
22402
  /*!
22599
22403
  * validate.js 0.9.0
22600
22404
  *