Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deferred-http-statuses

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deferred-http-statuses - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

28

index.js
var Q = require('q');
module.exports = function () {
module.exports = function (action) {
'use strict';

@@ -22,10 +22,19 @@

return {
var resolves = {
// 200s
success: resolve.bind(resolve, 200),
created: resolve.bind(resolve, 201),
accepted: resolve.bind(resolve, 202),
noContent: resolve.bind(resolve, 204),
partialContent: resolve.bind(resolve, 206)
};
var rejections = {
// 400s
badRequest: reject.bind(reject, 400),
unauthorized: reject.bind(reject, 401),
paymentRequired: reject.bind(reject, 402),
forbidden: reject.bind(reject, 403),
notFound: reject.bind(reject, 404),
methodNotAllowed: reject.bind(reject, 405),
conflict: reject.bind(reject, 409),

@@ -35,7 +44,16 @@ gone: reject.bind(reject, 410),

internalServerError: reject.bind(reject, 500),
// Exposure
notImplemented: reject.bind(reject, 501),
badGateway: reject.bind(reject, 502),
serviceUnavailable: reject.bind(reject, 503),
gatewayTimeout: reject.bind(reject, 504)
};
var promise = {
reject: deferred.reject,
resolve: deferred.resolve,
promise: deferred.promise
resolve: deferred.resolve
};
action(resolves, rejections, promise);
return deferred.promise;
};

4

package.json
{
"name": "deferred-http-statuses",
"version": "1.0.2",
"version": "2.0.0",
"description": "A quick promise wrapper and helper for http status codes",

@@ -24,4 +24,4 @@ "main": "index.js",

"dependencies": {
"q": "^1.2.0"
"q": "1.2.0"
}
}

@@ -10,30 +10,39 @@ ## DeferredHTTPStatuses

var Deferred = require('deferred-http-statuses');
var deferred = require('deferred-http-statuses');
var deferred = new Deferred();
return deferred(function (resolve, reject, promise) {
if (err) {
reject.badRequest(err);
} else {
resolve.success();
});
if (err) {
deferred.badRequest(err);
} else {
deferred.success();
}
### Methods
return deferred.promise;
// 200s
success,
created,
accepted,
noContent,
partialContent
### Methods
// 400s
badRequest,
unauthorized,
paymentRequired,
forbidden,
notFound,
methodNotAllowed,
conflict,
gone,
// 200s
success,
noContent,
// 400s
badRequest,
unauthorized,
notFound,
conflict,
gone,
// 500s
internalServerError,
// Exposure
reject: deferred.reject,
resolve: deferred.resolve,
promise: deferred.promise
// 500s
internalServerError,
notImplemented,
badGateway,
serviceUnavailable,
gatewayTimeout
// Exposure
reject: reject,
resolve: resolve

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc