Install
Packages are distributed as source/archive, not published to npm.
npm pack ./dist/packages/ledger
npm install /path/to/cranberry-forge-ledger-0.1.0.tgzRequires Node 22+ for Node examples, or a modern browser supporting structuredClone.
Example
import { Ledger } from "@cranberry-forge/ledger";
const stats = new Ledger({ base: { attack: 50, speed: 3 }, rounding: 2 });
stats.setModifier({
id: "blade:attack",
source: "blade",
stat: "attack",
kind: "flat",
value: 10,
});
console.log(stats.result.values.attack); // 60
stats.removeSource("blade"); // attack returns to 50