UNPKG

@randsum/dice

Version:

A flexible, type-safe dice roller for tabletop RPGs, game development, and probability simulations

8 lines (7 loc) 243 B
function calculateTotal(rolls, bonus = 0) { if (rolls.every((roll) => typeof roll === 'number')) { return rolls.reduce((acc, cur) => Number(acc) + cur, bonus); } return rolls.flat().join(', '); } export { calculateTotal };