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-utils

v0.4.0

Published

ELO utilities

Downloads

8

Readme

Build Status Coverage Status

elo-utils

Used to provide some basic utilities to support the calculation of ELO Ratings.

Usage

const EloUtils = require('elo-utils');

Functions

elo(rating1, rating2, result=R1, k=32)

Calculates the new ELO rating for two competitors given the ELO rating prior to the match and the actual outcome. The user can optionally provide the result of the match and a new K factor with defaults being set for R1 being the victor and a K rating of 32.

For example, if participant 1 (2200) and participant 2 (2600) were to have match and the underdog (Participant 1) were to win, the elo function would be able to calulate the new ratings.

//Basic Usage
console.log(EloUtils.elo(2200, 2600)); //Rating 1, Rating 2 assuming R1 is the winner
// Output: { R1: 2229.090909090909, R2: 2570.909090909091 }

A result can be passed into the function to specify which participant won the match using the RESULT enum.

console.log(EloUtils.RESULT.R1)  //Participant 1 wins (Default)
//Output: Symbol(R1)

console.log(EloUtils.RESULT.R2) //Participant 2 wins
//Output: Symbol(R2)

console.log(EloUtils.RESULT.TIE) //Tie
//Output: Symbol(TIE)


console.log(EloUtils.elo(2200, 2600, EloUtils.RESULT.R2)); //Rating 1, Rating 2 assuming R2 is the winner
// Output: { R1: 2197.090909090909, R2: 2602.909090909091 }

console.log(EloUtils.elo(2200, 2600, EloUtils.RESULT.TIE)); //Rating 1, Rating 2 assuming a tie
// Output: { R1: 2213.090909090909, R2: 2586.909090909091 }

The function assumes a 'K' factor of 32 which is standard for most cases, however in the event where there is a need for greater variablity a custom rating can be used.

console.log(EloUtils.elo(2200, 2600, EloUtils.RESULT.R1, 64)); //Rating 1, Rating 2 assuming R2 is the winner
// Output: { R1: 2258.181818181818, R2: 2541.818181818182 }

probability(rating1, rating2)

Provides the win probability in a match between to participants given thier respective ratings.

//Win Probabilities
 //calculates the win probability given two partiicpants with calculated ELO ratings
console.log(EloUtils.probabilty(2200, 2600));
// Output: { r1: 0.09266675659153722, r2: 0.9073332434084628 }
// r1 would have a 9% chance of winning
// r2 would have a 91% chance of winning