superagent 3.8.2 → 3.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/superagent.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
2
  function Agent() {
3
3
  this._defaults = [];
4
4
  }
@@ -284,7 +284,7 @@ RequestBase.prototype.then = function then(resolve, reject) {
284
284
  return this._fullfilledPromise.then(resolve, reject);
285
285
  };
286
286
 
287
- RequestBase.prototype.catch = function(cb) {
287
+ RequestBase.prototype['catch'] = function(cb) {
288
288
  return this.then(undefined, cb);
289
289
  };
290
290
 
@@ -860,6 +860,7 @@ ResponseBase.prototype._setStatusProperties = function(status){
860
860
  : false;
861
861
 
862
862
  // sugar
863
+ this.created = 201 == status;
863
864
  this.accepted = 202 == status;
864
865
  this.noContent = 204 == status;
865
866
  this.badRequest = 400 == status;
@@ -867,6 +868,7 @@ ResponseBase.prototype._setStatusProperties = function(status){
867
868
  this.notAcceptable = 406 == status;
868
869
  this.forbidden = 403 == status;
869
870
  this.notFound = 404 == status;
871
+ this.unprocessableEntity = 422 == status;
870
872
  };
871
873
 
872
874
  },{"./utils":5}],5:[function(require,module,exports){
@@ -1296,7 +1298,7 @@ request.types = {
1296
1298
 
1297
1299
  request.serialize = {
1298
1300
  'application/x-www-form-urlencoded': serialize,
1299
- 'application/json': JSON.stringify,
1301
+ 'application/json': JSON.stringify
1300
1302
  };
1301
1303
 
1302
1304
  /**
@@ -1310,7 +1312,7 @@ request.serialize = {
1310
1312
 
1311
1313
  request.parse = {
1312
1314
  'application/x-www-form-urlencoded': parseString,
1313
- 'application/json': JSON.parse,
1315
+ 'application/json': JSON.parse
1314
1316
  };
1315
1317
 
1316
1318
  /**
@@ -2030,4 +2032,4 @@ request.put = function(url, data, fn) {
2030
2032
  };
2031
2033
 
2032
2034
  },{"./agent-base":1,"./is-object":2,"./request-base":3,"./response-base":4,"component-emitter":6}]},{},[7])(7)
2033
- });
2035
+ });
package/test.js ADDED
@@ -0,0 +1,7 @@
1
+ const request = require('./lib/node');
2
+
3
+ request.post('nevermind')
4
+ .field({a:1,b:2})
5
+ .attach('c', 'does-not-exist.txt')
6
+ .then(() => assert.fail("It should not allow this"))
7
+ .catch(() => true);