pactole-js
v0.2.0
Published
A TypeScript library for managing lottery results.
Readme
Pactole.js
A TypeScript library for managing lottery results.
A Python version is also available: pactole.
Installation
Add pactole-js to your project:
npm install pactole-jsDocumentation
See the complete documentation index: Documentation. It's also published on ReadTheDocs: pactole-js.readthedocs.io.
Requirements
Requires Node.js (version 20 or newer).
Usage
import * as pactole from 'pactole-js';EuroMillions lottery
import { EuroMillions } from 'pactole-js';
const lottery = new EuroMillions();
// Build a known ticket
const ticket = lottery.getCombination({ numbers: [3, 15, 22, 28, 44], stars: [2, 9] });
console.log(lottery.drawDays.days);
console.log(lottery.getLastDrawDate(new Date(2026, 1, 19)));
console.log(lottery.getNextDrawDate(new Date(2026, 1, 19)));
console.log(lottery.getNextDrawDate()); // From today
console.log(ticket.numbers.values);
console.log(ticket.stars.values);
console.log(ticket.rank);
// Generate 3 random combinations
const combinations = lottery.generate({ n: 3 });
console.log(combinations);EuroDreams lottery
import { EuroDreams } from 'pactole-js';
const lottery = new EuroDreams();
// Build a known ticket
const ticket = lottery.getCombination({ numbers: [2, 3, 5, 7, 9, 38], dream: [3] });
console.log(lottery.drawDays.days);
console.log(lottery.getLastDrawDate(new Date(2026, 1, 19)));
console.log(lottery.getNextDrawDate(new Date(2026, 1, 19)));
console.log(lottery.getNextDrawDate()); // From today
console.log(ticket.numbers.values);
console.log(ticket.dream.values);
console.log(ticket.rank);
// Generate 3 random combinations
const combinations = lottery.generate({ n: 3 });
console.log(combinations);Scripts
dev: Start development server with Vitedocs:api: Generate the API documentationbuild: Build the librarybuild:lib: Build the library onlyformat: Format the project with Prettierformat:check: Check formatting with Prettiertest: Run tests with Vitesttest:coverage: Run tests with coveragetest:watch: Run tests in watch mode with coverage outputlint: Lint code with ESLint and Prettier checks
Changes
For the changelog, see CHANGELOG.md.
License
MIT License - See LICENSE file for details.
