Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jprochazk/roll-dice

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jprochazk/roll-dice

evaluate standard dice roll notation

  • 0.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by450%
Maintainers
0
Weekly downloads
 
Created
Source

roll-dice

Evaluate standard dice roll notation.

$ npm i roll-dice@npm:jprochazk/roll-dice
import { roll } from "roll-dice";

roll("5d6") // roll a 6-sided die 5 times.
roll("5d6 + 10") // roll a 6-sided die 5 times, and add 10 to the result.

Syntax

descriptionexample
a + badd a and b1 + 1
a - bsubtract b from a1 - 1
a * bmultiply a by b1 * 1
a / bdivide a by b1 / 1
- bnegates b-1
d arolls an a-sided died5
a d brolls a b-sided die, a times2d10
( a )grouping expression, used to specify precedence(1+1)

Every a or b in the above table may contain another expression, and expressions may be arbitrarily nested. For example (10+5)*2+(5d10) is a valid expression.

Structure

  • lib.rs - entry point for the WASM module
  • parse.rs - a recursive descent parser which outputs a list of instructions in postfix notation.
  • eval.rs

The library is written in Rust, and uses wasm-pack for packing it as a WASM module and publishing it on NPM. Various commands (available in the justfile) are run using just.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

FAQs

Package last updated on 20 Jul 2024

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