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

maze-builder

v0.1.2

Published

Framework-agnostic, pure TypeScript maze generation library

Readme

maze-builder

Framework-agnostic, pure TypeScript maze generation library. Zero runtime dependencies. Dual ESM/CJS output with .d.ts declarations.

Installation

npm install maze-builder
# or
yarn add maze-builder

Quick Start

import { generateMaze, Algorithm } from 'maze-builder';

// 10×10 maze using DFS — returns a (2H+1)×(2W+1) numeric matrix
// 0 = wall, 1 = passage
const maze = generateMaze({ width: 10, height: 10, algorithm: Algorithm.DFS });

// Reproducible output with a seed
const seeded = generateMaze({ width: 10, height: 10, algorithm: Algorithm.DFS, seed: 42 });

// Graph adjacency-list format
import { Format } from 'maze-builder';
const graph = generateMaze({ width: 5, height: 5, algorithm: Algorithm.PRIMS, format: Format.GRAPH });
// graph[0] → { id: 0, x: 0, y: 0, neighbors: [1, 5, ...] }

API

generateMaze(config: MazeConfig): MazeMatrix | MazeGraph

| Field | Type | Required | Description | |-------|------|----------|-------------| | width | number | ✓ | Cells wide (positive integer) | | height | number | ✓ | Cells tall (positive integer) | | algorithm | Algorithm | ✓ | Generation algorithm | | format | Format | — | Output format (default: MATRIX) | | seed | number | — | PRNG seed for reproducibility | | fractalMode | 'tile-substitution' \| 'quadtree-division' | — | Fractal Tessellation mode (default: 'tile-substitution') | | roomsConnectionMode | 'manhattan-l' \| 'random-walk' \| 'nearest-mst' | — | Rooms & Corridors connector strategy (default: 'manhattan-l') | | voronoiPreset | 'natural' \| 'structured' \| 'border-doors' \| 'border-doors-braided' \| 'region-border-doors' | — | Voronoi Diagram preset (default: 'natural') | | caFillRatio | number | — | Cellular Automaton initial alive-cell fill ratio in (0, 1) (default: 0.45) | | caGenerations | number | — | Cellular Automaton generation count, positive integer (default: 4) | | caRule | 'b5s45' \| 'maze' \| 'mazectric' | — | Cellular Automaton rule preset (default: 'b5s45') |

generateMazeSteps(config: MazeConfig): MazeMatrix[]

Returns ordered intermediate matrix snapshots for animation/progression use-cases. The last snapshot equals generateMaze(config) in matrix format.

Algorithms

| Value | Description | Time | Space | |-------|-------------|------|-------| | Algorithm.DFS | Iterative Depth-First Search (Recursive Backtracker) | O(W×H) | O(W×H) | | Algorithm.PRIMS | Randomised Prim's | O(W×H) | O(W×H) | | Algorithm.KRUSKALS | Randomised Kruskal's (Union-Find) | O(W×H·α(W×H)) | O(W×H) | | Algorithm.BINARY_TREE | Binary Tree maze generation | O(W×H) | O(W×H) | | Algorithm.WILSONS | Wilson's algorithm | O(W×H) | O(W×H) | | Algorithm.ALDOUS_BRODER | Aldous-Broder random walk | O(W×H) | O(W×H) | | Algorithm.ELLERS | Eller’s algorithm | O(W×H) | O(W) | | Algorithm.SIDEWINDER | Sidewinder algorithm | O(W×H) | O(W) | | Algorithm.HUNT_AND_KILL | Hunt-and-kill algorithm | O(W×H) | O(W×H) | | Algorithm.RECURSIVE_DIVISION | Recursive division | O(W×H) | O(W×H) | | Algorithm.GROWING_TREE | Growing Tree algorithm | O(W×H) | O(W×H) | | Algorithm.HOUSTONS | Houston's algorithm | O(W×H) | O(W×H) | | Algorithm.TREMAUX | Trémaux-inspired exploration/backtracking | O(W×H) | O(W×H) | | Algorithm.SPIRAL_BACKTRACKER | DFS variant with clockwise turning preference, producing spiral-heavy local structure | O(W×H) | O(W×H) | | Algorithm.SPANNING_TREE_BFS | BFS frontier spanning tree, producing shorter/wider paths and shallow dead ends | O(W×H) | O(W×H) | | Algorithm.FRACTAL_TESSELLATION | Fractal Tessellation (tile/quadtree modes) | O(W×H) | O(W×H) | | Algorithm.ROOMS_AND_CORRIDORS | Room placement with corridor connectors | O(W×H + R²) | O(W×H + R²) | | Algorithm.VORONOI_DIAGRAM | Voronoi regions + spanning connectors (natural/structured presets) | O(W×H×S) | O(W×H + S) | | Algorithm.CELLULAR_AUTOMATON | Cellular automaton cave generation with connectivity repair | O(G×W×H) | O(W×H) |

Output Formats

  • Format.MATRIX (default) - number[][] grid of size (2H+1)×(2W+1). 0 = wall, 1 = passage. Entry opens at grid[1][0]; exit at grid[2H-1][2W].
  • Format.GRAPH - GraphNode[] adjacency list. Each node: { id, x, y, neighbors }.

Development

yarn install        # install dev dependencies
yarn test           # vitest watch mode
yarn test:run       # single test run
yarn test:coverage  # coverage report
yarn typecheck      # tsc --noEmit
yarn build          # Vite library build → dist/

Metadata source of truth

Algorithm lists, variant presets, and runtime option guards are centralized in src/metadata/algorithms.ts. When adding or changing algorithm exposure, update metadata there first, then consume it from API/sandbox code instead of duplicating string literals across files.

Project MCP servers

This repository includes project MCP server config in .mcp.json for:

  • context7
  • github
  • lovable

Demo Pages

  • /index.html - algorithm gallery with per-algorithm maze cards
  • /compare.html - overlap comparison across selected algorithms
  • /visualizer.html - step-by-step generation snapshots
  • /formats.html - one seeded maze rendered in both Format.MATRIX and Format.GRAPH
  • /game.html - playable maze game with DOM and canvas renderers

GitHub Pages Live URLs

  • https://krontill.github.io/maze-builder/
  • https://krontill.github.io/maze-builder/compare.html
  • https://krontill.github.io/maze-builder/visualizer.html
  • https://krontill.github.io/maze-builder/formats.html
  • https://krontill.github.io/maze-builder/game.html

License

MIT