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

@mazely/core

v0.3.0

Published

Platform-agnostic maze generation, solving, traversal, and grid algorithms for TypeScript.

Readme

@mazely/core

Platform-agnostic maze generation and solving algorithms with step-based execution. No DOM or Canvas dependencies — rendering and scheduling belong to the app layer.

Install

pnpm add @mazely/core

Concepts

  • Grid — cells connected by edges; an edge is a wall until it is opened.
  • Algorithm — a generator that yields MazeSteps instead of mutating the grid directly. Generation and solving share the same shape.
  • StepPlayer — applies steps forward (next) and backward (prev), so an application can inspect progress or run an algorithm to completion.

Usage

import { Mazely } from '@mazely/core'

const maze = new Mazely({
  grid: { type: 'square', rows: 21, cols: 21 },
  seed: 42, // optional, makes runs reproducible
})

// Generate: step through or fast-forward.
const generation = maze.generate('dfs', { start: { x: 0, y: 0 } })
generation.next() // one step at a time
generation.finish() // or apply everything at once

// Solve: same player interface.
const solving = maze.solve('a-star', {
  start: { x: 0, y: 0 },
  end: { x: 20, y: 20 },
})
solving.finish()

const result = maze.getSolveResult()
// { solved: true, path: [{ x, y }, ...], visitedCount, algorithm }

Each applied step exposes a payload describing the carve/expand direction (from/to cell IDs). Applications may use it as renderer input; the package does not provide rendering or animation scheduling:

const step = generation.steps[generation.index - 1]
step.payload // { from: '0:0', to: '0:1' }

// Lazy players know the exact total only when the source is exhausted.
generation.progress
// { index, bufferedSteps, done, totalSteps: number | null }

Algorithms

Generation: aldous-broder, binary-tree, dfs, eller, growing-tree, hunt-and-kill, kruskal, prim, recursive-division, sidewinder, traversal, and wilson.

  • prim — Prim's algorithm on randomly weighted edges: each frontier edge gets a fixed random weight when discovered, and the minimum-weight edge is carved next.
  • traversal — random traversal: a uniformly random frontier edge is carved on every step (a growing-tree variant; createGrowingTreeAlgorithm(strategy) exposes the shared implementation with random/newest/oldest strategies).

Solving: bfs, dfs, best-first, a-star, and flood. flood performs breadth-first traversal from a start point until every reachable cell is visited and does not require an end point.

maze.solve('flood', {
  start: { x: 0, y: 0 },
}).finish()

All generation algorithms support connected masks and finish with a spanning tree. Generation rejects a disconnected mask before changing the grid.

Runtime registries and guards are exported as MAZE_GENERATION_ALGORITHMS, MAZE_SOLVING_ALGORITHMS, isMazeGenerationAlgorithm(), and isMazeSolvingAlgorithm().

Editing

edit() validates and stages the complete batch before applying it. If a callback or operation throws, no edge changes or lifecycle events are kept.

maze.edit((editor) => {
  editor.closeAllEdges()
  editor.setEdgeOpenedBetween({ x: 0, y: 0 }, { x: 1, y: 0 }, true)
})

Traversal

Use traverseGrid() when an app needs every reachable cell without an end point. Results contain topology-neutral cell IDs, depth, and parent IDs.

import { traverseGrid } from '@mazely/core'

const visits = traverseGrid(maze.grid, {
  startCellId: '0:0',
  strategy: 'bfs',
})

Serialization

import { applySerializedGrid, serializeGrid } from '@mazely/core'

const saved = serializeGrid(maze.grid)
applySerializedGrid(otherMaze.grid, saved)

Events

const off = maze.on('step', ({ state }) => {
  console.log(state.index, '/', state.totalSteps)
})
maze.on('complete', () => console.log('done')) // fires once per completion
off() // on() returns an unsubscribe function

License

MIT