@aiacta/dicelang

A language parsing and execution tool for dice roll.

Usage no npm install needed!

<script type="module">
  import aiactaDicelang from 'https://cdn.skypack.dev/@aiacta/dicelang';
</script>

README

dicelang

Installation

yarn add @aiacta/dicelang

Usage

import Program from '@aiacta/dicelang';

...

const resolution = await new Program('1d20').run();
resolution.value //? 7

Alternatively 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

Features