UNPKG

spacerepetition

Version:
59 lines (58 loc) 2.25 kB
import { Flashcard, LearningAlgorithm } from '../types.js'; export default class Deck { private cards; private lastCard; /** * Creates an instance of Deck. * @param {any} [cards] - Initial set of cards. * @param {LearningAlgorithm} [learningAlgorithm="default"] - The learning algorithm to use. * @param {object} [config] - Configuration object for the cards. */ constructor(cards?: any, learningAlgorithm?: LearningAlgorithm, config?: object); /** * Creates flashcards from the given data. * @param {any} cards - Data to create flashcards from. * @param {LearningAlgorithm} learningAlgorithm - The learning algorithm to use. * @param {object} config - Configuration object for the cards. * @returns {Flashcard[]} - Array of created flashcards. */ createFlashcards(cards: any, learningAlgorithm: LearningAlgorithm, config: object): Flashcard[]; /** * Creates a single flashcard from the given data. * @param {any} card - Data to create a flashcard from. * @param {object} config - Configuration object for the card. * @returns {Flashcard} - Created flashcard. */ createFlashcard(card: any, config: object): Flashcard; /** * Adds a card to the deck. * @param {Flashcard} card - The card to add. */ addCard(card: Flashcard): void; /** * Removes a card from the deck. * @param {Flashcard} card - The card to remove. * @returns {boolean} - True if the card was removed, false otherwise. */ removeCard(card: Flashcard): boolean; /** * Gets all cards in the deck. * @returns {Flashcard[]} - Array of all cards in the deck. */ getAllCards(): Flashcard[]; /** * Gets the next card to review. * @returns {Flashcard | undefined} - The next card to review, or undefined if no card is due. */ getNextCard(): Flashcard | undefined; /** * Alias for getNextCard. * @returns {Flashcard | undefined} - The next card to review, or undefined if no card is due. */ nextCard(): Flashcard | undefined; /** * Adds another deck's cards to this deck. * @param {Deck} deck - The deck to add. */ addDeck(deck: Deck): void; }