3.0.4 • Published 12 months ago

roll-anything v3.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
12 months ago

Roll anything 🎲

npm i roll-anything

A very tiny dice util. You can roll a dice with any amount of sides.

Meet the family (more tiny utils with TS support)

Usage

Roll a number

import { roll } from 'roll-anything'

// Rolling 🎲👋
roll() // returns a random number between 0-100; including 0 and 100
roll(10) // returns a random number between 0-10; including 0 and 10
roll(5, 10) // returns a random number between 5-10; including 5 and 10

Flip a coin

import { flip } from 'roll-anything'

flip() // returns 'heads' or 'tails' at random

Dice 🎲

import { Dice } from 'roll-anything'

// Create a die of 6 sides
const dice = Dice(6)
// returns { sides: 6, roll: function }

dice.roll() // returns 1 ~ 6
dice.sides // returns 6

// Rolling 🎲👋
Dice().roll() // returns 1 ~ 6
// → 6 sided dice is the default.

Dice(2).roll() // returns 1 ~ 2
Dice(10).roll() // returns 1 ~ 10

// Roll a specific number
Dice(6).rollAssert(6)
// rolls 1 ~ 6
//   then returns `true` if it rolled 6 or `false` if it didn't

Dice(2).rollAssert(1)
// 50-50 chance to get `true` or `false`

Source code

See the source code here.

3.0.4

12 months ago

3.0.3

1 year ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

4 years ago

1.0.0

4 years ago

0.0.4

4 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago