0.5.1 • Published 10 years ago

ranking v0.5.1

Weekly downloads
46
License
-
Repository
github
Last release
10 years ago

ranking

Build Status Coverage Status npm version

Based on: Fast and reliable ranking in datastore

npm.io

IMPORTANT The current implementation does not have auto balance. Which makes inserting faster. But in cases when the game does not have a max score is necessary define in the ranking a huge number for maxScore to avoid any user reach the limit. Which works but is an annoying solution. I am working in the implementation with auto balance in a new branch. Probably the changes will affect only the internal code so the public api will still the same with no break changes.

Installation

Install via npm:

$ npm install ranking

Usage

// the example uses es6 but it works with es5 as well
import Ranking from 'ranking';

const ranking = new Ranking({
  maxScore: 1000000,
  branchFactor: 1000
});

add player points

ranking.addPlayerPoints({ playerId: 10, points: 28 });
// { position: 1, score: 28, playerId: 20 }

find

// by score
ranking.find({ score: { $gte: 1, $lte: 30 }, $limit: 10 });
ranking.find({ score: 20, $limit: 10 });
ranking.findOne({ score: 20 });

// by position
ranking.find({ position: { $gte: 1, $lte: 30 }, $limit: 10 });
ranking.find({ position: 20 });
ranking.findOne({ position: 20 });

// by player id
ranking.findOne({ playerId: 29 });

Contributing

It is required to use editorconfig and please write and run specs before pushing any changes:

npm test

License

Copyright (c) 2015 Max Claus Nunes. This software is licensed under the MIT License.

0.5.1

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.0

10 years ago