lotto-draw
Version:
A simple tool used to pick random elements from a mutable collection of weighted participants
21 lines (20 loc) • 908 B
TypeScript
import { Lotto } from "./Lotto";
/**
* A type defining a participant and ticket count.
*/
export declare type ParticipantEntry<TParticipant> = [TParticipant, number];
/**
* The options relating to the creation of a Lotto instance.
*/
export declare type LottoCreationOptions<TParticipant> = {
/** A function to return a pseudorandom number between 0 and 1. */
random?: () => number;
/** The initial lotto participants. */
participants?: ParticipantEntry<TParticipant>[];
};
/**
* A function that creates and returns a Lotto instance.
* @param participantsOrOptions An array of initial participants or options relating to the creation of a Lotto instance.
* @returns A new Lotto instance.
*/
export declare function createLotto<TParticipant = any>(participantsOrOptions?: ParticipantEntry<TParticipant>[] | LottoCreationOptions<TParticipant>): Lotto<TParticipant>;