diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 1c13055..a69dc01 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -8,5 +8,6 @@
+
\ No newline at end of file
diff --git a/classes/CConfirmation.js b/classes/CConfirmation.js
index 8585474..80172c4 100644
--- a/classes/CConfirmation.js
+++ b/classes/CConfirmation.js
@@ -3,7 +3,7 @@ const SteamCommunity = require('../index.js');
module.exports = CConfirmation;
function CConfirmation(community, data) {
- Object.defineProperty(this, "_community", {"value": community});
+ Object.defineProperty(this, '_community', {value: community});
this.id = data.id.toString();
this.type = data.type;
@@ -19,7 +19,7 @@ function CConfirmation(community, data) {
CConfirmation.prototype.getOfferID = function(time, key, callback) {
if (this.type && this.creator) {
if (this.type != SteamCommunity.ConfirmationType.Trade) {
- callback(new Error("Not a trade confirmation"));
+ callback(new Error('Not a trade confirmation'));
return;
}
diff --git a/classes/CEconItem.js b/classes/CEconItem.js
index 4ccfc9b..49eebd5 100644
--- a/classes/CEconItem.js
+++ b/classes/CEconItem.js
@@ -1,14 +1,11 @@
module.exports = CEconItem;
function CEconItem(item, description, contextID) {
- var thing;
- for (thing in item) {
- if (item.hasOwnProperty(thing)) {
- this[thing] = item[thing];
- }
+ for (let thing in item) {
+ this[thing] = item[thing];
}
- var isCurrency = !!(this.is_currency || this.currency) || typeof this.currencyid !== 'undefined'; // I don't want to put this on the object yet; it's nice to have the ids at the top of printed output
+ let isCurrency = !!(this.is_currency || this.currency) || typeof this.currencyid !== 'undefined'; // I don't want to put this on the object yet; it's nice to have the ids at the top of printed output
if (isCurrency) {
this.currencyid = this.id = (this.id || this.currencyid);
@@ -27,10 +24,8 @@ function CEconItem(item, description, contextID) {
description = description[this.classid + '_' + this.instanceid];
}
- for (thing in description) {
- if (description.hasOwnProperty(thing)) {
- this[thing] = description[thing];
- }
+ for (let thing in description) {
+ this[thing] = description[thing];
}
}
@@ -51,18 +46,18 @@ function CEconItem(item, description, contextID) {
if (this.tags) {
this.tags = this.tags.map(function(tag) {
return {
- "internal_name": tag.internal_name,
- "name": tag.localized_tag_name || tag.name,
- "category": tag.category,
- "color": tag.color || "",
- "category_name": tag.localized_category_name || tag.category_name
+ internal_name: tag.internal_name,
+ name: tag.localized_tag_name || tag.name,
+ category: tag.category,
+ color: tag.color || '',
+ category_name: tag.localized_category_name || tag.category_name
};
});
}
// Restore market_fee_app, if applicable
- var match;
- if (this.appid == 753 && this.contextid == 6 && this.market_hash_name && (match = this.market_hash_name.match(/^(\d+)\-/))) {
+ let match;
+ if (this.appid == 753 && this.contextid == 6 && this.market_hash_name && (match = this.market_hash_name.match(/^(\d+)-/))) {
this.market_fee_app = parseInt(match[1], 10);
}
@@ -82,7 +77,7 @@ function CEconItem(item, description, contextID) {
this.cache_expiration = this.item_expiration;
}
- if (this.actions === "") {
+ if (this.actions === '') {
this.actions = [];
}
@@ -94,15 +89,15 @@ function CEconItem(item, description, contextID) {
}
CEconItem.prototype.getImageURL = function() {
- return "https://steamcommunity-a.akamaihd.net/economy/image/" + this.icon_url + "/";
+ return 'https://steamcommunity-a.akamaihd.net/economy/image/' + this.icon_url + '/';
};
CEconItem.prototype.getLargeImageURL = function() {
- if(!this.icon_url_large) {
+ if (!this.icon_url_large) {
return this.getImageURL();
}
- return "https://steamcommunity-a.akamaihd.net/economy/image/" + this.icon_url_large + "/";
+ return 'https://steamcommunity-a.akamaihd.net/economy/image/' + this.icon_url_large + '/';
};
CEconItem.prototype.getTag = function(category) {
@@ -110,7 +105,7 @@ CEconItem.prototype.getTag = function(category) {
return null;
}
- for (var i = 0; i < this.tags.length; i++) {
+ for (let i = 0; i < this.tags.length; i++) {
if (this.tags[i].category == category) {
return this.tags[i];
}
diff --git a/classes/CMarketItem.js b/classes/CMarketItem.js
index b031d34..c489cb4 100644
--- a/classes/CMarketItem.js
+++ b/classes/CMarketItem.js
@@ -3,32 +3,33 @@ const Cheerio = require('cheerio');
const SteamCommunity = require('../index.js');
SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, callback) {
- if (typeof currency == "function") {
+ if (typeof currency == 'function') {
callback = currency;
currency = 1;
}
- var self = this;
- this.httpRequest("https://steamcommunity.com/market/listings/" + appid + "/" + encodeURIComponent(hashName), function(err, response, body) {
+
+ this.httpRequest('https://steamcommunity.com/market/listings/' + appid + '/' + encodeURIComponent(hashName), (err, response, body) => {
if (err) {
callback(err);
return;
}
- var $ = Cheerio.load(body);
- if($('.market_listing_table_message') && $('.market_listing_table_message').text().trim() == 'There are no listings for this item.') {
- callback(new Error("There are no listings for this item."));
+ let $ = Cheerio.load(body);
+ let $listingTableMessage = $('.market_listing_table_message');
+ if ($listingTableMessage && $listingTableMessage.text().trim() == 'There are no listings for this item.') {
+ callback(new Error('There are no listings for this item.'));
return;
}
- var item = new CMarketItem(appid, hashName, self, body, $);
+ let item = new CMarketItem(appid, hashName, this, body, $);
item.updatePrice(currency, function(err) {
- if(err) {
+ if (err) {
callback(err);
} else {
callback(null, item);
}
});
- }, "steamcommunity");
+ }, 'steamcommunity');
};
function CMarketItem(appid, hashName, community, body, $) {
@@ -37,38 +38,38 @@ function CMarketItem(appid, hashName, community, body, $) {
this._community = community;
this._$ = $;
- this._country = "US";
- var match = body.match(/var g_strCountryCode = "([^"]+)";/);
- if(match) {
+ this._country = 'US';
+ let match = body.match(/var g_strCountryCode = "([^"]+)";/);
+ if (match) {
this._country = match[1];
}
- this._language = "english";
+ this._language = 'english';
match = body.match(/var g_strLanguage = "([^"]+)";/);
- if(match) {
+ if (match) {
this._language = match[1];
}
this.commodity = false;
match = body.match(/Market_LoadOrderSpread\(\s*(\d+)\s*\);/);
- if(match) {
+ if (match) {
this.commodity = true;
this.commodityID = parseInt(match[1], 10);
}
this.medianSalePrices = null;
match = body.match(/var line1=([^;]+);/);
- if(match) {
+ if (match) {
try {
this.medianSalePrices = JSON.parse(match[1]);
this.medianSalePrices = this.medianSalePrices.map(function(item) {
return {
- "hour": new Date(item[0]),
- "price": item[1],
- "quantity": parseInt(item[2], 10)
+ hour: new Date(item[0]),
+ price: item[1],
+ quantity: parseInt(item[2], 10)
};
});
- } catch(e) {
+ } catch (e) {
// ignore
}
}
@@ -101,90 +102,88 @@ CMarketItem.prototype.updatePrice = function (currency, callback) {
};
CMarketItem.prototype.updatePriceForCommodity = function(currency, callback) {
- if(!this.commodity) {
- throw new Error("Cannot update price for non-commodity item");
+ if (!this.commodity) {
+ throw new Error('Cannot update price for non-commodity item');
}
- var self = this;
this._community.httpRequest({
- "uri": "https://steamcommunity.com/market/itemordershistogram?country=US&language=english¤cy=" + currency + "&item_nameid=" + this.commodityID,
- "json": true
- }, function(err, response, body) {
- if (err) {
- callback(err);
- return;
- }
-
- if(body.success != 1) {
- if(callback) {
- callback(new Error("Error " + body.success));
- }
-
- return;
- }
-
- var match = (body.sell_order_summary || '').match(/