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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@randsum/daggerheart

v1.1.0

Published

A flexible, type-safe dice roller for building Daggerheart-compatible applications

Readme

npm version bundle size Types License Downloads codecov

A type-safe implementation of Daggerheart Duality Dice mechanics.

Installation

npm install @randsum/daggerheart
# or
bun add @randsum/daggerheart

Usage

import { roll } from "@randsum/daggerheart"

// Basic roll - Hope die (d12) + Fear die (d12)
const result = roll({})

console.log(result.total) // Combined total
console.log(result.result) // 'hope' | 'fear' | 'critical hope'

// With a modifier
const modified = roll({ modifier: 2 })

// With advantage (adds d6) or disadvantage (subtracts d6)
const withAdvantage = roll({ rollingWith: "Advantage" })
const withDisadvantage = roll({ rollingWith: "Disadvantage" })

// Amplified dice (d20 instead of d12)
const amplified = roll({
  amplifyHope: true, // Hope die becomes d20
  amplifyFear: true // Fear die becomes d20
})

Result Types

Daggerheart uses Duality Dice: a Hope die and a Fear die. The result type is determined by which die rolls higher:

  • 'hope' - Hope die is higher (player narrates)
  • 'fear' - Fear die is higher (GM gains Fear)
  • 'critical hope' - Both dice show the same value (critical success)
const { result, total, details } = roll({ modifier: 2 })

switch (result) {
  case "critical hope":
    console.log("Critical success!")
    break
  case "hope":
    console.log("Success with Hope")
    break
  case "fear":
    console.log("Success, but GM gains Fear")
    break
}

// Access individual dice
console.log(details.hope.roll) // Hope die value
console.log(details.fear.roll) // Fear die value
console.log(details.modifier) // Applied modifier

API Reference

roll(options)

function roll(options: DaggerheartRollArgument): DaggerheartRollResult

Options:

| Parameter | Type | Default | Description | | ------------- | ------------------------------- | ------- | ---------------------- | | modifier | number | 0 | Added to the total | | rollingWith | 'Advantage' \| 'Disadvantage' | - | Adds or subtracts a d6 | | amplifyHope | boolean | false | Use d20 for Hope die | | amplifyFear | boolean | false | Use d20 for Fear die |

Returns:

interface DaggerheartRollResult {
  total: number
  result: "hope" | "fear" | "critical hope"
  details: {
    hope: { roll: number; amplified: boolean }
    fear: { roll: number; amplified: boolean }
    modifier: number
    advantage: { roll: number } | undefined
  }
}

Related Packages