0.0.9 • Published 11 years ago

leaderboard v0.0.9

Weekly downloads
46
License
-
Repository
-
Last release
11 years ago

Leaderboard

Leaderboards backed by Redis in Node.js. Inspired by Agoragames' Leaderboard.

Build Status

API

#Constructor

new Leaderboard('name', [options], [redisOptions])

Creates a new leaderboard or attaches to an existing leaderboard.

###Options

  • pageSize - default: 0

    Page size to be used when paging through the leaderboard

##Methods

  • add(member, score, λ)

    Ranks a member in the leaderboard.

    board.add('borbit', 100500, function(err, rank) {
      // rank - current position in the leadeboard
    });
  • rank(member, λ)

    Retrieves the rank for a member in the leaderboard.

    board.rank('borbit', function(err, rank) {
      // rank - current position, -1 if a member doesn't
      // fall within the leaderboard
    });
  • score(member, λ)

    Retrieves the score for a member in the leaderboard.

    board.score('borbit', function(err, rank) {
      // score - current score, -1 if a member doesn't
      // fall within the leaderboard
    });
  • list([page], λ)

    Retrieves a page of leaders from the leaderboard.

    board.list(function(err, list) {
      // list - list of leaders are ordered from
      // the highest to the lowest score
      // [
      //   {member: 'member1', score: 30},
      //   {member: 'member2', score: 20},
      //   {member: 'member3', score: 10}
      // ]
    });

##Tests

Leaderboard is covered by Mocha. To run tests:

 $ npm test

License

MIT. Copyright (c) 2012 Serge Borbit <serge.borbit@gmail.com>

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago