cs2-inventory-resolver 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ByMykel
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ByMykel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,78 +1,78 @@
1
- # cs2-inventory-resolver
2
-
3
- Resolve raw CS2 Game Coordinator (GC) items into human-readable names, images, and categories.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install cs2-inventory-resolver
9
- ```
10
-
11
- ## Usage
12
-
13
- ### `resolveItem(gcItem)`
14
-
15
- Takes a raw GC item and returns its name, image URL, entity type, rarity, and marketability.
16
-
17
- For skins, the `name` is fully decorated with the appropriate prefix and wear:
18
-
19
- - `StatTrak™` prefix (detected via attribute 80)
20
- - `Souvenir` prefix (detected via attribute 140)
21
- - `★` for knives/gloves (already included in the base name)
22
- - Wear suffix based on `paint_wear` (e.g. `Factory New`, `Field-Tested`)
23
-
24
- ```ts
25
- import { resolveItem } from 'cs2-inventory-resolver';
26
-
27
- // Regular skin
28
- resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30 });
29
- // => { name: "AK-47 | Redline (Field-Tested)", image: "https://...", entity: "skin", rarity: { id: "rarity_mythical_weapon", name: "Restricted", color: "#8847ff" }, marketable: true }
30
-
31
- // StatTrak skin
32
- resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30, attribute: [{ def_index: 80, value_bytes: ... }] });
33
- // => { name: "StatTrak™ AK-47 | Redline (Field-Tested)", ... }
34
-
35
- // StatTrak knife (quality 3 = ★ already in name)
36
- resolveItem({ def_index: 507, paint_index: 38, quality: 3, paint_wear: 0.01, attribute: [{ def_index: 80, value_bytes: ... }] });
37
- // => { name: "★ StatTrak™ Karambit | Fade (Factory New)", ... }
38
-
39
- // Non-skin item
40
- resolveItem({ def_index: 1505 });
41
- // => { name: "CS:GO Case Key", image: "https://...", entity: "key", rarity: null, marketable: true }
42
- ```
43
-
44
- Returns `null` if the item could not be identified.
45
-
46
- #### Input (`GcItemInput`)
47
-
48
- | Field | Type | Description |
49
- |-------|------|-------------|
50
- | `def_index` | `number` | Item definition index (required) |
51
- | `paint_index` | `number?` | Paint/skin index |
52
- | `quality` | `number?` | Item quality (`3` = ★ knife/glove) |
53
- | `paint_wear` | `number?` | Wear float (`0.0`–`1.0`) |
54
- | `stickers` | `{sticker_id?: number}[]?` | Sticker slots |
55
- | `attribute` | `{def_index: number; value_bytes?: Buffer}[]?` | Raw attribute array |
56
-
57
- #### Output (`ResolvedItemData`)
58
-
59
- | Field | Type | Description |
60
- |-------|------|-------------|
61
- | `name` | `string` | Decorated item name |
62
- | `image` | `string` | Image URL |
63
- | `entity` | `ItemEntity` | Item type (`skin`, `crate`, `key`, `collectible`, etc.) |
64
- | `rarity` | `{id, name, color} \| null` | Rarity info or `null` |
65
- | `marketable` | `boolean` | Whether the item is marketable on Steam |
66
-
67
- ### `getAttributeUint32(item, attrDefIndex)`
68
-
69
- Reads a uint32 value from a GC item's raw `attribute[]` array.
70
-
71
- ```ts
72
- import { getAttributeUint32 } from 'cs2-inventory-resolver';
73
-
74
- const musicIndex = getAttributeUint32(gcItem, 166);
75
- if (musicIndex) {
76
- console.log('Music kit ID:', musicIndex);
77
- }
78
- ```
1
+ # cs2-inventory-resolver
2
+
3
+ Resolve raw CS2 Game Coordinator (GC) items into human-readable names, images, and categories.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install cs2-inventory-resolver
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### `resolveItem(gcItem)`
14
+
15
+ Takes a raw GC item and returns its name, image URL, entity type, rarity, and marketability.
16
+
17
+ For skins, the `name` is fully decorated with the appropriate prefix and wear:
18
+
19
+ - `StatTrak™` prefix (detected via attribute 80)
20
+ - `Souvenir` prefix (detected via attribute 140)
21
+ - `★` for knives/gloves (already included in the base name)
22
+ - Wear suffix based on `paint_wear` (e.g. `Factory New`, `Field-Tested`)
23
+
24
+ ```ts
25
+ import { resolveItem } from 'cs2-inventory-resolver';
26
+
27
+ // Regular skin
28
+ resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30 });
29
+ // => { name: "AK-47 | Redline (Field-Tested)", image: "https://...", entity: "skin", rarity: { id: "rarity_mythical_weapon", name: "Restricted", color: "#8847ff" }, marketable: true }
30
+
31
+ // StatTrak skin
32
+ resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30, attribute: [{ def_index: 80, value_bytes: ... }] });
33
+ // => { name: "StatTrak™ AK-47 | Redline (Field-Tested)", ... }
34
+
35
+ // StatTrak knife (quality 3 = ★ already in name)
36
+ resolveItem({ def_index: 507, paint_index: 38, quality: 3, paint_wear: 0.01, attribute: [{ def_index: 80, value_bytes: ... }] });
37
+ // => { name: "★ StatTrak™ Karambit | Fade (Factory New)", ... }
38
+
39
+ // Non-skin item
40
+ resolveItem({ def_index: 1505 });
41
+ // => { name: "CS:GO Case Key", image: "https://...", entity: "key", rarity: null, marketable: true }
42
+ ```
43
+
44
+ Returns `null` if the item could not be identified.
45
+
46
+ #### Input (`GcItemInput`)
47
+
48
+ | Field | Type | Description |
49
+ |-------|------|-------------|
50
+ | `def_index` | `number` | Item definition index (required) |
51
+ | `paint_index` | `number?` | Paint/skin index |
52
+ | `quality` | `number?` | Item quality (`3` = ★ knife/glove) |
53
+ | `paint_wear` | `number?` | Wear float (`0.0`–`1.0`) |
54
+ | `stickers` | `{sticker_id?: number}[]?` | Sticker slots |
55
+ | `attribute` | `{def_index: number; value_bytes?: Buffer}[]?` | Raw attribute array |
56
+
57
+ #### Output (`ResolvedItemData`)
58
+
59
+ | Field | Type | Description |
60
+ |-------|------|-------------|
61
+ | `name` | `string` | Decorated item name |
62
+ | `image` | `string` | Image URL |
63
+ | `entity` | `ItemEntity` | Item type (`skin`, `crate`, `key`, `collectible`, etc.) |
64
+ | `rarity` | `{id, name, color} \| null` | Rarity info or `null` |
65
+ | `marketable` | `boolean` | Whether the item is marketable on Steam |
66
+
67
+ ### `getAttributeUint32(item, attrDefIndex)`
68
+
69
+ Reads a uint32 value from a GC item's raw `attribute[]` array.
70
+
71
+ ```ts
72
+ import { getAttributeUint32 } from 'cs2-inventory-resolver';
73
+
74
+ const musicIndex = getAttributeUint32(gcItem, 166);
75
+ if (musicIndex) {
76
+ console.log('Music kit ID:', musicIndex);
77
+ }
78
+ ```