0.7.1 • Published 4 years ago

listboard v0.7.1

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
4 years ago

Create and quickly organize your leaderboard in a few steps! Contribute to this project, click here to view more.

Topics

Getting Started

You can easy contribute to the project by installing the package, this helps a lot to the package development and for adding future releases. Want to contribute? View the instructions below:

$ npm install listboard --save
const listboard = require('listboard');

You can render your board by using the render function. View more of this function by clicking here.

To create a leaderboard class and start using, you can create this using the code below:

const leaderboard = new listboard.Listboard({
  max: *the max items you want*,
  columns: {
    items: *the items column name*,
    values: *the score column name*
  }
});

Documentation

Values

addItem

Add a item to leaderboard.

  • name: the name to set the key in leaderboard
  • value: the value to set the key in leaderboard
<Listboard>.addItem('rtkr', '128');

removeItem

Remove a item of the leaderboard.

  • name: the name of the key set in leaderboard
<Listboard>.removeItem('rtkr');

removeItemByRank

Remove a item from the leaderboard by the rank id.

  • rank: the item rank to be removed
<Listboard>.removeItemByRank(1);

getRanking

Alias of top, but return all leaderboard ranking.

<Listboard>.getRanking();

getItem

Fetch a value of the leaderboard.

  • name: the name of the key set in leaderboard
<Listboard>.getItem('rtkr');

getItemByRank

Get a item from the leaderboard by the rank id.

  • rank: the item rank to be get
<Listboard>.getItemByRank(2);

spliceItems

Remove values from the leaderboard starting in the specified index.

  • index: start index to splice the leaderboard
  • count: the count to splice the leaderboard
    • default: 1
<Listboard>.spliceItems(5, 1);

get

Get all leaderboard items or a specific item by specified value.

  • value: search a item by item value
    • default: all
<Listboard>.get()
  .then(items => {
    console.log(items);
  }).catch(error => {
    console.error(error);
  });

Leaderboard

render

Render the leaderboard in a JSON array.

<Listboard>.render();

jolb

You can also just organize an array as a leaderboard quickly.

  • array: the array to organize
listboard.jolb([ { name: 'A', value: 2 }, { name: 'B', value: 1 } ]);

top

Return the ranking of the leaderboard.

  • value: how many items will be shown in the rank
    • default: items.length
<Listboard>.top(3);
0.7.1

4 years ago

0.7.0

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.1

4 years ago