@aiacta/dicelang
v2.0.0
Published
A language parsing and execution tool for dice roll.
Readme
dicelang
Installation
yarn add @aiacta/dicelangUsage
import Program from '@aiacta/dicelang';
...
const resolution = await new Program('1d20').run();
resolution.value //? 7Alternatively you can provide a custom implementation for rolling dice:
import Program from '@aiacta/dicelang';
...
const resolution = await new Program('1d20').run({
async roll(faces: number) {
return 19; // always so close...
},
});
resolution.value //? 19