listboard v0.7.1
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
- default:
<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
- default:
<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
- default:
<Listboard>.top(3);