ranking
Based on: Fast and reliable ranking in datastore
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; const ranking = maxScore: 1000000 branchFactor: 1000;
add player points
ranking;// { position: 1, score: 28, playerId: 20 }
find
// by scoreranking;ranking;ranking; // by positionranking;ranking;ranking; // by player idranking;
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.