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

@zakkster/lite-shadow

v1.0.0

Published

Zero-GC 2D visibility polygon. Raycasting with AABB rejection, angle deduplication, fround() stability.

Readme

@zakkster/lite-shadow

npm version npm bundle size npm downloads npm total downloads TypeScript Dependencies License: MIT

🔦 What is lite-shadow?

@zakkster/lite-shadow computes a visibility polygon from a light source against wall segments — the foundation for fog of war, line of sight, and dynamic shadows.

It gives you:

  • 🔦 Visibility polygon from any origin point
  • 🧱 Raycasting against flat [x1,y1,x2,y2,...] wall segments
  • ⚡ AABB rejection (skips 30–60% of ray-segment math)
  • 🎯 Angle deduplication (shared corners cast once)
  • 🔬 Math.fround() stability for precision at exact corners
  • 📐 3 rays per unique angle (±ε for perfect corner tracing)
  • 🪶 < 1.5 KB minified

Part of the @zakkster/lite-* ecosystem — micro-libraries built for deterministic, cache-friendly game development.

🚀 Install

npm i @zakkster/lite-shadow

🕹️ Quick Start

import { VisibilityCaster } from '@zakkster/lite-shadow';

const caster = new VisibilityCaster(200); // max 200 wall segments
const walls = new Float32Array([
    0,0, 800,0,     // top wall
    800,0, 800,600,  // right wall
    800,600, 0,600,  // bottom wall
    0,600, 0,0       // left wall
]);
const polyBuf = new Float32Array(2400);

const numVerts = caster.cast(playerX, playerY, walls, polyBuf);

ctx.beginPath();
ctx.moveTo(polyBuf[0], polyBuf[1]);
for (let i = 2; i < numVerts * 2; i += 2) {
    ctx.lineTo(polyBuf[i], polyBuf[i + 1]);
}
ctx.closePath();
ctx.fill(); // visibility area

🧠 Why This Exists

Visibility polygon computation is usually baked into game engines (Phaser, rot.js). lite-shadow is the first standalone, zero-allocation raycaster. AABB pre-rejection skips expensive cross-product math for segments that can't possibly intersect the ray.

📊 Comparison

| Library | Size | Allocations | AABB Rejection | Install | |---------|------|-------------|----------------|---------| | rot.js FOV | ~8 KB | Medium (coupled) | No | npm i rot-js | | visibility-polygon | ~2 KB | Arrays per cast | No | npm i visibility-polygon | | lite-shadow | < 1.5 KB | Zero (pre-allocated) | Yes | npm i @zakkster/lite-shadow |

⚙️ API

new VisibilityCaster(maxEdges)

  • maxEdges: Max number of wall segment endpoints (not segments). Allocates internal buffers.

cast(originX, originY, segments, outPoly)

  • segments: Float32Array — flat [x1,y1,x2,y2,...] wall segments
  • outPoly: Float32Array — pre-allocated output [x,y,x,y,...]
  • Returns: number of vertices written

🧪 Benchmark

200 wall segments, 60fps cast:
  visibility-polygon: 1.8ms (array allocation per cast)
  lite-shadow:        0.6ms (pre-allocated, AABB skips 30-60% of math)

📦 TypeScript

Full TypeScript declarations included in VisibilityCaster.d.ts.

📚 LLM-Friendly Documentation

See llms.txt for AI-optimized metadata and usage examples.

License

MIT