New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

response-objects

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

response-objects - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

6

index.js

@@ -62,3 +62,3 @@ const status = require("statuses");

resp.status = resp.statusCode = code;
resp.body = body != null ? body : defaultBody(code, headers);
resp.body = bodyCreator(code, body, headers);
if (headers != null) resp.headers = headers;

@@ -68,3 +68,3 @@ return resp;

let defaultBody = (code /*, headers */ ) => status[code];
exports.createDefaultBody = f => defaultBody = f;
let bodyCreator = (code, body /*, headers */) => body != null ? body : status[code];
exports.setBodyCreator = f => bodyCreator = f;
{
"name": "response-objects",
"version": "0.6.0",
"version": "0.7.0",
"description": "simple value objects representing HTTP responses",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@ const expect = require("expect");

const noTest = [ "MARKER", "createDefaultBody" ];
const noTest = [ "MARKER", "setBodyCreator" ];

@@ -99,4 +99,13 @@ const someResponse = R.Ok();

it("createDefaultBody", function () {
R.createDefaultBody(() => ({}));
expect(R.Ok().body).toEqual({});
const _headers = {};
R.setBodyCreator((code, body, headers) => {
expect(code).toBe(200);
expect(body).toBe("success");
expect(headers).toBe(_headers);
return { status: body };
});
expect(R.Ok("success", _headers).body).toEqual({ status: "success" });
resetBodyCreator();
});

@@ -119,1 +128,5 @@ });

});
function resetBodyCreator () {
R.setBodyCreator((code, body) => body != null ? body : status[code]);
}
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