You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// import { ISchema, NameToDefindex, DefindexToName, SchemaEnum } from 'tf2-item-format'
56
53
```
54
+
57
55
Then you just have to:
56
+
58
57
```ts
59
58
import { createFormat } from'tf2-item-format';
60
59
61
60
const format =createFormat(schema);
62
61
```
62
+
63
63
Every method is then export same as before.
64
64
65
65
You can use `parseSKU` and `toSKU` without schema:
66
+
66
67
```ts
67
68
import { parseSKU, toSKU } from'tf2-item-format';
68
69
```
69
70
70
71
Please note that static schema has implemented a lot of overwrites for defindexes that simply cannot be obtained by the limited data we have, so when you are implementing it yourself you should use the current `Schema` as your guide.
71
72
73
+
`getVersion` function should return a versioning number for your schema, we recommend incrementing
74
+
this whenever you update your schema, so that cached items, like exceptions for item combinations
75
+
that cannot co-exist, can be recalculated. Only do this whenever the schema actually changes,
76
+
easiest way to do that, is by checking the item count between updates.
77
+
72
78
## Instalation
79
+
73
80
Via NPM: `npm install tf2-item-format`
74
81
Or Yarn: `yarn add tf2-item-format`
75
82
76
83
## Documentation
84
+
77
85
Currently there is no full documentation.
78
86
79
87
We export these methods:
88
+
80
89
-`parseString`
81
90
-`stringify`
82
91
-`parseEconItem`
@@ -86,12 +95,14 @@ We export these methods:
86
95
-`fixName`
87
96
88
97
And static schema:
98
+
89
99
- under property `schema`
90
100
91
101
Everything is fully typed so you should be able to get this working on your own, until I make a documentation.
92
102
Some of the types are a bit confusing which will get fixed in next major version.
-`determineUniqueHat` - if set it checks in schema if given item should use `The` in name, defaults to `false`
124
139
- Returns the item name
125
140
126
-
#### Note for stringify
127
-
If you are using sku format to store your items and want to use `The` in your names, you have to turn `determineUniqueHat` to `true`.
141
+
> [!INFO]
142
+
> If you are using sku format to store your items and want to use `The` in your names, you have to turn `determineUniqueHat` to `true`.
143
+
144
+
### parseSKU
145
+
```ts
146
+
parseSKU(sku: string): SKUAttributes
147
+
```
148
+
149
+
Parse Marketplace.tf's SKU format into `SKUAttributes` object, which is compatible with other methods.
150
+
151
+
### toSKU
152
+
```ts
153
+
toSKU(attribute: SKUAttributes): string
154
+
```
155
+
156
+
Get an SKU from `SKUAttributes` object, you can also supply `EconItem` or attributes from `parseString` if you have `inNumbers` and `useDefindexes` set to true.
128
157
129
158
## Compability usage
159
+
130
160
```ts
131
161
// Have a name, want a sku
132
162
const attributes =parseString(name, true, true); // To get defindexes and enums
@@ -140,4 +170,5 @@ const name = stringify(attributes);
140
170
const attributes =parseSKU(sku);
141
171
const listing =createBPListing(attributes);
142
172
```
173
+
143
174
Every method should be interchangable in similar ways.
0 commit comments