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

pouchdb-ajax

Package Overview
Dependencies
Maintainers
5
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pouchdb-ajax - npm Package Compare versions

Comparing version 5.4.4 to 5.4.5

40

lib/index-browser.js

@@ -134,4 +134,3 @@ 'use strict';

} catch (exception) {
/* error code hardcoded to throw INVALID_URL */
callback(exception, {statusCode: 413});
return callback(new Error(exception.name || 'Url is invalid'));
}

@@ -203,5 +202,5 @@

var err = {};
if(timedout) {
if (timedout) {
err = new Error('ETIMEDOUT');
response.statusCode = 400; // for consistency with node request
err.code = 'ETIMEDOUT';
} else {

@@ -212,3 +211,4 @@ try {

}
callback(err, response);
err.status = xhr.status;
callback(err);
}

@@ -271,2 +271,3 @@ };

if (!options.binary && options.json && typeof obj === 'string') {
/* istanbul ignore next */
try {

@@ -294,27 +295,2 @@ obj = JSON.parse(obj);

function onError(err, cb) {
var errParsed, errObj;
if (err.code && err.status) {
var err2 = new Error(err.message || err.code);
err2.status = err.status;
return cb(err2);
}
/* istanbul ignore if */
if (err.message && err.message === 'ETIMEDOUT') {
return cb(err);
}
// We always get code && status in node
/* istanbul ignore next */
try {
errParsed = JSON.parse(err.responseText);
//would prefer not to have a try/catch clause
errObj = pouchdbErrors.generateErrorFromResponse(errParsed);
} catch (e) {
errObj = pouchdbErrors.generateErrorFromResponse(err);
}
/* istanbul ignore next */
cb(errObj);
}
if (options.json) {

@@ -338,5 +314,5 @@ if (!options.binary) {

return ajax$1(options, function (err, response, body) {
if (err) {
err.status = response ? response.statusCode : 400;
return onError(err, callback);
return callback(pouchdbErrors.generateErrorFromResponse(err));
}

@@ -343,0 +319,0 @@

30

lib/index.js

@@ -37,2 +37,3 @@ 'use strict';

if (!options.binary && options.json && typeof obj === 'string') {
/* istanbul ignore next */
try {

@@ -60,27 +61,2 @@ obj = JSON.parse(obj);

function onError(err, cb) {
var errParsed, errObj;
if (err.code && err.status) {
var err2 = new Error(err.message || err.code);
err2.status = err.status;
return cb(err2);
}
/* istanbul ignore if */
if (err.message && err.message === 'ETIMEDOUT') {
return cb(err);
}
// We always get code && status in node
/* istanbul ignore next */
try {
errParsed = JSON.parse(err.responseText);
//would prefer not to have a try/catch clause
errObj = pouchdbErrors.generateErrorFromResponse(errParsed);
} catch (e) {
errObj = pouchdbErrors.generateErrorFromResponse(err);
}
/* istanbul ignore next */
cb(errObj);
}
if (options.json) {

@@ -104,5 +80,5 @@ if (!options.binary) {

return request(options, function (err, response, body) {
if (err) {
err.status = response ? response.statusCode : 400;
return onError(err, callback);
return callback(pouchdbErrors.generateErrorFromResponse(err));
}

@@ -109,0 +85,0 @@

{
"name": "pouchdb-ajax",
"version": "5.4.4",
"version": "5.4.5",
"description": "PouchDB's ajax() method.",

@@ -27,8 +27,8 @@ "main": "./lib/index.js",

"js-extend": "1.0.1",
"pouchdb-binary-utils": "5.4.4",
"pouchdb-errors": "5.4.4",
"pouchdb-promise": "5.4.4",
"pouchdb-utils": "5.4.4",
"pouchdb-binary-utils": "5.4.5",
"pouchdb-errors": "5.4.5",
"pouchdb-promise": "5.4.5",
"pouchdb-utils": "5.4.5",
"request": "2.72.0"
}
}

@@ -25,2 +25,3 @@ import request from './request';

if (!options.binary && options.json && typeof obj === 'string') {
/* istanbul ignore next */
try {

@@ -48,27 +49,2 @@ obj = JSON.parse(obj);

function onError(err, cb) {
var errParsed, errObj;
if (err.code && err.status) {
var err2 = new Error(err.message || err.code);
err2.status = err.status;
return cb(err2);
}
/* istanbul ignore if */
if (err.message && err.message === 'ETIMEDOUT') {
return cb(err);
}
// We always get code && status in node
/* istanbul ignore next */
try {
errParsed = JSON.parse(err.responseText);
//would prefer not to have a try/catch clause
errObj = generateErrorFromResponse(errParsed);
} catch (e) {
errObj = generateErrorFromResponse(err);
}
/* istanbul ignore next */
cb(errObj);
}
if (options.json) {

@@ -92,5 +68,5 @@ if (!options.binary) {

return request(options, function (err, response, body) {
if (err) {
err.status = response ? response.statusCode : 400;
return onError(err, callback);
return callback(generateErrorFromResponse(err));
}

@@ -97,0 +73,0 @@

@@ -129,4 +129,3 @@ /* global fetch */

} catch (exception) {
/* error code hardcoded to throw INVALID_URL */
callback(exception, {statusCode: 413});
return callback(new Error(exception.name || 'Url is invalid'));
}

@@ -198,5 +197,5 @@

var err = {};
if(timedout) {
if (timedout) {
err = new Error('ETIMEDOUT');
response.statusCode = 400; // for consistency with node request
err.code = 'ETIMEDOUT';
} else {

@@ -207,3 +206,4 @@ try {

}
callback(err, response);
err.status = xhr.status;
callback(err);
}

@@ -210,0 +210,0 @@ };

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