Socket
Socket
Sign inDemoInstall

bfet

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

164

lib/core/core.js

@@ -85,51 +85,51 @@ 'use strict';

}
}
} else {
// listen to event 'data' for each indivdiual chunk of data
response.on('data', function (chunk) {
dataChunks.push(chunk);
});
// listen to event 'data' for each indivdiual chunk of data
response.on('data', function (chunk) {
dataChunks.push(chunk);
});
// listen to event 'end' when all chunks of data are transmitted
response.on('end', function () {
// listen to event 'end' when all chunks of data are transmitted
response.on('end', function () {
// combine all data chunks together
var d = dataChunks.join('');
// combine all data chunks together
var d = dataChunks.join('');
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
var rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
var rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
} catch (e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
} catch (e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
}
} else {
// just get the data back
rd = d;
}
} else {
// just get the data back
rd = d;
}
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// listen to event 'error'
response.on('error', function (e) {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
// listen to event 'error'
response.on('error', function (e) {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
}
});

@@ -232,51 +232,51 @@

}
}
} else {
// listen to event 'data' for each indivdiual chunk of data
response.on('data', function (chunk) {
dataChunks.push(chunk);
});
// listen to event 'data' for each indivdiual chunk of data
response.on('data', function (chunk) {
dataChunks.push(chunk);
});
// listen to event 'end' when all chunks of data are transmitted
response.on('end', function () {
// listen to event 'end' when all chunks of data are transmitted
response.on('end', function () {
// combine all data chunks together
var d = dataChunks.join('');
// combine all data chunks together
var d = dataChunks.join('');
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
var rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
var rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
} catch (e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
} catch (e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
}
} else {
// just get the data back
rd = d;
}
} else {
// just get the data back
rd = d;
}
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// listen to event 'error'
response.on('error', function (e) {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
// listen to event 'error'
response.on('error', function (e) {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
}
});

@@ -283,0 +283,0 @@

{
"name": "bfet",
"version": "1.1.0",
"version": "1.1.1",
"description": "A thin minimal wrapped around http|https NodeJS module for NodeJS and browser.",

@@ -5,0 +5,0 @@ "main": "lib/bfet.js",

@@ -92,52 +92,53 @@ 'use strict';

}
else {
// listen to event 'data' for each indivdiual chunk of data
response.on('data', (chunk) => {
dataChunks.push(chunk);
});
// listen to event 'data' for each indivdiual chunk of data
response.on('data', (chunk) => {
dataChunks.push(chunk);
});
// listen to event 'end' when all chunks of data are transmitted
response.on('end', () => {
// listen to event 'end' when all chunks of data are transmitted
response.on('end', () => {
// combine all data chunks together
let d = dataChunks.join('');
// combine all data chunks together
let d = dataChunks.join('');
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
let rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
let rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
}
catch(e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
}
}
catch(e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
else {
// just get the data back
rd = d;
}
}
else {
// just get the data back
rd = d;
}
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// listen to event 'error'
response.on('error', (e) => {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
// listen to event 'error'
response.on('error', (e) => {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
}
});

@@ -247,52 +248,53 @@

}
else {
// listen to event 'data' for each indivdiual chunk of data
response.on('data', (chunk) => {
dataChunks.push(chunk);
});
// listen to event 'data' for each indivdiual chunk of data
response.on('data', (chunk) => {
dataChunks.push(chunk);
});
// listen to event 'end' when all chunks of data are transmitted
response.on('end', () => {
// listen to event 'end' when all chunks of data are transmitted
response.on('end', () => {
// combine all data chunks together
let d = dataChunks.join('');
// combine all data chunks together
let d = dataChunks.join('');
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
// check if data is null
if (d == null) {
var error = new Error("Response is null");
error.code = bfet.errorCode.responseIsNull;
return reject();
}
let rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
let rd = null;
var json_parse = bfet.util.propChk(opts, "json_parse", true);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
if (json_parse) {
try {
// parse data resposne to json
rd = JSON.parse(d);
}
catch(e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
}
}
catch(e) {
var error = new Error("Error parsing JSON response message [" + e.message + "]");
error.code = bfet.errorCode.jsonParsedError;
return reject(error);
else {
// just get the data back
rd = d;
}
}
else {
// just get the data back
rd = d;
}
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// all ok
// note: we didn't check for api-level error here, user
// need to manually check on their side
return resolve(rd);
});
// listen to event 'error'
response.on('error', (e) => {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
// listen to event 'error'
response.on('error', (e) => {
var error = new Error("Response error [" + e.message + "]");
error.code = bfet.errorCode.responseError;
return reject(error);
});
}
});

@@ -299,0 +301,0 @@

@@ -67,12 +67,2 @@ var isBrowser = new Function("try {return this===window;}catch(e){ return false;}");

it("should be able to support 302 (redirect URL)", function(done) {
// playbasis.com has returned 302, and support CORS
bfet.get("https://playbasis.com", null, { json_parse: false} )
.then((result) => {
done();
}, (e) => {
fail(e);
});
});
// only test this test case on nodejs

@@ -93,3 +83,3 @@ // as target website doesn't support CORS

it("should be able to support 301 (moved permanently)", function(done) {
// baidu.com has returned 301, but doesn't support CORS
// baidu.com has returned 301
bfet.get("https://baidu.com", null, { json_parse: false })

@@ -101,4 +91,15 @@ .then((result) => {

});
});
});
it("should be able to support 302 (redirect URL)", function(done) {
// playbasis.com has returned 302
bfet.get("https://playbasis.com", null, { json_parse: false} )
.then((result) => {
done();
}, (e) => {
console.log("error: ", e);
fail(e);
});
});
}
});

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc