superagent-bluebird-promise
Advanced tools
Comparing version 3.0.2 to 4.0.0
17
index.js
@@ -88,3 +88,3 @@ // From https://gist.github.com/epeli/11209665 | ||
* | ||
* Make superagent requests Promises/A+ conformant | ||
* Make superagent requests Promises ES6 conformant | ||
* | ||
@@ -102,1 +102,16 @@ * Call .then([onFulfilled], [onRejected]) to register callbacks | ||
}; | ||
/** | ||
* | ||
* Make superagent requests Promises ES6 conformant | ||
* | ||
* Call .catch([onRejected]) to register callback | ||
* | ||
* @method catch | ||
* @param {function} [onRejected] | ||
* @return {Bluebird.Promise} | ||
*/ | ||
Request.prototype.catch = function() { | ||
var promise = this.promise(); | ||
return promise.catch.apply(promise, arguments); | ||
}; |
{ | ||
"name": "superagent-bluebird-promise", | ||
"description": "Add promise support to superagent using Bluebird", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
@@ -36,9 +36,9 @@ "bugs": { | ||
"jshint": "^2.7.0", | ||
"mocha": "^2.2.4", | ||
"mocha": "^3.0.2", | ||
"mocha-unfunk-reporter": "^0.4.0", | ||
"pre-commit": "^1.0.6", | ||
"sinon": "^1.14.1", | ||
"superagent": "^1.2.0", | ||
"superagent": "^2.2.0", | ||
"underscore": "^1.8.3" | ||
} | ||
} |
@@ -14,3 +14,3 @@ [![Build Status](https://img.shields.io/travis/KyleAMathews/superagent-bluebird-promise/master.svg?style=flat-square)](http://travis-ci.org/KyleAMathews/superagent-bluebird-promise) | ||
## Usage | ||
Simply require this package instead of `superagent`. Then you can call `.then()` instead of `.end()` to get a promise for your requests. | ||
Simply require this package instead of `superagent`. Then you can call `.then()` or `.catch()` instead of `.end()` to get a promise for your requests. | ||
@@ -20,2 +20,3 @@ ```javascript | ||
// .then() | ||
request.get('/an-endpoint') | ||
@@ -27,2 +28,8 @@ .then(function(res) { | ||
}); | ||
// .catch() | ||
request.get('/an-endpoint') | ||
.catch(function(error) { | ||
console.log(error); | ||
}); | ||
``` | ||
@@ -29,0 +36,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 4 instances in 1 package
102
55
1
12684
9