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

send-data

Package Overview
Dependencies
Maintainers
2
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 7.0.0 to 8.0.0

19

css.js

@@ -1,14 +0,23 @@

var send = require("./index")
'use strict';
var extend = require('xtend');
var send = require('./index')
var CONTENT_TYPE_HEADER = {
'content-type': 'text/css'
};
module.exports = sendCss
function sendCss(req, res, opts, callback) {
if (typeof opts === "string" || Buffer.isBuffer(opts)) {
if (typeof opts === 'string' || Buffer.isBuffer(opts)) {
opts = { body: opts }
} else {
opts = extend(opts);
}
opts.headers = opts.headers || {}
opts.headers["Content-Type"] = "text/css"
opts.headers = extend(opts.headers, CONTENT_TYPE_HEADER);
send(req, res, opts, callback)
}
}

@@ -1,15 +0,24 @@

var Buffer = require("buffer").Buffer;
var send = require("./index")
'use strict';
var Buffer = require('buffer').Buffer;
var extend = require('xtend');
var send = require('./index')
var CONTENT_TYPE_HEADER = {
'content-type': 'text/html'
};
module.exports = sendHtml
function sendHtml(req, res, opts, callback) {
if (typeof opts === "string" || Buffer.isBuffer(opts)) {
if (typeof opts === 'string' || Buffer.isBuffer(opts)) {
opts = { body: opts }
} else {
opts = extend(opts);
}
opts.headers = opts.headers || {}
opts.headers["Content-Type"] = "text/html"
opts.headers = extend(opts.headers, CONTENT_TYPE_HEADER);
send(req, res, opts, callback)
send(req, res, opts, callback);
}

@@ -1,5 +0,7 @@

var Buffer = require("buffer").Buffer
var zlib = require("zlib")
'use strict';
var CALLBACK_REQUIRED = "send(req, res, opts, callback). Callback is required"
var Buffer = require('buffer').Buffer
var zlib = require('zlib')
var CALLBACK_REQUIRED = 'send(req, res, opts, callback). Callback is required'
var isGzip = /\bgzip\b/

@@ -12,6 +14,6 @@

var statusCode = opts.statusCode || null
var body = typeof opts === "object" ? opts.body : opts
var body = typeof opts === 'object' ? opts.body : opts
var gzip = opts.gzip || false
body = Buffer.isBuffer(body) ? body : new Buffer(body || "")
body = Buffer.isBuffer(body) ? body : new Buffer(body || '')
headers = headers || {}

@@ -35,6 +37,6 @@

res.once("finish", callback)
res.once('finish', callback)
res.setHeader("Content-Encoding", "gzip")
res.setHeader("Content-Length", body.length)
res.setHeader('content-encoding', 'gzip')
res.setHeader('content-length', body.length)
res.end(body)

@@ -44,6 +46,6 @@ })

if (callback) {
res.once("finish", callback)
res.once('finish', callback)
}
res.setHeader("Content-Length", body.length)
res.setHeader('content-length', body.length)
res.end(body)

@@ -54,5 +56,5 @@ }

function acceptsGzip(req) {
var acceptEncoding = req.headers["accept-encoding"] || ""
var acceptEncoding = req.headers['accept-encoding'] || ''
return !!acceptEncoding.match(isGzip)
}

@@ -0,1 +1,3 @@

'use strict';
module.exports = isSendObject

@@ -5,4 +7,4 @@

return object &&
(typeof object.statusCode === "number" ||
(typeof object.headers === "object" && object.headers !== null))
(typeof object.statusCode === 'number' ||
(typeof object.headers === 'object' && object.headers !== null));
}

@@ -0,1 +1,5 @@

'use strict';
var extend = require('xtend');
var send = require("./index")

@@ -5,11 +9,16 @@

var CONTENT_TYPE_HEADER = {
"content-type": "text/javascript"
}
function sendJavascript(req, res, opts, callback) {
if (typeof opts === "string" || Buffer.isBuffer(opts)) {
opts = { body: opts }
} else {
opts = extend(opts);
}
opts.headers = opts.headers || {}
opts.headers["Content-Type"] = "text/javascript"
opts.headers = extend(opts.headers, CONTENT_TYPE_HEADER);
send(req, res, opts, callback)
}

@@ -1,6 +0,14 @@

// var stringify = require("json-stringify-safe")
'use strict';
var send = require("./index")
var isSendObject = require("./is-send-object")
// var stringify = require('json-stringify-safe')
var extend = require('xtend');
var send = require('./index')
var isSendObject = require('./is-send-object')
var CONTENT_TYPE_HEADER = {
'content-type': 'application/json'
}
module.exports = sendJson

@@ -11,11 +19,12 @@

opts = { body: opts }
} else {
opts = extend(opts);
}
opts = opts || {}
if (opts.pretty) {
opts.space = " "
opts.space = ' '
}
var tuple = safeStringify(opts.body,
opts.replacer || null, opts.space || "");
opts.replacer || null, opts.space || '');

@@ -26,5 +35,4 @@ if (tuple[0]) {

opts.headers = opts.headers || {}
opts.headers = extend(opts.headers, CONTENT_TYPE_HEADER);
opts.body = tuple[1];
opts.headers["Content-Type"] = "application/json"

@@ -31,0 +39,0 @@ send(req, res, opts, callback)

{
"name": "send-data",
"version": "7.0.0",
"version": "8.0.0",
"description": "send data through response",

@@ -21,3 +21,3 @@ "keywords": [],

"json-stringify-safe": "^5.0.0",
"xtend": "^3.0.0"
"xtend": "^4.0.0"
},

@@ -24,0 +24,0 @@ "devDependencies": {

@@ -1,14 +0,23 @@

var send = require("./index")
'use strict';
var extend = require('xtend');
var send = require('./index')
var CONTENT_TYPE_HEADER = {
'content-type': 'text/plain; charset=utf-8'
}
module.exports = sendPlain
function sendPlain(req, res, opts, callback) {
if (typeof opts === "string" || Buffer.isBuffer(opts)) {
if (typeof opts === 'string' || Buffer.isBuffer(opts)) {
opts = { body: opts }
} else {
opts = extend(opts);
}
opts.headers = opts.headers || {}
opts.headers["Content-Type"] = "text/plain; charset=utf-8"
opts.headers = extend(opts.headers, CONTENT_TYPE_HEADER);
send(req, res, opts, callback)
}
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