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

elo-rating

v1.0.1

Published

elo-rating.js is a simple utility to calculate elo ratings for Node.js

Downloads

1,381

Readme

elo-rating.js

elo-rating.js is a simple utility to calculate elo ratings for Node.js. See https://en.wikipedia.org/wiki/Elo_rating_system for more information about elo rating.

Installation

npm install elo-rating

Usage

var EloRating = require('elo-rating');

var playerWin = false;
var result = EloRating.calculate(1750, 1535, playerWin);

console.log(result.playerRating) // Output: 1735
console.log(result.opponentRating) // Output: 1550

result = EloRating.calculate(1750, 1535);

console.log(result.playerRating) // Output: 1754
console.log(result.opponentRating) // Output: 1531

Functions

EloRating.ratingDifference(playerRating, opponentRating)

Calculates the rating difference, capped at -400 and +400.

var EloRating = require('elo-rating');

console.log(EloRating.ratingDifference(1500, 1350)); // Output: 150
console.log(EloRating.ratingDifference(1200, 2000)); // Output: -400

EloRating.expected(playerRating, opponentRating)

Calculates the expected value for the player with the given rating if he plays against an opponent with the given rating. (0 = Loss, 0.5 = Draw, 1 = Win).

var EloRating = require('elo-rating');

console.log(EloRating.expected(1800, 1800)); // Output: 0.5
console.log(EloRating.expected(1500, 1350)); // Output: 0.70...
console.log(EloRating.expected(1200, 2000)); // Output: 0.09...

EloRating.calculate(playerRating, opponentRating, playerWin = true, k = 20)

Calculates the new rating for the player and his opponent.

var EloRating = require('elo-rating');

console.log(EloRating.calculate(1800, 1800));
// Output: { playerRating: 1810, opponentRating: 1790 }
console.log(EloRating.calculate(1200, 1500, false));
// Output: { playerRating: 1197, opponentRating: 1503 }
console.log(EloRating.calculate(1200, 1500, false, 40));
// Output: { playerRating: 1194, opponentRating: 1506 }

License

The MIT License (MIT)

Similar modules

There are several other modules for Node.js, which provide similar functionality. Check them out as well:

  • https://github.com/dmamills/elo-rank
  • https://github.com/moroshko/elo.js
  • https://github.com/PhobosRising/node-arpad
  • https://github.com/jbrooksuk/node-elo