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

@study-rpg/core

v0.2.0

Published

Study-RPG engine: stats, leveling, gacha loot with pity, SRS, boss runs, and generic UI components. Content-pack agnostic.

Readme

@study-rpg/core

Engine layer of study-rpg — a content-pack-agnostic「養成型 RPG for exam prep」runtime. Provides the deterministic primitives (4-stat character, XP curves, gacha loot with pity, SRS due queue, mini-boss runs, daily streak multiplier, skill tree resolver) that any content / theme fork can build on top of. The default content pack ships Taiwan 一階 醫師國考 questions, but core itself knows nothing about medicine.

Install

pnpm add @study-rpg/core
# peer deps your app probably already has:
pnpm add react react-dom dexie dexie-react-hooks framer-motion

Requires Node ≥ 20.19 (for ESM import() of typed declarations) and a modern bundler (Vite / Webpack 5 / esbuild).

Minimal usage

import {
  newPlayer,
  applyXp,
  addStat,
  rollRarity,
  REWARD,
  DEFAULT_RARITY_WEIGHTS,
  DEFAULT_STAT_SCHEMA,
} from '@study-rpg/core'

// Bootstrap a player. The third arg is the ordered list of stat ids your
// theme/content pack uses; DEFAULT_STAT_SCHEMA is the engine's 4-stat default.
let player = newPlayer('p1', '見習醫師', DEFAULT_STAT_SCHEMA.order)
console.log(player.level) // 1

// Grant one minute of focused reading: REWARD primitives are structured —
// apply the xp portion via applyXp, and the stat bump via addStat.
const r = REWARD.readPerMinute
player = {
  ...applyXp(player, r.xp).player,
  stats: addStat(player.stats, r.stat.name, r.stat.delta),
}
console.log(player.xp, player.stats.stamina) // 5, 1

// Roll a rarity tier with built-in pity (SR at 30, SSR at 100).
// player.lootStats is initialized by newPlayer; reuse it for pity tracking.
const { rarity } = rollRarity(player.lootStats, DEFAULT_RARITY_WEIGHTS)
console.log(rarity) // 'N' | 'R' | 'SR' | 'SSR'

What you get

  • Player / Item / Question / Subject / ThemePack type definitions
  • applyXp / addStat / applyCheckIn / getStreakMultiplier reward helpers
  • rollLoot with built-in pity rules (PITY_SR_THRESHOLD = 30, PITY_SSR_THRESHOLD = 100)
  • newCard / reviewCard / dueCards SM-2 style spaced repetition
  • sampleMiniBoss / passed boss-run sampler
  • resolveSkillTree skill-node unlock resolver
  • getDB / StudyRpgDB Dexie wrapper for client-side persistence

Full API: see TypeScript declarations shipped with the package, or browse src/index.ts in the main repo.

License

AGPL-3.0-or-later. See LICENSE. Engine + themes are AGPL; default content pack is CC-BY-NC-4.0 (separate package).

Status

Pre-1.0 (0.x.y). Patch bumps are additive; minor bumps are breaking. The API surface stabilizes at 1.0.0 after the engine has more dogfood mileage. See the main repo for the roadmap.