smart-score-queue
v0.1.4
Published
## How to import ```javascript import { LinearBased, ScoreBased } from 'smart-score-queue' ```
Downloads
12
Readme
Smart Queue Lib - Typescript
How to import
import { LinearBased, ScoreBased } from 'smart-score-queue'
Example test data for reference
export const TestObj: ScoreData[] = [
{
name: 'Flaschard 1',
description: 'Hola como no',
},
{
name: 'Flaschard 2',
description: 'Hola como no',
},
{
name: 'Flaschard 3',
description: 'Hola como no',
},
...
LinearBased
new LinearBased(TestObj, 10, 0)
Create a new LinearBased instance witht the array
of data, amount
of records and offset
const linearBased = new LinearBased(TestObj, 10, 0);
.getNext() => ScoreData
Gets the next object in the queue initiated by new LinearBased(...)
let nextObj = linearBased.getNext();
.score(id, 4)
Sets the score to a given record id (id: string, score: number)
let nextObj = linearBased.getNext();
linearBased.score(nextObj.id, 4);
.getCurrentSession() => ScoreData[]
Gets the current session of the queue with all the elements limited by the amount provided in the constructor
linearBased.getCurrentSession();
.save() => ScoreData[]
will merge the array objects with the modified values in the current section
linearBased.save()
ScoreBased
new ScoreBased(TestObj, 10)
Create a new ScoreBased instance witht the array
of data, amount
of records
const scoreBased = new ScoreBased(TestObj, 10, 0);
.getNext() => ScoreData
Gets the next object in the queue initiated by new ScoreBased(...)
let nextObj = scoreBased.getNext();
.score(id, 4)
Sets the score to a given record id (id: string, score: number)
let nextObj = scoreBased.getNext();
scoreBased.score(nextObj.id, 4);
.getCurrentSession() => ScoreData[]
Gets the current session of the queue with all the elements limited by the amount provided in the constructor
scoreBased.getCurrentSession();
.save() => ScoreData[]
will merge the array objects with the modified values in the current section
scoreBased.save()
ScoreData - Type
interface ScoreData {
score?: number;
order?: number;
id?: string;
lastFetched?: Date;
lastScored?: Date;
duplicatedObj?: boolean
duplicatedObjId?: string
[x: string | number | symbol]: unknown;
}