Huge News!Announcing our $40M Series B led by Abstract Ventures.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.5.0 to 0.6.0

.eslintrc

9

index.js

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

return _decorate(err, code, body, headers);
}, name)
}, name);
}

@@ -51,3 +51,3 @@

return _decorate(Object.create(proto), code, body, headers);
}, name)
}, name);
}

@@ -64,5 +64,8 @@

resp.status = resp.statusCode = code;
resp.body = body != null ? body : status[code];
resp.body = body != null ? body : defaultBody(code, headers);
if (headers != null) resp.headers = headers;
return resp;
}
let defaultBody = (code /*, headers */ ) => status[code];
exports.createDefaultBody = f => defaultBody = f;
{
"name": "response-objects",
"version": "0.5.0",
"description": "",
"version": "0.6.0",
"description": "simple value objects representing HTTP responses",
"main": "index.js",
"repository": {
"type": "git",
"url": "git://github.com/nickb1080/response-objects.git"
"url": "git://github.com/bttmly/response-objects.git"
},

@@ -13,8 +13,9 @@ "scripts": {

},
"author": "Nick Bottomley (github.com/nickb1080)",
"author": "Nick Bottomley (github.com/bttmly)",
"license": "MIT",
"dependencies": {
"statuses": "^1.3.0"
"statuses": "1.3.0"
},
"devDependencies": {
"eslint": "^3.19.0",
"expect": "^1.20.2",

@@ -21,0 +22,0 @@ "mocha": "^3.1.0"

@@ -11,3 +11,3 @@ # response-objects

This package is general-purpose, but is particularly useful with [koa-detour](http://github.com/nickb1080/koa-detour). Put simply, the idea is to raise the level of abstraction by having routes or resources return objects or throw errors that represent HTTP responses, rather than imperatively doing things like `res.write()` (or in Koa `ctx.body = ...`)
This package is general-purpose, but is particularly useful with [koa-detour](http://github.com/bttmly/koa-detour). Put simply, the idea is to raise the level of abstraction by having routes or resources return objects or throw errors that represent HTTP responses, rather than imperatively doing things like `res.write()` (or in Koa `ctx.body = ...`)

@@ -14,0 +14,0 @@ ```js

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

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

@@ -88,8 +88,19 @@ const someResponse = R.Ok();

describe("symbols", function () {
describe("miscellaneous", function () {
it("R.MARKER is a symbol", function () {
expect(R.MARKER).toBeA("symbol");
});
it("R.MARKER is in the symbol registry", function () {
const s = Symbol.for("@@response-objects/MARKER");
expect(s).toBe(R.MARKER);
});
it("createDefaultBody", function () {
R.createDefaultBody(() => ({}));
expect(R.Ok().body).toEqual({});
});
});
// rough measurements:

@@ -96,0 +107,0 @@ // 1.5s with Object.create() constructors

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