mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-29 18:30:13 +08:00
Some more refactoring
This commit is contained in:
parent
40ee35ac89
commit
9d47d28a1e
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 = {};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user