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

preq

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

preq - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

39

index.js

@@ -5,2 +5,4 @@ if (!global.Promise) {

var util = require('util');
if (!Array.prototype.last) {

@@ -39,5 +41,18 @@ Array.prototype.last = function() {

/*
* Error instance wrapping HTTP error responses
*
* Has the same properties as the original response.
*/
function HTTPErrorResponse(response) {
for (var key in response) {
this[key] = response[key];
}
this.stack = this.toString();
}
util.inherits(HTTPErrorResponse, Error);
function wrap(method) {
return function (url, options) {
var options = getOptions(url, options);
options = getOptions(url, options);
if (method) {

@@ -50,4 +65,3 @@ options.method = method;

if (!err) {
err = new Error('Response error');
err.response = {
err = new HTTPErrorResponse({
status: 500,

@@ -57,8 +71,16 @@ body: {

}
};
});
} else {
err = new HTTPErrorResponse({
status: 500,
body: {
type: 'internal_error'
},
stack: err.stack
});
}
return reject(err);
}
if (res.body && res.headers
&& /^application\/json/.test(res.headers['content-type'])) {
if (res.body && res.headers &&
/^application\/json/.test(res.headers['content-type'])) {
res.body = JSON.parse(res.body);

@@ -74,6 +96,3 @@ }

if (ourRes.status >= 400) {
var e = new Error('Response error:\n'
+ JSON.stringify(ourRes, null, 2));
e.response = ourRes;
reject(e);
reject(new HTTPErrorResponse(ourRes));
} else {

@@ -80,0 +99,0 @@ resolve(ourRes);

{
"name": "preq",
"version": "0.1.2",
"version": "0.2.0",
"description": "Yet another promising request wrapper",

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

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