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

trpg-dice

v1.3.4

Published

Tabletop RPG dice-roller with a multiple dice-types, rolling methods, minimum and maximum values, string output, and error-first callbacks.

Downloads

53

Readme

trpg-dice

Build Status npm NpmLicense

Tabletop RPG dice-roller with a multiple dice-types, rolling methods, minimum and maximum values, string output, and error-first callbacks.

Installation

npm install trpg-dice

Usage

To use the library, import the module and call the roll() method with a dice expression, an optional options parameter, and a callback function. Dice expressions with standard <number of dice>d<number of sides> are all supported as well as simple math. To roll Fate/Fudge dice, use dF or df for the dice expression.

const dice = require("trpg-dice");

function callback(err, result) {
  if (err) {
    throw err;
  } else {
    console.log(result);
  }
}

dice.roll("2d6+10", callback);
dice.roll("d20-2", { roll: 10 }, callback); // will roll d20-2 for 10 times
dice.roll("4dF+2", callback); // will roll Fate/Fudge dice
dice.roll("d8+d12", callback);
dice.roll("4d6+(2d6/2)", callback);

The roll() method is an error-first callback that invokes the callback function with an error (or null if none) and an object with the original dice expression, minimum, maximum, average, and roll results.

{
  expression: '2d6+2',
  min: 4,
  max: 14,
  avg: 9,
  rolls: [
    { result: 12, resultString: '(5+5)+2', condensedResultString: '(10)+2' },
    { result: 8, resultString: '(1+5)+2', condensedResultString: '(6)+2' },
    { result: 11, resultString: '(3+6)+2', condensedResultString: '(9)+2' },
    { result: 5, resultString: '(2+1)+2', condensedResultString: '(3)+2' },
    { result: 8, resultString: '(5+1)+2', condensedResultString: '(6)+2' },
    { result: 13, resultString: '(6+5)+2', condensedResultString: '(11)+2' },
    { result: 9, resultString: '(5+2)+2', condensedResultString: '(7)+2' },
    { result: 9, resultString: '(4+3)+2', condensedResultString: '(7)+2' },
    { result: 8, resultString: '(4+2)+2', condensedResultString: '(6)+2' },
    { result: 8, resultString: '(4+2)+2', condensedResultString: '(6)+2' }
  ]
}

Options

The following options are currently supported:

  • roll - specifies the amount of times the dice expression should be rolled, increasing the number of roll results returned in the object