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

teepee

Package Overview
Dependencies
Maintainers
4
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

teepee - npm Package Compare versions

Comparing version 2.30.0 to 2.31.0

78

lib/Teepee.js

@@ -15,2 +15,4 @@ /*global JSON, setTimeout, setImmediate*/

passError = require('passerror'),
isStream = require('is-stream'),
FormData = require('form-data'),
http = require('http'),

@@ -66,4 +68,8 @@ https = require('https'),

// Invoked without new, shorthand for issuing a request
var teepee = new Teepee(config);
return teepee.request.call(teepee, {}, arguments[1]);
var args = Array.prototype.slice.call(arguments);
var teepee;
if (typeof args[0] === 'string' || (args[0] && typeof args[0] === 'object')) {
teepee = new Teepee(args.shift());
}
return teepee.request.apply(teepee, args);
}

@@ -304,11 +310,26 @@

*/
Teepee.prototype.request = function (options, cb) {
if (typeof options === 'string') {
options = { path: options };
} else if (typeof options === 'function') {
Teepee.prototype.request = function (url, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
} else {
options = options || {};
options = undefined;
} else if (typeof url === 'function') {
cb = url;
url = undefined;
options = undefined;
}
if (typeof url === 'string') {
if (options && typeof options === 'object') {
options.url = url;
url = undefined;
} else if (typeof options === 'undefined') {
options = { url: url };
url = undefined;
} else {
throw new Error('Teepee#request: options cannot be passed as ' + typeof options);
}
} else if (url && typeof url === 'object') {
options = url;
url = undefined;
}
options = options || {};

@@ -330,3 +351,30 @@ var numRetriesLeft = options.streamRows ? 0 : typeof options.numRetries !== 'undefined' ? options.numRetries : this.numRetries || 0,

[this.headers, options.headers].forEach(function (headersObj) {
var headerObjs = [this.headers, options.headers];
if (options && options.formData) {
if (typeof body !== 'undefined') {
throw new Error('Teepee#request: The "body" and "formData" options are not supported together');
}
body = new FormData();
Object.keys(options.formData).forEach(function (name) {
var value = options.formData[name],
partOptions = {};
if (isStream.readable(value) && value.path) {
partOptions.filename = value.path;
} else if (typeof value === 'object' && !Buffer.isBuffer(value)) {
partOptions = _.extend({}, value);
value = partOptions.value;
delete partOptions.value;
if (partOptions.fileName) {
partOptions.filename = partOptions.fileName;
delete partOptions.fileName;
}
}
body.append(name, value, partOptions);
});
headerObjs.push(body.getHeaders());
}
headerObjs.forEach(function (headersObj) {
if (headersObj) {

@@ -375,3 +423,3 @@ Object.keys(headersObj).forEach(function (headerName) {

var url = this._addQueryStringToUrl(this.resolveUrl(this.url, requestUrl, options), query);
url = this._addQueryStringToUrl(this.resolveUrl(this.url, requestUrl, options), query);
var auth;

@@ -812,2 +860,6 @@ // https://github.com/joyent/node/issues/25353 url.parse() fails if auth contain a colon,

}, args[0]);
} else if (args[1] && typeof args[1] === 'object') {
args[1] = _.defaults({
method: methodName
}, args[1]);
} else if (typeof args[0] === 'string') {

@@ -832,2 +884,6 @@ args[0] = { method: methodName, url: args[0] };

}, args[0]);
} else if (args[1] && typeof args[1] === 'object') {
args[1] = _.defaults({
method: methodName
}, args[1]);
} else if (typeof args[0] === 'string') {

@@ -834,0 +890,0 @@ args[0] = { method: methodName, url: args[0] };

6

package.json
{
"name": "teepee",
"version": "2.30.0",
"version": "2.31.0",
"description": "Generic HTTP client",

@@ -19,3 +19,5 @@ "main": "lib/Teepee.js",

"dnserrors": "2.1.0",
"form-data": "2.1.4",
"httperrors": "2.2.0",
"is-stream": "1.1.0",
"lodash": "^4.17.4",

@@ -29,3 +31,3 @@ "passerror": "1.1.1",

"eslint-config-onelint": "^1.1.0",
"httpception": "0.5.0",
"httpception": "0.5.1",
"istanbul": "^0.4.3",

@@ -32,0 +34,0 @@ "mocha": "^3.0.2",

Sorry, the diff of this file is too big to display

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