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.
npm install elo-rating
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
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
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...
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 }
The MIT License (MIT)
There are several other modules for Node.js, which provide similar functionality. Check them out as well: