{"id":22281651,"url":"https://github.com/danocmx/node-tf2-item-format","last_synced_at":"2025-07-14T05:36:35.229Z","repository":{"id":36975601,"uuid":"178283435","full_name":"danocmx/node-tf2-item-format","owner":"danocmx","description":"Fully typed battle-tested library that helps you format TF2 items to the community standards.","archived":false,"fork":false,"pushed_at":"2025-06-28T15:58:49.000Z","size":5460,"stargazers_count":24,"open_issues_count":6,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-28T16:49:56.354Z","etag":null,"topics":["sku","tf2","tf2-items"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danocmx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-28T21:15:45.000Z","updated_at":"2025-06-28T15:58:46.000Z","dependencies_parsed_at":"2023-12-19T12:24:37.957Z","dependency_job_id":"6b1aa9ce-f4b0-4f0d-82c0-25a41e024f90","html_url":"https://github.com/danocmx/node-tf2-item-format","commit_stats":{"total_commits":396,"total_committers":7,"mean_commits":56.57142857142857,"dds":"0.33333333333333337","last_synced_commit":"2ba5a36ba1849cc27964d8c2aff36b2a9dae122c"},"previous_names":[],"tags_count":89,"template":false,"template_full_name":null,"purl":"pkg:github/danocmx/node-tf2-item-format","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danocmx%2Fnode-tf2-item-format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danocmx%2Fnode-tf2-item-format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danocmx%2Fnode-tf2-item-format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danocmx%2Fnode-tf2-item-format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danocmx","download_url":"https://codeload.github.com/danocmx/node-tf2-item-format/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danocmx%2Fnode-tf2-item-format/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262465431,"owners_count":23315625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sku","tf2","tf2-items"],"created_at":"2024-12-03T16:20:07.406Z","updated_at":"2025-07-14T05:36:35.204Z","avatar_url":"https://github.com/danocmx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TF2 Item Format\r\nFormatting for TF2 items.\r\n\r\nUse `v5` branch for current version.\r\nInstall it via `npm install tf2-item-format`\r\n\r\n## Features\r\n- Parses item name into attribute object\r\n- Stringifies attribute object into item name same as backpack.tf\r\n- Parses ECON item into attributes\r\n- Parses SKU into attributes\r\n- Makes SKU out of attributes\r\n- Creates backpack.tf compatible format for listing creation\r\n\r\n## Support the project\r\ntf2-item-format is now used in number of production grade projects for handling item data,\r\nhelp support the project by donating items [here](https://steamcommunity.com/tradeoffer/new/?partner=162338347\u0026token=Od7J3LIh).\r\n\r\n## Migrating from v4 to v5\r\nTo keep your application working like before with version 5 you have to:\r\n```ts\r\nimport { parseString } from 'tf2-item-format/static' // -\u003e from 'tf2-item-format'\r\n\r\nconst { parseString } = require('tf2-item-format/static') // -\u003e from 'tf2-item-format'\r\n```\r\n\r\n### New\r\n\r\nTo inject your own schema use this interface:\r\n```ts\r\nexport type ISchema = {\r\n    getDefindex(search: number | string): number|null;\r\n    getName(search: number | string): string;\r\n    getEffectName(effect: number | string): string;\r\n    getWearName(wear: number | string): string;\r\n    getKillstreakName(killstreak: number | string): string;\r\n    getTextureName(texture: number | string): string;\r\n    getQualityName(quality: number | string): string;\r\n    getEffectEnum(effect: number | string): number;\r\n    getWearEnum(wear: number | string): number;\r\n    getKillstreakEnum(killstreak: number | string): number;\r\n    getTextureEnum(texture: number | string): number;\r\n    getQualityEnum(quality: number | string): number;\r\n    getTextures(): SchemaEnum;\r\n    getEffects(): SchemaEnum;\r\n    isUniqueHat(defindexOrName: string | number): boolean;\r\n}\r\n\r\n// Extra types you might need:\r\nexport type NameToDefindex = { [name: string]: number };\r\nexport type DefindexToName = { [defindex: number]: string };\r\nexport type SchemaEnum = NameToDefindex \u0026 DefindexToName;\r\n\r\n// Import these like:\r\n// import { ISchema, NameToDefindex, DefindexToName, SchemaEnum } from 'tf2-item-format'\r\n```\r\nThen you just have to:\r\n```ts\r\nimport { createFormat } from 'tf2-item-format';\r\n\r\nconst format = createFormat(schema);\r\n```\r\nEvery method is then export same as before.\r\n\r\nYou can use `parseSKU` and `toSKU` without schema:\r\n```ts\r\nimport { parseSKU, toSKU } from 'tf2-item-format';\r\n```\r\n\r\nPlease 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.\r\n\r\n## Instalation\r\nVia NPM: `npm install tf2-item-format`\r\nOr Yarn: `yarn add tf2-item-format`\r\n\r\n## Documentation\r\nCurrently there is no full documentation.\r\n\r\nWe export these methods:\r\n- `parseString`\r\n- `stringify`\r\n- `parseEconItem`\r\n- `toSKU`\r\n- `parseSKU`\r\n- `createBPListing`\r\n- `fixName`\r\n\r\nAnd static schema:\r\n- under property `schema`\r\n\r\nEverything is fully typed so you should be able to get this working on your own, until I make a documentation.\r\nSome of the types are a bit confusing which will get fixed in next major version.\r\n\r\n### parseEconItem\r\n```ts\r\nparseEconItem(econ: EconItem, inNumbers: boolean, useDefindexes: boolean, options?: { useTrueDefindex: boolean }): ParsedEconItem;\r\n```\r\n\r\n- `econ` is raw item you receive from the api\r\n- `inNumbers` - changes return type of certain attributes to numbers instead of pure strings, eg. quality, texture, wear, ...\r\n- `useDefindexes` - appends item defindex to the object, adds target \u0026 output aswell\r\n- `options`\r\n    - `useTrueDefindex` - returns true defindex item has on this econ, doesn't ask schema.\r\n- Returns `ParsedEconItem` which is an object of all attributes the econ gives us\r\n\r\n### createBPListing\r\n```ts\r\ncreateBPListing(attributes: ItemAttributes | StringifySKUAttributes, options?: CreateBPListingOptions): BackpackTFListing\r\n```\r\n\r\n- `attributes` - these you get from `parseString`, `parseSKU` or `parseEconItem`, all are compatible\r\n- `options`\r\n    - `unuSkinsToDecorated` - defaults unusual skins to decorated weapon quality, default value is `true`\r\n- Returns `BackpackTFListing` object compatible with `item` object in backpack.tf listing creation api\r\n\r\n### stringify\r\n```ts\r\nstringify(attributes: StrigifySKUAttributes | ItemAttributes, options?: StringifyOptions): string\r\n```\r\n\r\n- `attributes` - these you get from `parseString`, `parseSKU` or `parseEconItem`, all are compatible\r\n- `options`\r\n    - `determineUniqueHat` - if set it checks in schema if given item should use `The` in name, defaults to `false`\r\n- Returns the item name\r\n\r\n#### Note for stringify\r\nIf you are using sku format to store your items and want to use `The` in your names, you have to turn `determineUniqueHat` to `true`.\r\n\r\n## Compability usage\r\n```ts\r\n// Have a name, want a sku\r\nconst attributes = parseString(name, true, true); // To get defindexes and enums\r\nconst sku = toSKU(attributes);\r\n\r\n// Have a sku, want a name\r\nconst attributes = parseSKU(sku);\r\nconst name = stringify(attributes);\r\n\r\n// Have a sku, want a bp listing\r\nconst attributes = parseSKU(sku);\r\nconst listing = createBPListing(attributes);\r\n```\r\nEvery method should be interchangable in similar ways.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanocmx%2Fnode-tf2-item-format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanocmx%2Fnode-tf2-item-format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanocmx%2Fnode-tf2-item-format/lists"}