Some more refactoring

This commit is contained in:
Alex Corn 2021-07-29 03:20:14 -04:00
parent 40ee35ac89
commit 9d47d28a1e
No known key found for this signature in database
GPG Key ID: E51989A3E7A27FDF
6 changed files with 18 additions and 20 deletions

View File

@ -44,15 +44,13 @@ function CEconItem(item, description, contextID) {
// Restore old property names of tags
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
};
});
this.tags = this.tags.map((tag) => ({
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

View File

@ -22,7 +22,7 @@ SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, cal
}
let item = new CMarketItem(appid, hashName, this, body, $);
item.updatePrice(currency, function(err) {
item.updatePrice(currency, (err) => {
if (err) {
callback(err);
} else {
@ -62,13 +62,11 @@ function CMarketItem(appid, hashName, community, body, $) {
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)
};
});
this.medianSalePrices = this.medianSalePrices.map((item) => ({
hour: new Date(item[0]),
price: item[1],
quantity: parseInt(item[2], 10)
}));
} catch (e) {
// ignore
}

View File

@ -38,7 +38,7 @@ SteamCommunity.prototype.marketSearch = function(options, callback) {
referer: 'https://steamcommunity.com/market/search'
},
json: true
}, function(err, response, body) {
}, (err, response, body) => {
if (err) {
callback(err);
return;

View File

@ -19,7 +19,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) {
return;
}
XML2JS.parseString(body, function(err, result) {
XML2JS.parseString(body, (err, result) => {
if (err) {
callback(err);
return;

View File

@ -19,7 +19,7 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
return;
}
XML2JS.parseString(body, function(err, result) {
XML2JS.parseString(body, (err, result) => {
if (err || (!result.response && !result.profile)) {
callback(err || new Error('No valid response'));
return;

View File

@ -552,6 +552,8 @@ SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callba
let $ = Cheerio.load(JSON.parse(body).comments_html);
// !! DO NOT replace this function with an arrow function. We depend on the `this` context inside the function,
// which is the comment element.
$('.commentthread_comment_content').each(function() {
let comment = {};