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

@rppdice/core

v1.2.0

Published

RppDice engine: universal dice grammar (2d6+3>=10, 4D6KH3, …) + declarative TOML system loader + step pipeline runner.

Readme

@rppdice/core

RppDice のエンジン本体 — 汎用ダイス文法 (2d6+3>=104D6KH33D10R6 …)、TOML 定義の TRPG システムローダー、ステップパイプラインランナー。純粋 TypeScript、ネイティブモジュールなし。全体像は リポジトリ README を参照。

インストール

npm install @rppdice/core

(プレアルファ — 公開 API が固まるまで npm への publish は保留しています。)

2 つのエントリポイント

1. 汎用ダイス文法 — roll(command, opts?)

import { roll } from "@rppdice/core";

const r = roll("2d6+3", { seed: 42n });
// r.value → 13
// r.text  → "2D6+3 > [4, 6]+3 = 13"
// r.rands → [{ kind: "normal", sides: 6, value: 4 }, …]

const c = roll("2d6+3>=10", { seed: 42n });
// c.comparison → { op: ">=", lhs: 13, rhs: 10, success: true }

NdM+ - * /()、比較演算 (>=<===!= …)、修飾子 (KH N / KL N / DH N / DL N の keep / drop、R K / R>=K 等の爆発) をサポート。修飾子は記述順 (左→右) に適用されるため、4d6KH3R6 (keep → 爆発) と 4d6R6KH3 (爆発 → keep) は別物です。

完全な記法リファレンス: プレイグラウンドサイトの /docs/<lang>/basics 以下のセクション群、または roll の JSDoc を参照。

2. システム判定 — evalSystem(registry, id, command, opts?)

import { createRegistry, loadSystem, evalSystem } from "@rppdice/core";
import TB_TOML from "@rppdice/example/systems/three-band-2d6.toml";

const registry = createRegistry();
loadSystem(registry, TB_TOML);

const out = evalSystem(registry, "three-band-2d6", "TB+3", { seed: 42n, locale: "ja" });
// out.text    → "2D6 [4, 6] 修正=3 合計=13 → 大成功"
// out.success → true   (rule.verdict が flags.success に登録されているとき)

TOML 「システム」は、正規表現コマンドパターン・ステップパイプライン (rollevaloutcomeiflooprepeataccumulateoutput)・i18n.<tag> ブロックをひとまとめにします。マッチした verdict は out.success / out.failure / out.critical / out.fumble のいずれかに反映され、テンプレ用には実行コンテキストの {verdict} 変数(ローカライズ済みラベル)で参照できます。登録済みパターンのいずれにも該当しない入力は、evalSystem が汎用文法へフォールスルーするので基本記法はそのまま動きます。

作成ガイドはサンプル一式を参照: packages/example/ の各 src/systems/*.tomli18n ブロック・outcome.flags の使い方・テーブル参照・ループの典型を網羅しています。

トレース

evalSystemtracer コールバックを受け付け、マッチしたパイプラインのトップレベルステップごとに TraceFrame を 1 個渡します。CI でのステップ単位検証、プレイグラウンド表示、@rppdice/clirppdice trace コマンドなどで利用します。

const frames: TraceFrame[] = [];
evalSystem(registry, "three-band-2d6", "TB+3", {
  seed: 42n,
  tracer: (f) => frames.push(f),
});

エラー

スローされる全エラーは RppDiceError を継承し、ダウンストリーム i18n 用の { code, params } を持ちます。コードカタログは src/dice/error-codes.tssrc/expr/error-codes.ts にあります。

import { RppDiceError } from "@rppdice/core";

try {
  roll("2d0");
} catch (e) {
  if (e instanceof RppDiceError) {
    e.code; // "dice.invalid_sides"
    e.params; // { sides: 0 }
  }
}

ライセンス

MIT。LICENSE を参照。