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

dice-wizard

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dice-wizard

A utility package for rolling dice with various configurations

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
0
Weekly downloads
 
Created
Source

Dice Wizard 🎲

A flexible TypeScript/JavaScript utility package for rolling and manipulating dice results.

Installation

npm install dice-wizard

Usage

import { DiceWizard } from "dice-wizard";

const diceWizard = new DiceWizard();
const result = diceWizard.roll("d20");
console.log(result);

API Reference

DiceRoller Class

roll(count: number, dieType: DieType): DieResult[]

Rolls a specified number of dice of a given type.

  • count: Number of dice to roll
  • dieType: Type of die (4, 6, 8, 10, 12, 20, or 100)
  • Returns: Array of die results
getSum(): number

Gets the sum of the last roll.

  • Returns: Total value of all dice in last roll
keepValues(values: number[]): DieResult[]

Keeps only dice with specific values from the last roll.

  • values: Array of values to keep
  • Returns: Filtered array of die results
removeValues(values: number[]): DieResult[]

Removes dice with specific values from the last roll.

  • values: Array of values to remove
  • Returns: Filtered array of die results
keepHighest(count: number): DieResult[]

Gets the highest N dice from the last roll.

  • count: Number of dice to keep
  • Returns: Array of the highest value die results
keepLowest(count: number): DieResult[]

Gets the lowest N dice from the last roll.

  • count: Number of dice to keep
  • Returns: Array of the lowest value die results

Types

typescript type DieType = 4 | 6 | 8 | 10 | 12 | 20 | 100; interface DieResult { value: number; dieType: DieType; }

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © Justin Michaliga

Keywords

FAQs

Package last updated on 07 Feb 2025

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