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

moirae-core

v0.1.0

Published

The moirae engine: deterministic simulation testing for distributed systems. Clock, event queue, PRNG, network faults, invariants, JSONL trace. Zero dependencies.

Readme

moirae-core

The moirae engine: deterministic simulation testing for distributed systems, in TypeScript, with zero dependencies. You write a protocol against a small interface; the engine runs it under a deterministic scheduler with injected faults — latency, loss, duplication, partitions, crashes — checks your invariants after every step, and writes a JSONL trace you can replay and scrub through.

The interface

interface Process<S> {
  persistent?: readonly (keyof S)[];   // state fields that survive a crash
  init(ctx: Ctx<S>): S;
  onMessage(ctx: Ctx<S>, from: NodeId, msg: Message): void;
  onTimer(ctx: Ctx<S>, name: string): void;
  onRestart?(ctx: Ctx<S>, persisted: Partial<S>): void;
}

interface Ctx<S> {
  readonly me: NodeId;
  readonly peers: readonly NodeId[];
  state: S;
  now(): SimTime;                              // logical clock, never wall clock
  random(): number;                            // [0,1), per-node seeded PRNG
  randomInt(min: number, max: number): number; // integer in [min, max]
  send(to: NodeId, msg: Message): void;
  broadcast(msg: Message): void;
  setTimer(name: string, delayMs: number): void;
  cancelTimer(name: string): void;
  log(event: string, data?: Record<string, unknown>): void;
  crash(): void;
}

A process sees the world only through ctx. There is no other way to get the time, a random number, or a timer.

Run one

import { simulate } from 'moirae-core';

const result = simulate<State>({
  seed: 0xc0ffee,
  nodes: 5,
  process: MyProtocol,            // a class implementing Process<State>
  until: { simTime: 5_000 },
  network: {
    latency: [10, 50],
    dropRate: 0.02,
    partitions: [{ groups: [[1, 2], [3, 4, 5]], start: 1000, end: 2000 }],
  },
  faults: { crashes: [{ node: 3, at: 2500, restartAt: 3000 }] },
  invariants: [myInvariant],      // { name, check(world): string | null }
});

result.violation; // null, or { invariant, detail, step, time }
result.jsonl;     // the trace — `npx moirae replay` opens it

A sketch; the runnable, typechecked version is examples/src/ping.ts.

Determinism

Same seed, same trace, byte for byte — across runs, machines and Node versions; the project's CI hashes its example traces on Node 20, 22 and 24 on every push. When a run finds a violation, the seed is the whole bug report.

The interfaces, precisely: SPEC.md. Repository: https://github.com/pchrysostomou/moirae. Apache-2.0.