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 🙏

© 2026 – Pkg Stats / Ryan Hefner

towerfall-stats

v0.3.1

Published

Retrieve TowerFall session stats and save them to disk and/or a database

Readme

TowerFall Stats

A library for retrieving TowerFall session stats and saving them to disk and/or a database.

If you want to post stats to Slack, there's a package for that.

Configuration

Towerfall-stats needs to know the location of your tf_saveData file. It assumes a default location, but if you need to change it you can run tf-stats-config for a global install or npm run configure for a local install. This will save the config to a file in your home directory called towerfall-stats-config.json.

If you wish to save match stats to a database, you must run tf-stats-db-config for a global install or npm run db-configure for a local install. Supported databases are MySQL, MariaDB, PostgreSQL, and SQLite.

Use

Library

Towerfall-stats works by watching for changes to the tf_saveData file. The watchForUpdates method will start watching for changes. It accepts a callback which will be called after every completed match. The callback accepts one argument, which contains the stats for the just-completed match.

var fileHandler = require('towerfall-stats').fileHandler;

fileHandler.watchForUpdates(function (matchStats) {
    // Do something with matchStats
});

The watchForUpdatesAndSaveToFile method does just that, saving accumulated stats to the liveStats file in your tf_saveData directory. In addition to saving the stats of each individual match, it will also keep a tally of total kills, deaths, and rounds, as well as kill/death and win/match ratios. To get the contents of this file, as well as a tally of winning streaks, use the getCompiledLiveStats method.

As a convenience, there is also a method that will return rankings for each category. Just pass in the stats returned by getCompiledLiveStats,

var statParser = require('towerfall-stats').parser;
var fileHandler = require('towerfall-stats').fileHandler;

var stats = fileHandler.getCompiledLiveStats();
var rankings = statParser.getRankings(stats);

This will return an object that looks like this:

{
    wins   : [['blue'], ['cyan', 'white'], ['red']],
    kills  : ...
    deaths : ...
    kdr    : ...
    ...
}

In the example above, blue took first place, cyan and white were tied for second, and red came in last.

Watch script

If creating a stats file or writing stats to a database is all you need to do, you can use the watch command (tf-stats-watch globally or npm run watch locally). The command accepts three options (note if running via npm run you must have -- between the command and the options).

  • -f or --save-to-file - Save match data and accumulated summary data to a file
  • -d or --save-to-db - Save match data to the database
  • -a or --append - If using the -f option, append to the existing file instead of overwriting it