New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ranking

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ranking

ranking

  • 0.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ranking

Build Status Coverage Status npm version

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

Keywords

FAQs

Package last updated on 13 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc