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 🙏

© 2025 – Pkg Stats / Ryan Hefner

elo-calculator

v1.0.1

Published

Elo rating calculator

Readme

Elo

The Elo rating system is a method for calculating the relative skill levels of players in competitor-versus-competitor games. A player's Elo rating is represented by a number which increases or decreases depending on the outcome of games between rated players. After every game, the winning player takes points from the losing one. The difference between the ratings of the winner and loser determines the total number of points gained or lost after a game. See https://en.wikipedia.org/wiki/Elo_rating_system for more information.

Installation

npm install elo-calculator

Usage

In node.js, require the module:

const Elo = require('elo-calculator');

First we initialize the Elo calculator, optionally passing options.

const elo = new Elo({
  // The rating of which each initialized player will start with
  rating: 1200,
  // The coefficient, called the K-factor, is the maximum possible adjustment per game.
  // Which value is used depends on one or more the following points:
  // 1. The number of games the player has played
  // 2. The current rating of the player
  // 3. The highest rating the player has ever had.
  // Weak and new players generally have a higher coefficient than stronger, more experienced players.
  // The conditions used to apply a k-factor are based the ones used by the World Chess Federation (http://www.fide.com/fide/handbook.html?id=172&view=article)
  k: [40, 20, 10]
});

Then we create players, optionally passing options to the player.

// const player = elo.createPlayer(currentRating, numberOfGamesPlayed, highestRating);
const player1 = elo.createPlayer();
const player2 = elo.createPlayer(1900, 50, 1950);
const player3 = elo.createPlayer(1550);

The ratings of the players are updated by feeding the calculator with match results:

elo.updateRatings([
  [player1, player2, 1], // Player 1 wins
  [player2, player1, 0], // Player 2 loses
  [player2, player3, .5] // Player 2 and player 3 draws the game
]);

Players are stored in the players property of the instance of Elo. Iterate through the players and display the ratings:

elo.players.forEach(function(player, i) {
  console.log(`Player ${i + 1} has played ${player.numberOfGamesPlayed} and has a rating of ${Math.round(player.rating)}`);
});