Compare commits

...

3 Commits

Author SHA1 Message Date
Alex Corn
2a12174a7c 3.50.0 2026-03-27 04:32:44 -04:00
DoctorMcKay
caa76ee84b Merge pull request #365 from DarkGL/feat/asset-properties
feat: Add asset_properties support to getInventoryContents
2026-03-27 04:29:47 -04:00
Rafal Wiecek
bc8893fedd feat: add asset properties to inventory items 2026-03-16 15:52:32 +01:00
3 changed files with 17 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
module.exports = CEconItem;
function CEconItem(item, description, contextID) {
function CEconItem(item, description, contextID, assetProperties) {
var thing;
for (thing in item) {
if (item.hasOwnProperty(thing)) {
@@ -86,6 +86,11 @@ function CEconItem(item, description, contextID) {
this.actions = [];
}
// Assign asset_properties if provided
if (assetProperties) {
this.asset_properties = assetProperties;
}
// One wouldn't think that we need this if statement, but apparently v8 has a weird bug/quirk where deleting a
// property results in greatly increased memory usage. Because that makes sense.
if (this.currency) {

View File

@@ -647,12 +647,21 @@ SteamCommunity.prototype.getUserInventoryContents = function(userID, appID, cont
return;
}
// Build asset_properties lookup by assetid
var assetPropertiesLookup = {};
if (body.asset_properties) {
for (var j = 0; j < body.asset_properties.length; j++) {
assetPropertiesLookup[body.asset_properties[j].assetid] = body.asset_properties[j].asset_properties;
}
}
for (var i = 0; i < body.assets.length; i++) {
var description = getDescription(body.descriptions, body.assets[i].classid, body.assets[i].instanceid);
if (!tradableOnly || (description && description.tradable)) {
body.assets[i].pos = pos++;
(body.assets[i].currencyid ? currency : inventory).push(new CEconItem(body.assets[i], description, contextID));
var assetProperties = assetPropertiesLookup[body.assets[i].assetid] || null;
(body.assets[i].currencyid ? currency : inventory).push(new CEconItem(body.assets[i], description, contextID, assetProperties));
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "steamcommunity",
"version": "3.49.0",
"version": "3.50.0",
"description": "Provides an interface for logging into and interacting with the Steam Community website",
"files": [
"/classes",