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

rolld20

v1.0.7

Published

A simple tool designed to roll dices, of any side: d2 (flip coin), d3, d4, d6, d8, d12, d20, d30, d60, d100, d1000, and jan-ken-po.

Downloads

31

Readme

Roll d20 🎲

A simple tool designed to roll dices, of any side: d2 (flip coin), d3, d4, d6, d8, d12, d20, d30, d60, d100, d1000, and jan-ken-po.

npm i rolld20
yarn add rolld20

Usage

Pick a Dice

2 sides dice (d2) / flip a coin

import { d2, flipCoin } from 'rolld20'

// Rolling d2 🎲👋
d2(); // return a random number between 1-2;
d2(10); // return an array of 10 elements with random numbers between 1-2;

flipCoin(); // return a string: 'heads' or 'tails" at random;

3 sides dice (d3)

import { d3 } from 'rolld20'
 // Rolling d3 🎲👋
d3(); // return a random number between 1-3;
d3(10); // return an array of 10 elements with random numbers between 1-3;

4 sides dice (d4)

import { d4 } from 'rolld20'

 // Rolling d4 🎲👋
d4(); // return a random number between 1-4;
d4(10); // return an array of 10 elements with random numbers between 1-4;

6 sides dice (d6)

import { d6 } from 'rolld20'

// Rolling d6 🎲👋
d6(); // return a random number between 1-6;
d6(10); // return an array of 10 elements with random numbers between 1-6;

8 sides dice (d8)

import { d8 } from 'rolld20'

// Rolling d8 🎲👋
d8(); // return a random number between 1-8;
d8(10); // return an array of 10 elements with random numbers between 1-8;

10 sides dice (d10)

import { d10 } from 'rolld20'

// Rolling d10 🎲👋
d10(); // return a random number between 1-10;
d10(10); // return an array of 10 elements with random numbers between 1-10;

12 sides dice (d12)

import { d12 } from 'rolld20'

// Rolling d12 🎲👋
d12(); // return a random number between 1-12;
d12(10); // return an array of 10 elements with random numbers between 1-12;

20 sides dice (d20)

import { d20 } from 'rolld20'

// Rolling d20 🎲👋
d20(); // return a random number between 1-20;
d20(10); // return an array of 10 elements with random numbers between 1-20;

30 sides dice (d30)

import { d30 } from 'rolld20'

// Rolling d30 🎲👋
d30(); // return a random number between 1-30;
d30(10); // return an array of 10 elements with random numbers between 1-30;

60 sides dice (d60)

import { d60 } from 'rolld20'

// Rolling d60 🎲👋
d60(); // return a random number between 1-60;
d60(10); // return an array of 10 elements with random numbers between 1-60;

100 sides dice (d100)

import { d100 } from 'rolld20'

// Rolling d100 🎲👋
d100(); // return a random number between 1-100;
d100(10); // return an array of 10 elements with random numbers between 1-100;

1000 sides dice (d1000)

import { d1000 } from 'rolld20'

// Rolling d1000 🎲👋
d1000(); // return a random number between 1-1000;
d1000(10); // return an array of 10 elements with random numbers between 1-1000;

Rolling Jan-ken-po

import { janKenPo } from 'rolld20'

// Rolling jan-ken-po ✊✋✌️
janKenPo(); // return a string: 'rock', 'paper', or 'scissors' at random;

// Rolling jan-ken-po with bomb allowed ✊✋✌️👍
janKenPo(true); // return a string: 'rock', 'paper', 'scissors', or 'bomb' at random;

Comparing Jan-ken-po

import { compareJanKenPo } from 'rolld20'

// Compare two jan-ken-po ✊✋✌️👍 x ✊✋✌️👍
compareJanKenPo('paper', 'bomb'); // return 1 (bomb beats paper)
compareJanKenPo('scissor', 'paper'); // return -1 (scissors beats papaer)
compareJanKenPo('rock', 'rock'); // return 0 (it's a tie)

Source code

See the source code here.