niv_dice_roller
v0.2.8
Published
This library provides a simple and efficient way to simulate dice rolls directly from your JavaScript applications using WebAssembly. With it, you can roll any number of dice, each with a customizable number of sides. Built with Rust, this library can pro
Downloads
14
Readme
Dice Roller RUST
This library provides a simple and efficient way to simulate dice rolls directly from your JavaScript applications using WebAssembly. With it, you can roll any number of dice, each with a customizable number of sides. Built with Rust, this library can process up to 10 million dice rolls in under 6 seconds, showcasing the power of WebAssembly in high-performance applications.
Features
- Roll any number of dice with any number of sides.
- Unmatched Performance: Capable of rolling up to 10 million dices in less than 6 seconds.
- Fast and efficient computation with Rust and WebAssembly.
- Easy integration into JavaScript projects.
Getting Started
To use this library, you'll first need to include it in your project. Assuming you have a package generated and published, you can include it via npm or yarn:
npm install niv_dice_roller
# or
yarn add niv_dice_roller
Usage
Here's a quick example to get you started:
import { roll_dice } from 'your-dice-roller-package';
const diceConfig = [
{times: 4, side: 20},
{times: 2, side: 6},
{times: 3, side: 10}
];
// This will roll 4d20, 2d6, and 3d10 dices, returning an object with the roll results.
const output = roll_dice(diceConfig);
console.log(output);
This will roll 4d20, 2d6, and 3d10 dice, returning an object with the roll results.
Example of Output
The roll_dice function returns an object where each key corresponds to a dice configuration from the input array, and its value is an array of roll results. Here’s an example output for the provided input:
{
"1": [1, 6, 4, 19],
"2": [1, 4],
"3": [6, 5, 2]
}