New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ck-dice

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ck-dice

A little dice helper library

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

ckDice

This is a little dice utility library with some convenience methods wrapped around a little dice function.

version

v1.0.0

installation

npm install ck-dice

The index.js file can be found in the src directory. This project is written in CoffeeScript.

walkthrough

When you require the library you get an instance of the DiceRoller class:

var diceRoller = require('ck-dice');

The main usage is the rollDice method. rollDice takes two parameters, the number of sides of the dice you want to roll and the number of dice you want rolled. You will get the sum of the number of dice rolled as a result. The next code example will roll four, six sided die.

var diceRoller = require('ck-dice');
console.log( diceRoller.rollDice(6, 4);
// result: 13

If you want to get an array of rolled dice back you can use the rollList function. This function also takes the number of sides and the number of dice as parameters and returns an array of integers.

var diceRoller = require('ck-dice');
console.log( diceRoller.rollList(10, 10);
// result: [ 4, 8, 3, 1, 6, 9, 2, 9, 3, 9 ]

There are also 9 convenience methods on the object representing the standard dice you could use. These methods take the number of dice and return a integer representing the sum the of the rolls. The methods area called as follows:

  1. d2()
  2. d4()
  3. d6()
  4. d8()
  5. d10()
  6. d12()
  7. d18()
  8. d20()
  9. d100()

Conclusion

If you find a bug or want to add some features, let me know. This project is still under active development.

Keywords

FAQs

Package last updated on 20 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc