superagent-as-promised
Advanced tools
Comparing version 2.0.0 to 3.0.0
SuperAgent as Promised | ||
====================== | ||
Request = require 'superagent' | ||
Promise = require 'bluebird' | ||
@@ -9,23 +8,22 @@ | ||
Request.Request.prototype.endAsync = -> | ||
new Promise (resolve,reject) => | ||
try | ||
@end (error, response) -> | ||
if error | ||
reject error | ||
return | ||
if response.error | ||
reject response.error | ||
return | ||
resolve response | ||
catch error | ||
reject error | ||
module.exports = (Request) -> | ||
Request.Request.prototype.endAsync = -> | ||
new Promise (resolve,reject) => | ||
try | ||
@end (error, response) -> | ||
if error | ||
reject error | ||
return | ||
if response.error | ||
reject response.error | ||
return | ||
resolve response | ||
catch error | ||
reject error | ||
Request.Request.prototype.then = -> | ||
@endAsync() | ||
.then arguments... | ||
Request.Request.prototype.catch = -> | ||
@endAsync() | ||
.catch arguments... | ||
module.exports = Request | ||
Request.Request.prototype.then = -> | ||
@endAsync() | ||
.then arguments... | ||
Request.Request.prototype.catch = -> | ||
@endAsync() | ||
.catch arguments... |
72
index.js
@@ -1,45 +0,41 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var Promise, Request; | ||
var Promise; | ||
Request = require('superagent'); | ||
Promise = require('bluebird'); | ||
Request.Request.prototype.endAsync = function() { | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
var error; | ||
try { | ||
return _this.end(function(error, response) { | ||
if (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (response.error) { | ||
reject(response.error); | ||
return; | ||
} | ||
return resolve(response); | ||
}); | ||
} catch (_error) { | ||
error = _error; | ||
return reject(error); | ||
} | ||
}; | ||
})(this)); | ||
module.exports = function(Request) { | ||
Request.Request.prototype.endAsync = function() { | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
var error; | ||
try { | ||
return _this.end(function(error, response) { | ||
if (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (response.error) { | ||
reject(response.error); | ||
return; | ||
} | ||
return resolve(response); | ||
}); | ||
} catch (_error) { | ||
error = _error; | ||
return reject(error); | ||
} | ||
}; | ||
})(this)); | ||
}; | ||
Request.Request.prototype.then = function() { | ||
var ref; | ||
return (ref = this.endAsync()).then.apply(ref, arguments); | ||
}; | ||
return Request.Request.prototype["catch"] = function() { | ||
var ref; | ||
return (ref = this.endAsync())["catch"].apply(ref, arguments); | ||
}; | ||
}; | ||
Request.Request.prototype.then = function() { | ||
var _ref; | ||
return (_ref = this.endAsync()).then.apply(_ref, arguments); | ||
}; | ||
Request.Request.prototype["catch"] = function() { | ||
var _ref; | ||
return (_ref = this.endAsync())["catch"].apply(_ref, arguments); | ||
}; | ||
module.exports = Request; | ||
}).call(this); |
{ | ||
"name": "superagent-as-promised", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "SuperAgent with a Promise twist", | ||
@@ -17,12 +17,12 @@ "main": "index.js", | ||
"dependencies": { | ||
"bluebird": "^2.3.11", | ||
"superagent": "^0.21.0" | ||
"bluebird": "^2.9.14" | ||
}, | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"chai-as-promised": "^4.1.1", | ||
"coffee-script": "^1.8.0", | ||
"express": "^4.10.4", | ||
"mocha": "^2.0.1" | ||
"superagent": "^1.1.0", | ||
"chai": "^2.1.2", | ||
"chai-as-promised": "^4.3.0", | ||
"coffee-script": "^1.9.1", | ||
"express": "^4.12.3", | ||
"mocha": "^2.2.1" | ||
} | ||
} |
@@ -14,4 +14,7 @@ SuperAgent as Promise(d) | ||
var request = require('superagent-as-promised'); | ||
var request = require('superagent'); | ||
require('superagent-as-promised')(request); | ||
Then | ||
request | ||
@@ -18,0 +21,0 @@ .get('/location') |
@@ -5,3 +5,4 @@ chai = require 'chai' | ||
Request = require '..' | ||
Request = require 'superagent' | ||
(require '..') Request | ||
express = require 'express' | ||
@@ -8,0 +9,0 @@ |
5022
1
41
6
- Removedsuperagent@^0.21.0
- Removedasync@0.9.2(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcomponent-emitter@1.1.2(transitive)
- Removedcookiejar@2.0.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedextend@1.2.1(transitive)
- Removedform-data@0.1.3(transitive)
- Removedformidable@1.0.14(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedmethods@1.0.1(transitive)
- Removedmime@1.2.11(transitive)
- Removedms@2.0.0(transitive)
- Removedqs@1.2.0(transitive)
- Removedreadable-stream@1.0.27-1(transitive)
- Removedreduce-component@1.0.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedsuperagent@0.21.0(transitive)
Updatedbluebird@^2.9.14