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 1.1.0 to 1.1.1

2

package.json
{
"name": "response-objects",
"version": "1.1.0",
"version": "1.1.1",
"description": "simple value objects representing HTTP responses",

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

@@ -30,11 +30,13 @@ import status = require("statuses");

let bodyCreator: BodyCreator = (code, body) => body != null ? body : (status[code] || `Unknown status for ${code}`)
export const setBodyCreator = (fn: BodyCreator) => { bodyCreator = fn; }
const _setBodyCreator = (fn: BodyCreator) => { bodyCreator = fn; }
export const MARKER = Symbol.for("@@response-objects/MARKER");
const _MARKER = Symbol.for("@@response-objects/MARKER");
const proto: ResponseObject = { toJSON, toString, status: 0, statusCode: 0, headers: {}, [MARKER]: true };
export { _MARKER as MARKER, _setBodyCreator as setBodyCreator }
const proto: ResponseObject = { toJSON, toString, status: 0, statusCode: 0, headers: {}, [_MARKER]: true };
function createResponse (code: number): RConstructor {
const name = getName(code)
return _setName(function Response (body?: any, headers?: object) {
if (body && body[MARKER]) throw new Error(`Object is already a response: ${JSON.stringify(body)}`);
if (body && body[_MARKER]) throw new Error(`Object is already a response: ${JSON.stringify(body)}`);
return _decorate(Object.create(proto), code, body, headers);

@@ -48,3 +50,3 @@ }, name);

return _setName(function ErrorResponse (body?: any, headers?: object) {
if (body && body[MARKER]) throw new Error(`Object is already a response: ${JSON.stringify(body)}`);
if (body && body[_MARKER]) throw new Error(`Object is already a response: ${JSON.stringify(body)}`);
const err = Object.create(errProto);

@@ -210,2 +212,5 @@ _decorate(err, code, body, headers);

export const NetworkAuthenticationRequired = createErrorResponse(511)
export const setBodyCreator = _setBodyCreator
export const MARKER = _MARKER
}

@@ -212,0 +217,0 @@

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