https://github.com/mann-conomy/tf-sku
A static Node.js class for formatting Team Fortress 2 items into strings or JSON objects.
https://github.com/mann-conomy/tf-sku
formatter javascript json mann-conomy nodejs sku tf2 typescript
Last synced: 5 months ago
JSON representation
A static Node.js class for formatting Team Fortress 2 items into strings or JSON objects.
- Host: GitHub
- URL: https://github.com/mann-conomy/tf-sku
- Owner: Mann-Conomy
- License: mit
- Created: 2024-02-26T18:30:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-30T19:55:42.000Z (over 1 year ago)
- Last Synced: 2025-08-13T13:40:09.126Z (11 months ago)
- Topics: formatter, javascript, json, mann-conomy, nodejs, sku, tf2, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@mann-conomy/tf-sku
- Size: 85.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tf-sku
A static Node.js class for formatting Team Fortress 2 items into strings or JSON objects.
[](https://npmjs.com/package/@mann-conomy/tf-sku)
[](https://npmjs.com/package/@mann-conomy/tf-sku)
[](https://nodejs.org/en/about/releases/)
[](https://github.com/Mann-Conomy/tf-sku/blob/main/.github/workflows/test.yml)
[](https://github.com/Mann-Conomy/tf-sku/blob/main/LICENSE)
## Installation
Using [npm](https://www.npmjs.com/package/@mann-conomy/tf-sku):
```bash
$ npm install @mann-conomy/tf-sku
```
Using [yarn](https://yarnpkg.com/package/@mann-conomy/tf-sku):
```bash
$ yarn add @mann-conomy/tf-sku
```
## Testing
Using [npm](https://docs.npmjs.com/cli/v8/commands/npm-run-script):
```bash
$ npm test
```
Using [yarn](https://classic.yarnpkg.com/lang/en/docs/cli/run/):
```bash
$ yarn test
```
## Examples
Formatting Team Fortress 2 item objects into concise strings that captures their unique attributes.
```js
import { SKU } from "@mann-conomy/tf-sku";
try {
// Object representation of a Professional Festivized Australium Medi Gun
const item = {
defindex: 211,
quality: 11,
australium: true,
killstreak: 3,
festive: true
}
// Convert the item object into a SKU string
const sku = SKU.stringify(item);
console.log(sku); // 211;11;australium;kt-3;festive
} catch (error) {
console.error("Error creating SKU string", error.message);
}
```
Converting strings into structured objects that represent the attributes of Team Fortress 2 items.
```js
import { SKU } from "@mann-conomy/tf-sku";
try {
// String representation of a Strange Purple Energy Villain's Veil
const sku = "393;5;u10;strange";
// Parse the SKU string into an item object
const item = SKU.parse(sku);
console.log(item);
/*
{
defindex: 393,
quality: 5,
effect: 10,
australium: false,
craftable: true,
tradable: true,
wear: null,
paintkit: null,
elevated: true,
killstreak: 0,
target: null,
festive: false,
craftnumber: null,
crateseries: null,
output: null,
outputQuality: null,
paint: null
}
*/
} catch (error) {
console.error("Error parsing SKU string", error.message);
}
```
Some more examples are available in the [examples](https://github.com/Mann-Conomy/tf-sku/tree/main/examples) and [test](https://github.com/Mann-Conomy/tf-sku/tree/main/test) directories.
## Documentation
See the [Wiki pages](https://github.com/Mann-Conomy/tf-sku/wiki) for further documentation.
## License
[MIT](LICENSE)
Copyright 2024, The Mann-Conomy Project