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

miaoda-game-wave-core

v0.2.0

Published

Engine-agnostic enemy-spawn director. Covers both models games actually use: discrete waves (tower defense, boss rush, clear-the-room — ordered waves of groups that advance on cleared/spawned/timer) and continuous pressure (survivors-likes, arenas, AI dir

Readme

miaoda-game-wave-core

Use this engine-independent package to decide what enemies spawn, when they spawn, and which named spawn point they use. It emits plain SpawnInfo records; your game instantiates prefabs, places entities, and reports deaths.

Install

pnpm add miaoda-game-wave-core

Choose a pacing model

| Model | Best for | Completion | | --- | --- | --- | | WaveRunner | Tower defense, rooms, boss rushes | Ordered waves with cleared/spawned/timer rules | | Director | Survivors-like arenas and continuous pressure | Runs until stop() |

Both use seconds, accept an optional seed, and advance only when you call update(dt).

Discrete waves

import { WaveRunner } from 'miaoda-game-wave-core';

const runner = new WaveRunner({
  seed: 42,
  waves: [
    { groups: [{ type: 'goblin', count: 5, interval: 0.5, spawnPointId: 'left' }], restDelay: 3 },
    { name: 'boss', groups: [{ type: 'ogre' }], completeOn: 'cleared' },
  ],
});

runner.onSpawn(({ type, spawnPointId }) => spawnEnemy(type, spawnPointId));
runner.onWaveComplete((index) => showWaveComplete(index));
runner.onComplete(() => finishLevel());
runner.start();

// Fixed or frame update, in seconds:
runner.update(dt);
// When an enemy owned by the active cleared wave dies:
runner.reportKilled();

Groups run on their own delay/interval clocks and may use a fixed type or weighted table. completeOn defaults to cleared; use spawned when survival of old enemies should not block the next wave, or timer with duration for time-boxed pressure.

Continuous director

import { Director } from 'miaoda-game-wave-core';

const director = new Director({
  seed: 42,
  rate: [{ at: 0, value: 0.5 }, { at: 180, value: 6 }], // spawns per second
  table: (elapsed) => elapsed > 120 ? { bat: 3, skeleton: 2 } : { bat: 5 },
  maxAlive: 100,
  spawnPoints: ['north', 'south'],
});
director.onSpawn((info) => spawnEnemy(info.type, info.spawnPointId));
director.start();

Call director.reportKilled() for every tracked death. Otherwise maxAlive never frees capacity and spawning stops at the cap. stop() halts the run; a later start() begins a fresh run with reset time, alive count, spawn credit, and seeded RNG sequence.

Determinism and state

A fixed seed reproduces weighted types and spawn-point choices when update and death inputs are identical. WaveRunner.snapshot and Director.snapshot are observation/telemetry views only; neither class provides restore. Save authoritative spawned entities and scheduling state in your own game protocol if mid-wave restoration is required.

Public API

  • WaveRunner: ordered wave scheduling, phase/status events, and kill accounting.
  • Director: rate curves, evolving weighted tables, warmup, and alive caps.
  • sampleCurve, sampleOverTime: resolve time-varying numeric values.
  • Rng, SpawnInfo, SpawnTable, Wave, SpawnGroup, and config types.

The core never loads assets, chooses coordinates, or detects deaths.