redis-rank
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -5,7 +5,7 @@ /// <reference types="node" /> | ||
/** Entry identifier */ | ||
export declare type ID = string; | ||
export type ID = string; | ||
/** Score value */ | ||
export declare type Score = number; | ||
export type Score = number; | ||
/** Position in the leaderboard, determined by the sort policy. 1-based */ | ||
export declare type Rank = number; | ||
export type Rank = number; | ||
/** | ||
@@ -17,3 +17,3 @@ * Sort policy | ||
*/ | ||
export declare type SortPolicy = 'high-to-low' | 'low-to-high'; | ||
export type SortPolicy = 'high-to-low' | 'low-to-high'; | ||
/** | ||
@@ -27,4 +27,4 @@ * Update policy | ||
*/ | ||
export declare type UpdatePolicy = 'replace' | 'aggregate' | 'best'; | ||
export declare type LeaderboardOptions = { | ||
export type UpdatePolicy = 'replace' | 'aggregate' | 'best'; | ||
export type LeaderboardOptions = { | ||
/** | ||
@@ -51,3 +51,3 @@ * Sort policy for this leaderboard | ||
*/ | ||
export declare type Entry = { | ||
export type Entry = { | ||
id: ID; | ||
@@ -57,3 +57,3 @@ score: Score; | ||
}; | ||
export declare type EntryUpdateQuery = { | ||
export type EntryUpdateQuery = { | ||
id: ID; | ||
@@ -60,0 +60,0 @@ value: number | Score; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -20,0 +20,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
import { Redis } from 'ioredis'; | ||
import { Leaderboard, LeaderboardOptions, ID, Rank, Score, UpdatePolicy } from './Leaderboard'; | ||
import { PeriodicLeaderboard, PeriodicLeaderboardCycle, NowFunction } from './PeriodicLeaderboard'; | ||
export declare type DimensionName = string; | ||
export declare type FeatureName = string; | ||
export declare type DimensionDefinition = { | ||
export type DimensionName = string; | ||
export type FeatureName = string; | ||
export type DimensionDefinition = { | ||
name: DimensionName; | ||
cycle?: PeriodicLeaderboardCycle; | ||
}; | ||
export declare type FeatureDefinition = { | ||
export type FeatureDefinition = { | ||
name: FeatureName; | ||
options: LeaderboardOptions; | ||
}; | ||
export declare type LeaderboardMatrixOptions = { | ||
export type LeaderboardMatrixOptions = { | ||
/** leaderboard dimensions. Provide at least one */ | ||
@@ -22,3 +22,3 @@ dimensions: DimensionDefinition[]; | ||
}; | ||
export declare type MatrixEntry = { | ||
export type MatrixEntry = { | ||
/** identifier */ | ||
@@ -39,3 +39,3 @@ id: ID; | ||
}; | ||
export declare type MatrixShowcase = { | ||
export type MatrixShowcase = { | ||
dimension: DimensionName; | ||
@@ -45,3 +45,3 @@ feature: FeatureName; | ||
}; | ||
export declare type MatrixCount = { | ||
export type MatrixCount = { | ||
[dimension: string]: { | ||
@@ -51,3 +51,3 @@ [feature: string]: number; | ||
}; | ||
export declare type MatrixEntryUpdateQuery = { | ||
export type MatrixEntryUpdateQuery = { | ||
id: ID; | ||
@@ -59,3 +59,3 @@ values: { | ||
/** filter query results */ | ||
export declare type MatrixLeaderboardQueryFilter = { | ||
export type MatrixLeaderboardQueryFilter = { | ||
/** | ||
@@ -62,0 +62,0 @@ * dimensions to include in the result. If undefined or empty, |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -20,0 +20,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
import { Redis } from 'ioredis'; | ||
import { Leaderboard, LeaderboardOptions } from './Leaderboard'; | ||
/** uniquely identifies a cycle */ | ||
export declare type CycleKey = string; | ||
export declare type DefaultCycles = 'minute' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly'; | ||
export declare type NowFunction = () => Date; | ||
export declare type CycleFunction = (time: Date) => CycleKey; | ||
export type CycleKey = string; | ||
export type DefaultCycles = 'minute' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly'; | ||
export type NowFunction = () => Date; | ||
export type CycleFunction = (time: Date) => CycleKey; | ||
/** | ||
@@ -17,4 +17,4 @@ * The cycle of a periodic leaderboard. | ||
*/ | ||
export declare type PeriodicLeaderboardCycle = CycleFunction | DefaultCycles; | ||
export declare type PeriodicLeaderboardOptions = { | ||
export type PeriodicLeaderboardCycle = CycleFunction | DefaultCycles; | ||
export type PeriodicLeaderboardOptions = { | ||
/** underlying leaderboard options */ | ||
@@ -21,0 +21,0 @@ leaderboardOptions: LeaderboardOptions; |
{ | ||
"name": "redis-rank", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Manage real-time leaderboards using Redis", | ||
@@ -33,10 +33,10 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/jest": "^27.4.1", | ||
"@types/node": "^17.0.23", | ||
"@types/jest": "^29.2.5", | ||
"@types/node": "^18.11.18", | ||
"codecov": "^3.8.3", | ||
"ioredis": "^5.0.4", | ||
"jest": "^27.5.1", | ||
"nodemon": "^2.0.15", | ||
"ts-jest": "^27.1.4", | ||
"typescript": "^4.6.3" | ||
"ioredis": "^5.2.4", | ||
"jest": "^29.3.1", | ||
"nodemon": "^2.0.20", | ||
"ts-jest": "^29.0.4", | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -43,0 +43,0 @@ "peerDependencies": { |
@@ -104,8 +104,14 @@ | ||
A Redis server in localhost without password is expected. | ||
A Redis server in localhost without password is expected. You can create one easily with Docker like so: | ||
```shell | ||
docker run -p 6379:6379 -t -i --rm redis:latest | ||
``` | ||
⚠️ Note: **The database #15 will be flushed** ⚠️ | ||
Run tests: | ||
```shell | ||
$ npm test | ||
npm test | ||
``` | ||
@@ -112,0 +118,0 @@ |
Sorry, the diff of this file is not supported yet
123
96033