Rolls any-sided die with customizable input generators.
$ npm install --save ivory-dice
const ivoryDice = require('ivory-dice');
var rollResult = ivoryDice((min, max) => Math.floor(Math.random()*(max - min + 1) + min), 6);
Rolls a die using the given generator, returning the resulting roll.
The roll will be well-behaved with respect to the generator, i.e. if the generator provides a value X
, the unmodified roll of the die will be X
.
- Function
generator
: A random generator accepting two arguments, an integermin
and an integermax
, and returning an integer that is between the two inclusively. The function may contractually expectmin <= max
. - Number
sides
: The number of sides of the die to be rolled. Must be >= 1. Default: 6
- Number - The die roll result
MIT © Nathan Armstrong