teeny-request
Advanced tools
Comparing version 3.11.3 to 4.0.0
@@ -8,3 +8,3 @@ "use strict"; | ||
return extendStatics(d, b); | ||
} | ||
}; | ||
return function (d, b) { | ||
@@ -47,3 +47,3 @@ extendStatics(d, b); | ||
function requestToFetchOptions(reqOpts) { | ||
var options = __assign({ method: reqOpts.method || 'GET' }, reqOpts.timeout && { timeout: reqOpts.timeout }, reqOpts.gzip && { compress: reqOpts.gzip }); | ||
var options = __assign({ method: reqOpts.method || 'GET' }, (reqOpts.timeout && { timeout: reqOpts.timeout }), (reqOpts.gzip && { compress: reqOpts.gzip })); | ||
if (typeof reqOpts.json === 'object') { | ||
@@ -91,3 +91,3 @@ // Add Content-type: application/json header | ||
var resHeaders = {}; | ||
res.headers.forEach(function (value, key) { return resHeaders[key] = value; }); | ||
res.headers.forEach(function (value, key) { return (resHeaders[key] = value); }); | ||
var response = Object.assign(res.body, { | ||
@@ -140,8 +140,6 @@ statusCode: res.status, | ||
var boundary = uuid.v4(); | ||
options.headers['Content-Type'] = | ||
"multipart/related; boundary=" + boundary; | ||
options.headers['Content-Type'] = "multipart/related; boundary=" + boundary; | ||
options.body = createMultipartStream(boundary, multipart); | ||
// Multipart upload | ||
node_fetch_1.default(uri, options) | ||
.then(function (res) { | ||
node_fetch_1.default(uri, options).then(function (res) { | ||
var header = res.headers.get('content-type'); | ||
@@ -171,18 +169,7 @@ var response = fetchToRequestResponse(reqOpts, res); | ||
} | ||
if (callback === undefined) { // Stream mode | ||
if (callback === undefined) { | ||
// Stream mode | ||
var requestStream_1 = new stream_1.PassThrough(); | ||
options.compress = false; | ||
node_fetch_1.default(uri, options) | ||
.then(function (res) { | ||
if (!res.ok) { | ||
res.text().then(function (text) { | ||
var error = new RequestError(text); | ||
error.code = res.status; | ||
requestStream_1.emit('error', error); | ||
return; | ||
}, function (error) { | ||
requestStream_1.emit('error', error); | ||
}); | ||
return; | ||
} | ||
node_fetch_1.default(uri, options).then(function (res) { | ||
res.body.on('error', function (err) { | ||
@@ -204,4 +191,3 @@ console.log('whoa there was an error, passing it on: ' + err); | ||
// GET or POST with callback | ||
node_fetch_1.default(uri, options) | ||
.then(function (res) { | ||
node_fetch_1.default(uri, options).then(function (res) { | ||
var header = res.headers.get('content-type'); | ||
@@ -208,0 +194,0 @@ var response = fetchToRequestResponse(reqOpts, res); |
{ | ||
"name": "teeny-request", | ||
"version": "3.11.3", | ||
"version": "4.0.0", | ||
"description": "Like request, but smaller.", | ||
@@ -44,3 +44,3 @@ "main": "./build/src/index.js", | ||
"@types/mocha": "^5.2.5", | ||
"@types/nock": "^9.3.0", | ||
"@types/nock": "^10.0.0", | ||
"@types/node-fetch": "^2.1.2", | ||
@@ -50,6 +50,6 @@ "@types/request": "^2.47.1", | ||
"codecov": "^3.1.0", | ||
"gts": "^0.9.0", | ||
"mocha": "^5.2.0", | ||
"gts": "^1.0.0", | ||
"mocha": "^6.0.0", | ||
"nock": "^10.0.2", | ||
"nyc": "^13.1.0", | ||
"nyc": "^14.0.0", | ||
"typescript": "^3.0.1" | ||
@@ -56,0 +56,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
31784
239