Dice Rolls Library

TypeScript, Bun, Testing

Table-top eDice Link to heading

Overview Link to heading

A lightweight, dependency-free tool designed to facilitate dice rolling within your projects for tabletop gaming and interactive applications. Built with TypeScript and thoroughly tested with 100% code coverage.

Key Features Link to heading

  • Simple dice rolling syntax - Intuitive API for rolling dice
  • Roll any quantity of dice - Support for multiple dice in a single roll
  • Multiple dice types - Support for d4, d6, d8, d10, d12, and d20 dice
  • Optional result modifiers - Add or subtract values from rolls
  • TypeScript native - Built with TypeScript and includes type definitions
  • Lightweight and dependency-free - Easy to integrate without bloating your project
  • Comprehensive testing - 89 test cases with 100% code coverage

Technical Implementation Link to heading

Installation Link to heading

bun add dice-rolls@latest

Basic Usage Link to heading

import Roll from "dice-rolls"

// Roll 3 six-sided dice
const roll = new Roll("3d6")
console.log(roll.result) // Total result
console.log(roll.results) // Individual dice rolls

Advanced Capabilities Link to heading

  • Static helper methods for single dice rolls
  • Result filtering and counting for specific outcomes
  • Minimum/maximum value calculations for roll ranges
  • Modifier support for adding bonuses or penalties

Technical Specifications Link to heading

  • Language: TypeScript
  • Package Manager: Bun
  • Testing: 89 test cases with 100% code coverage
  • License: Apache License 2.0
  • Architecture: Object-oriented design with static utility methods

Use Cases Link to heading

  • Tabletop RPG applications
  • Board game implementations
  • Educational math tools
  • Gaming simulations
  • Random number generation with dice semantics

Quality Assurance Link to heading

The library maintains exceptional code quality with comprehensive test coverage, ensuring reliability for production use in gaming applications and educational tools.