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

send-data

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

send-data - npm Package Compare versions

Comparing version 3.3.2 to 3.3.3

25

json.js

@@ -1,2 +0,2 @@

var stringify = require("json-stringify-safe")
// var stringify = require("json-stringify-safe")

@@ -18,5 +18,11 @@ var send = require("./index")

var tuple = safeStringify(opts.body,
opts.replacer || null, opts.space || "");
if (tuple[0]) {
return callback(tuple[0]);
}
opts.headers = opts.headers || {}
opts.body = stringify(opts.body,
opts.replacer || null, opts.space || "")
opts.body = tuple[1];
opts.headers["Content-Type"] = "application/json"

@@ -26,1 +32,14 @@

}
function safeStringify(obj, replace, space) {
var json;
var error = null;
try {
json = JSON.stringify(obj, replace, space);
} catch (e) {
error = e;
}
return [error, json];
}

2

package.json
{
"name": "send-data",
"version": "3.3.2",
"version": "3.3.3",
"description": "send data through response",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -32,2 +32,18 @@ var test = require("tape")

})
} else if (req.url === "/json/shared") {
var shared = { foo: "bar" }
sendJson(req, res, {
shared1: shared,
shared2: shared
})
} else if (req.url === "/json/circular") {
var circular = {}
circular.circular = circular
sendJson(req, res, circular, function (err) {
if (err) {
res.end(err.message)
}
})
} else if (req.url === "/html") {

@@ -136,3 +152,25 @@ sendHtml(req, res, {

test("shared-json", function (t) {
request("/json/shared", function (err, res, body) {
var data = JSON.parse(body)
t.equal(res.statusCode, 200)
t.equal(data.shared1.foo, "bar")
t.equal(data.shared2.foo, "bar")
t.end()
})
})
test("circular-json", function (t) {
request("/json/circular", function (err, res, body) {
t.equal(res.statusCode, 200)
t.equal(res.body, "Converting circular structure to JSON")
t.end()
})
})
.on("end", done)
}
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