0.1.4 • Published 1 year ago

smart-score-queue v0.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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;
  }
0.1.2

1 year ago

0.1.1

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago