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

devildice

v1.1.1

Published

Create dice and use them

Downloads

10

Readme

Devil Dice

Roll the dice a simple dice roller. Nothing over the top just roll.

The basics

The code will auto load in a d6 dice.

roll

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.roll();

//output : [[2]]

add dice

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.addDice(20);

dd.roll();

//output : [[2,19]]

clear dice

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.clearStoredDice();

dd.roll();

//output : []

show dice

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.addDice(20);
dd.addDice(10);
dd.addDice(10);


dd.showDice();

//output : {"d6":1,"d10":2,"d20":1}

remove dice

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.addDice(20);
dd.addDice(10);
dd.addDice(3);

//Use the key from dd.showDice();
// in this case 2 would be the  key for the d10
dd.removeDice(2);

Advanced dice

Add multiple

const DevilDice = require("devildice");
var dd = new DevilDice;
dd.addDice([10,20,7,8])

Roll All Dice

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.addDice(20);
dd.addDice(10);
dd.addDice(3);
dd.addDice(3);

dd.rollAllDice();

//output : [[10,5,3,2]]

Roll them x number of times (remember that by default a d6 is added so the first dice unless cleared is a d6)

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.addDice(20);
dd.addDice(10);
dd.addDice(3);
dd.addDice(3);

dd.rollAllDice(6);

//output : [[2,17,1,3],[5,11,3,3],[10,5,1,1],[9,5,1,1],[2,2,2,3],[4,1,3,2]]

Mode

The mode can be change to have a greater details

const DevilDice = require("devildice");
var dd = new DevilDice;

dd.addDice([10,20,6])

dd.mode = 1;
dd.rollAllDiceWithStats(3);

//output : [{"key":"roll_0","result":[4,5,6,4],"stats":{"total":19,"min":4,"max":6,"mean":4.75,"mode":4,"median":4.5,"standardDeviation":0.9574271077563381}},{"key":"roll_1","result":[2,15,6,2],"stats":{"total":25,"min":2,"max":15,"mean":6.25,"mode":2,"median":4,"standardDeviation":6.1305247192498395}},{"key":"roll_2","result":[4,5,1,4],"stats":{"total":14,"min":1,"max":5,"mean":3.5,"mode":4,"median":4,"standardDeviation":1.7320508075688772}},{"name":"all dice","min":1,"max":15,"mean":4.833333333333333,"median":4,"mode":4,"total":58,"standardDeviation":3.563280749108846,"size":12,"variance":12.696969696969697}]

dd.mode = 0;
dd.rollAllDiceWithStats(3);

//output : [[8,18,6,1],[10,9,6,3],[10,15,5,2],{"name":"all dice","min":1,"max":18,"mean":7.749999999999999,"median":7,"mode":10,"total":93,"standardDeviation":5.083395429327635,"size":12,"variance":25.840909090909093}]

if you like check the rest of my projects at https://github.com/TechDevils and maybe checkout ko-fi