1.2.5 • Published 9 months ago

magic-lottery v1.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Magic Lottery

ci ts download-badge version commit license

Magic Lottery is an intuitive library aimed at simplifying your lottery experiences to make them simpler, more enjoyable, and fair.

Magic Lottery uses the Fisher-Yates Shuffle Algorithm as the default shuffling method.

Installation

To install Magic Lottery, use npm/yarn/pnpm. Execute the following command in your terminal:

npm install magic-lottery
# or
yarn add magic-lottery
# or
pnpm add magic-lottery

Usage Example

Here's a simple usage case for the Magic Lottery.

import MagicLottery from "magic-lottery";

// Create a new MagicLottery instance
const lottery = new MagicLottery(["Alice", "Bob", "Charlie"]);

// Add more entries to the lottery
lottery.add(["David", "Eve"]);

// Draw all shuffled entries
console.log(lottery.draw());

// Draw the first winner from the shuffled entries
console.log(lottery.drawWinner());

// Draw a specified number of winners from the shuffled entries
console.log(lottery.drawWinners(2));

// Check if an entry is in the lottery
console.log(lottery.hasEntry("Alice"));

// Get the size of the lottery
console.log(lottery.size());

// Check if the lottery is empty
console.log(lottery.isEmpty());

// Draw next winner async
lottery.nextWinner().then((winner) => console.log(winner));

// Reset the lottery
lottery.reset();

For more examples, please refer to the official documentation.

Contributing

Refer to our Contributing Guide.

License

MIT.

1.2.5

9 months ago

1.2.4

9 months ago

1.2.3

9 months ago

1.2.2

9 months ago

1.2.0

9 months ago

1.1.0

9 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago