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

bestbuy

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bestbuy - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

5

CHANGELOG.md

@@ -0,1 +1,6 @@

## 2.1.1 (2017-11-18)
- Added retry logic to ensure streams are more resilient.
- Show more data when debugging streams.
## 2.1.0 (2017-10-05)

@@ -2,0 +7,0 @@ - Added new endpoint: `realTimeAvailability` to check the near real-time availability of a sku for a store or postal code.

@@ -25,2 +25,6 @@ module.exports = apiServiceFactory;

.catch(error => {
if (error.response && error.response.status > 400 && error.response.status !== 404) {
return waitABit(1000).then(() => apiService(requestOpts, callback));
}
if (callback) callback(error.response);

@@ -31,2 +35,8 @@ return Promise.reject(error.response);

function waitABit (ms) {
return new Promise(resolve => {
setTimeout(() => resolve(true), ms);
});
}
function runAxios (opts, data) {

@@ -33,0 +43,0 @@ if (opts.debug) {

54

lib/debug-logger.js
module.exports = debugLogger;
var peek = require('peek-stream');
var through = require('through2');
var pump = require('pump');
function debugLogger (instance, debug) {

@@ -8,3 +12,13 @@ var debugFn;

} else {
debugFn = (data) => { console.log(JSON.stringify(data, null, 2)); };
debugFn = (data) => {
var formattedData;
try {
formattedData = JSON.stringify(data, null, 2);
} catch (err) {
console.error('Error while trying to JSON format the data!', err.message, err.stack);
formattedData = data;
}
console.log(formattedData);
};
}

@@ -26,11 +40,31 @@

var body = response.data;
if (response.data.readable) body = 'stream';
debugFn({
response: {
headers: response.headers,
status: response.status,
url: response.url,
body: body
}
});
if (response.data.readable) {
var stream = body;
var peekStream = peek(function (data, swap) {
debugFn({
response: {
headers: response.headers,
status: response.status,
url: response.url,
isStream: true,
body: data.toString()
}
});
swap(null, through());
});
pump(stream, peekStream);
response.data = peekStream;
} else {
debugFn({
response: {
headers: response.headers,
status: response.status,
url: response.url,
body: body
}
});
}
return response;

@@ -37,0 +71,0 @@ }, function (error) {

3

package.json
{
"name": "bestbuy",
"version": "2.1.0",
"version": "2.1.1",
"description": "High level node.js client for the Best Buy API.",

@@ -39,2 +39,3 @@ "main": "index.js",

"limiter": "^1.1.0",
"peek-stream": "^1.1.2",
"pump": "^1.0.2",

@@ -41,0 +42,0 @@ "through2": "^2.0.3"

var test = require('./lib/tape-nock-setup');
var BBY = require('../');
var AVAILABLE_SKU = 5670003; // Nintendo Switch
var UNAVAILABLE_SKU = 9554207; // Fallout 3 GOTY
var AVAILABLE_SKU = 4971902; // Insignia Batteries
var UNAVAILABLE_SKU = 5919830; // SNES Classic
var MINNEAPOLIS_POSTAL_CODE = 55454; // Minneapolis ZIP

@@ -28,9 +28,10 @@ var RICHFIELD_STORE_ID = '281'; // Richfield Big Box

t.ok(data.stores[0].storeType === 'Big_Box_Store', 'The RICHFIELD store has the correct storeType');
t.ok(data.stores[0].minPickupHours === 1, 'The RICHFIELD store has the correct minPickupHours');
t.ok(data.stores[0].lowStock === false, 'The RICHFIELD store has the correct lowStock');
t.end();
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
t.error(err, 'no error');
t.end();
});
});

@@ -51,3 +52,2 @@

t.ok(data.stores[0].storeType === 'Big_Box_Store', 'The RICHFIELD store has the correct storeType');
t.ok(data.stores[0].minPickupHours === 1, 'The RICHFIELD store has the correct minPickupHours');
t.ok(data.stores[0].lowStock === false, 'The RICHFIELD store has the correct lowStock');

@@ -103,3 +103,3 @@ t.end();

t.ok(data);
t.ok(data.ispuEligible === true, 'Eligible for in store pickup');
t.ok(data.ispuEligible === false, 'Eligible for in store pickup');
t.ok(data.stores.length === 0, 'No stores are returned');

@@ -113,3 +113,3 @@ t.end();

.then(function (data) {
t.ok(data.ispuEligible === true, 'Eligible for in store pickup');
t.ok(data.ispuEligible === false, 'Eligible for in store pickup');
t.ok(data.stores.length === 0, 'No stores are returned');

@@ -116,0 +116,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