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

toefungi-elo-calculator

v1.3.4

Published

A package to do all necessary computations to determine ELO rankings

Downloads

49

Readme

ELO Calculator

Build Status Quality Gate Status Bugs Code Smells Coverage

This package makes using the ELO ranking system easy. To get started you just need to decide what you want your starting ELO. After that, you can start calculating win probabilities based on two player's ELO scores and also determining the ELO of a player after a match.

It's very simple.

Installation

To install this package.

npm i toefungi-elo-calculator

Usage

You're first going to want to import the relevant files and instantiate a new instance of the EloCalculator.

import { EloCalculator } from 'toefungi-elo-calculator'

const eloCalculator: EloCalculator = new EloCalculator()

Here is a basic example of calculating a new ELO value.

import { ScoringBonus } from 'toefungi-elo-calculator'

// Declared player variables
const playerElo = 2149
const opponentElo = 2084

// Calculate ELO based on the outcome of the game without taking into account 
// Player performance or the score difference in the game
eloCalculator.calculateElo(playerElo, opponentElo, ScoringBonus.WIN)
  .then((elo: number) => {
    console.log(elo) // The new ELO
  })
  
// Take into account the numerical difference in the score to determine the ELO
// This will make the ELO change more dynamic as it computes slightly differently
// And will more accurately split the higher players from the lower players
// In terms of their ELO
const scoreDiff = 4

eloCalculator.calculateElo(playerElo, opponentElo, ScoringBonus.WIN, scoreDiff)
  .then((elo: number) => {
    console.log(elo) // The new ELO
  })

Here is a basic example of calculating win probabilities between two players.

import { Probabilities } from 'toefungi-elo-calculator'

// Declared player variables
const playerElo = 2149
const opponentElo = 2084

// Calculate ELO based on the outcome of the game
eloCalculator.caluclateWinProbability(playerElo, opponentElo)
  .then((probability: Probabilities) => {
    console.log(probability.player) // Probability player will win
    console.log(probability.opponent) // Probability opponent will win
  })

Testing

This package includes unit tests which cover 100% of the code and all tests are working. The testing framework being used is mocha and using chai-as-promisedto test the promise returns from the package.

The test suite can be run using the conventional npm test

The package uses nyc for code coverage.