npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mini-dice

v1.2.6

Published

A mini tool to generate random number based on dice roll

Downloads

5

Readme

Mini Dice

A mini tool to generate random number based on dice roll :game_die:

Build Status

Usage

var Dice = require('mini-dice');

// Roll the dice !
var random = Dice.roll();  

 // Roll two 12-sided dice
var damage = Dice.roll("2d12");
// Roll five 20-sided dice
var ennemies = Dice.roll([5, 20]);

// Find the minimum roll
var minScore = Dice.minRoll('4d10');
// Find the maximum roll
var criticalStrike = Dice.maxRoll(3, 20) > 18;

API

var Dice = require('mini-dice');

This module give access to a static class Dice, whith 3 methods

  • roll compute the sum of successive dice roll
  • maxRoll compute the maximum value obtained from successive dice roll
  • minRoll compute the minimum value obtained from successive dice roll

Accepted Input

All three methods accept the same type of input, which describes the number of dice to roll and the number of sides of the dice.

String

You can use a single String as input.

It should be formatted as "NdS" where N is the number of dice, d is the separator, and S the number of sides.

Example: roll("4D20")

Note: You can use either lower-case or upper-case d as a separator

Array

You can use a single Array as input.

The first two values will be used as N the number of dice and S the number of sides, respectively.

** Example:** roll([4, 20])

Number & String

You can use two Number or String as input.

The first value will be used as N the number of dice, and the second value as S the number of sides.

** Example:** roll(4,20)

Note: Both values can have different types, but they need to parsable as integers.

One Number / String

If you are feeling lazy, and only wants to give one input, you can.

The Number or String will be used as N the number of dice, and the number of sides is 6 by default.

Installation

The module can be installed from npm

npm install mini-dice

It can also be installed by including the mini-dice.js file in your project

License

This project is licensed under the WTFPL - see LICENSE for more details

Acknowledgments

This tool was used to test the creation of a simple node module, and continuous integration with Travis. Since it is used by some people, it should stay here for a while.