0.4.2 • Published 12 months ago

@jprochazk/roll-dice v0.4.2

Weekly downloads
-
License
MIT OR Apache-2.0
Repository
github
Last release
12 months ago

roll-dice

Evaluate standard dice roll notation.

$ npm i roll-dice@npm:jprochazk/roll-dice
import { roll } from "roll-dice";

roll("5d6") // roll a 6-sided die 5 times.
roll("5d6 + 10") // roll a 6-sided die 5 times, and add 10 to the result.

Syntax

descriptionexample
a + badd a and b1 + 1
a - bsubtract b from a1 - 1
a * bmultiply a by b1 * 1
a / bdivide a by b1 / 1
- bnegates b-1
d arolls an a-sided died5
a d brolls a b-sided die, a times2d10
( a )grouping expression, used to specify precedence(1+1)

Every a or b in the above table may contain another expression, and expressions may be arbitrarily nested. For example (10+5)*2+(5d10) is a valid expression.

Structure

The library is written in Rust, and uses wasm-pack for packing it as a WASM module and publishing it on NPM. Various commands (available in the justfile) are run using just.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

0.4.1

12 months ago

0.4.0

12 months ago

0.4.2

12 months ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago