npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tf2-backpack

v1.2.0

Published

Parses the backpack from node-tf2

Downloads

1,067

Readme

node-tf2-backpack

Typed module to parse inventory items from node-tf2 Using this you no longer have to retrieve your own (bots) backpack from the steam API, which has been having issues with increasing ratelimits.

Installation

npm install tf2-backpack
import { BackpackParser } from 'tf2-backpack';
const parser = new BackpackParser(itemsGame);
// or
const tf2backpack = require('tf2-backpack');
const parser = new tf2backpack.BackpackParser(itemsGame);

Docs

Constructor(itemsGame)

  • itemsGame - itemSchema property from node-tf2. See the docs.

Constructs a new BackpackParser.
It is recommended that you save the itemSchema. It is not emitted on every connection, as it is cached. Currently working on figuring out a way to maybe force a refresh, but no promises.

Alternatively, you can also use any vdf parser module and use items_game from items_game.txt (you can find this here or the schema as items_game_url) as input.
Or items-game.json from node-tf2-static-schema
They're the same

parseBackpack

parseBackpack(backpack: NodeTF2Backpack, mapToString = false): Item<string | number>[] {}
  • backpack - backpack property from node-tf2. See the docs.
  • mapToString - set to true to return spells, parts, sheen, killstreaker, killstreakTier and wear as names instead of IDs
  • Returns Item<string | number>[]

parseItem

parseItem(item: BackpackEntry, mapToString = false): Item<string | number> {}
  • item - item from node-tf2's itemAcquired/itemChanged/itemRemoved events. See the docs.
  • mapToString - set to true to return spells, parts, sheen, killstreaker, killstreakTier and wear as names instead of IDs
  • Returns Item<string | number>

Exactly the same as parseBackpack but for a single item for convenience

Other

Since there are no standardized skus for some properties, this module also provides the following exports:

  • spellNames - spell defindex to name
  • sheens
  • killstreakers
  • parts - strange parts

mapHexToPaintName

mapHexToPaintName(primaryColor?: string, secondaryColor?: string): string {}
  • primaryColor - Primary color of the paint can, the paint property from parseBackpack output

  • secondaryColor - Secondary color of the paint can, the paint_other property from parseBackpack output

  • Returns string - Name of the paint