superagent-then
Advanced tools
Comparing version 1.1.0 to 1.1.1
12
index.js
@@ -5,7 +5,9 @@ var superagent = require('superagent'); | ||
function plugin(request) { | ||
request.end = function end() { | ||
return when.promise(function (resolve, reject) { | ||
request.on('error', reject); | ||
superagent.Request.prototype.end.call(request, resolve); | ||
}); | ||
var promise = when.promise(function (resolve, reject) { | ||
request.on('response', resolve); | ||
request.on('error', reject); | ||
}); | ||
request.then = function then(onFulfilled, onRejected) { | ||
return promise.then(onFulfilled, onRejected); | ||
}; | ||
@@ -12,0 +14,0 @@ } |
{ | ||
"name": "superagent-then", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A trivial plugin for Superagent that gives Requests a Promises/A+ .then().", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
4625
26