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

@evilmonkeyinc/die-roller

v1.1.0

Published

A library that will allow you to take a common die shorthand, such as 2d20+5, and calculate the result

Downloads

3

Readme

Die Roller

A simple library to take die rolling shorthand and return the result

Installing

This library ahs been published to NPM and can be installed with npm or yarn

npm install @evilmonkeyinc/die-roller
yarn add @evilmonkeyinc/die-roller

The library will be compatible with both javascript and typescript

Usage

import { parse } from '@evilmonkeyinc/die-roller'

...

const parsedExpression = parse('4d6k3')
console.log(parsedExpression.result);
// will return a number between 3 and 18

The parse function will take a die expression shorthand and evaluate it and return the result.

The expression should be in the format {number of die}d{size of die}{options}

The options are used to perform simple actions on the die results before giving back the result, such as 2d20k1 which would return the higher of two d20 rolls or 4d6k3 which would return the result of the best three d6 rolls out of 4.

| Option | Description | | ---------- | --------------------------------------------- | | k{number} | Keep only the highest {number} of die results | | kh{number} | Keep only the highest {number} of die results | | kl{number} | Keep only the lowest {number} of die results | | d{number} | Drop the lowest {number} of die results | | dl{number} | Drop the lowest {number} of die results | | dh{number} | Drop the highest {number} of die results |

You can also chain expressions, or simply add or subtract whole numbers for the result by appending a + or - to an expression if you need to include modifiers to your results.

1d20+2+3 for your Palidin attacking with their Longsword, with their 2 in proficiency and 3 strength. You hit, and decide to SMITE the enemy, you could then roll 1d8+3+2d8 for damage, 1d8+3 for the weapon and 2d8 for a Divine Smite at 1st level