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

@orcish/dag-mermaid

v0.1.0

Published

Mermaid flowchart renderer for @orcish/dag: a pure DagRaw to string function with no DOM and no runtime dependencies.

Readme

@orcish/dag-mermaid

A Mermaid flowchart renderer for @orcish/dag. Pure DagRaw → string — no DOM, no runtime, no other dependencies. Pipe the output to any Mermaid integration (CLI, IDE preview, mermaid.live, the mermaid browser package, etc.).

Install

pnpm add @orcish/dag @orcish/dag-mermaid

Usage

import { Dag } from '@orcish/dag';
import { renderMermaid } from '@orcish/dag-mermaid';

const dag = new Dag({ idOf: n => n.id })
  .addNode({ id: 'a', label: 'Alpha', kind: 'source' })
  .addNode({ id: 'b', label: 'Beta', kind: 'work' })
  .addNode({ id: 'c', label: 'Gamma', kind: 'sink' })
  .addEdge('a', 'b')
  .addEdge('b', 'c');

const out = renderMermaid(dag.toRaw(), {
  direction: 'LR',
  label: n => n.label,
});

console.log(out);
// flowchart LR
//   a["Alpha"]
//   b["Beta"]
//   c["Gamma"]
//   a --> b
//   b --> c

dag.toRaw() is @orcish/dag's interop boundary — it returns the immutable DagRaw snapshot the renderer consumes. If you already work with the pure-function API, you can pass your DagRaw directly.

Options

All options are optional and operate on the user's own node type N — the package has no opinion about what labels, classes, or shapes mean.

| Option | Type | Default | | ----------- | ------------------------------------------------------------------------- | -------------- | | direction | 'TB' \| 'TD' \| 'BT' \| 'LR' \| 'RL' | 'TD' | | label | (node, id) => string | String(id) | | shape | (node, id) => 'rect' \| 'rounded' \| 'stadium' \| 'circle' \| 'diamond' | 'rect' | | classOf | (node, id) => string \| undefined | no class | | classDefs | Record<string, string> — Mermaid style strings per class | none | | edgeLabel | (from, to, fromId, toId) => string \| undefined | no edge labels | | indent | string — indentation per non-header line | ' ' |

Only classDef entries referenced by at least one node are emitted, and class assignments are grouped per class for compact output.

Output guarantees

  • Deterministic. Same DagRaw + same options → same string. Node lines follow state.nodes insertion order; edges follow state.out insertion order.
  • Mermaid-safe ids. Keys matching ^[A-Za-z_][A-Za-z0-9_]*$ pass through unchanged; anything else (and any collisions) becomes a synthetic n<i>.
  • Escaped labels. In both node and edge labels, " becomes #quot; and \n becomes <br/>; edge labels additionally escape | (the Mermaid label delimiter) as #124;.

Quickstart example

A runnable example covering every option lives at examples/quickstart.mjs. After installing and building the workspace:

node examples/quickstart.mjs               # prints the Mermaid source
node examples/quickstart.mjs | pbcopy      # macOS — paste into mermaid.live