Skip to content

Commit

Permalink
return rank as a number and fix spacing in docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Oct 2, 2023
1 parent a36af82 commit b1fc707
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export abstract class AbstractLeaderboardClient implements ILeaderboardClient {

/**
* Fetch the elements in the given leaderboard by index (rank).
* Note: can fetch a maximum of 8192 elements at a time and rank
* Note: can fetch a maximum of 8192 elements at a time and rank
* is 0-based (index begins at 0).
*
* @param {string} cacheName - The cache containing the leaderboard.
Expand Down Expand Up @@ -149,7 +149,7 @@ export abstract class AbstractLeaderboardClient implements ILeaderboardClient {

/**
* Fetch length (number of items) of leaderboard
*
*
* @param {string} cacheName - The cache containing the leaderboard.
* @param {string} leaderboardName - The leaderboard to fetch the length of.
* @returns {Promise<LeaderboardLength.Response>}
Expand Down Expand Up @@ -191,7 +191,7 @@ export abstract class AbstractLeaderboardClient implements ILeaderboardClient {

/**
* Delete the given leaderboard
*
*
* @param {string} cacheName - The cache containing the leaderboard.
* @param {string} leaderboardName - The leaderboard to delete.
* @returns {Promise<LeaderboardDelete.Response>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ class _Found extends Response {

/**
* Returns the elements as an array of objects, each containing an `id`, `score`, and `rank` field.
* The id is a bigint, the score is a number, and the rank is a bigint.
* @returns {{id: bigint, score: number, rank: bigint}[]}
* @returns {{id: bigint, score: number, rank: number}[]}
*/
public valueArray(): {id: bigint; score: number; rank: bigint}[] {
public valueArray(): {id: bigint; score: number; rank: number}[] {
return this._elements.map(item => {
return {
id: item.id,
score: item.score,
rank: item.rank,
rank: Number(item.rank),
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class _Found extends Response {

/**
* Returns the rank of the requested element in the leaderboard
* @returns {bigint}
* @returns {number}
*/
public rank(): bigint {
return this._rank;
public rank(): number {
return Number(this._rank);
}

/**
Expand All @@ -64,7 +64,7 @@ class _Found extends Response {
}

public override toString(): string {
return `${super.toString()}: get element rank ${this._rank}`;
return `${super.toString()}: get element rank ${Number(this._rank)}`;
}
}

Expand Down

0 comments on commit b1fc707

Please sign in to comment.