mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-31 03:22:31 +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
|
// Restore old property names of tags
|
||||||
if (this.tags) {
|
if (this.tags) {
|
||||||
this.tags = this.tags.map(function(tag) {
|
this.tags = this.tags.map((tag) => ({
|
||||||
return {
|
internal_name: tag.internal_name,
|
||||||
internal_name: tag.internal_name,
|
name: tag.localized_tag_name || tag.name,
|
||||||
name: tag.localized_tag_name || tag.name,
|
category: tag.category,
|
||||||
category: tag.category,
|
color: tag.color || '',
|
||||||
color: tag.color || '',
|
category_name: tag.localized_category_name || tag.category_name
|
||||||
category_name: tag.localized_category_name || tag.category_name
|
}));
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore market_fee_app, if applicable
|
// 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, $);
|
let item = new CMarketItem(appid, hashName, this, body, $);
|
||||||
item.updatePrice(currency, function(err) {
|
item.updatePrice(currency, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
} else {
|
} else {
|
||||||
@ -62,13 +62,11 @@ function CMarketItem(appid, hashName, community, body, $) {
|
|||||||
if (match) {
|
if (match) {
|
||||||
try {
|
try {
|
||||||
this.medianSalePrices = JSON.parse(match[1]);
|
this.medianSalePrices = JSON.parse(match[1]);
|
||||||
this.medianSalePrices = this.medianSalePrices.map(function(item) {
|
this.medianSalePrices = this.medianSalePrices.map((item) => ({
|
||||||
return {
|
hour: new Date(item[0]),
|
||||||
hour: new Date(item[0]),
|
price: item[1],
|
||||||
price: item[1],
|
quantity: parseInt(item[2], 10)
|
||||||
quantity: parseInt(item[2], 10)
|
}));
|
||||||
};
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ SteamCommunity.prototype.marketSearch = function(options, callback) {
|
|||||||
referer: 'https://steamcommunity.com/market/search'
|
referer: 'https://steamcommunity.com/market/search'
|
||||||
},
|
},
|
||||||
json: true
|
json: true
|
||||||
}, function(err, response, body) {
|
}, (err, response, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
|
@ -19,7 +19,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XML2JS.parseString(body, function(err, result) {
|
XML2JS.parseString(body, (err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
|
@ -19,7 +19,7 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XML2JS.parseString(body, function(err, result) {
|
XML2JS.parseString(body, (err, result) => {
|
||||||
if (err || (!result.response && !result.profile)) {
|
if (err || (!result.response && !result.profile)) {
|
||||||
callback(err || new Error('No valid response'));
|
callback(err || new Error('No valid response'));
|
||||||
return;
|
return;
|
||||||
|
@ -552,6 +552,8 @@ SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callba
|
|||||||
|
|
||||||
let $ = Cheerio.load(JSON.parse(body).comments_html);
|
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() {
|
$('.commentthread_comment_content').each(function() {
|
||||||
let comment = {};
|
let comment = {};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user