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

waffle-batch

v0.1.2

Published

**High-Performance React Faceting Engine**

Downloads

343

Readme

Waffle Batch 🧇

High-Performance React Faceting Engine

waffle-batch is a specialized charting engine designed to render thousands of small multiples ("trellis charts") efficiently. It solves the performance bottlenecks of rendering massive dashboard grids by leveraging virtualization, shared resource scaling, and optimized data splitting.

License React Vite

🚀 Features

  • High-Performance Rendering: Uses react-intersection-observer to virtualize charts, rendering only what is in the viewport (with skeleton loading states).
  • Trellis Architecture: Automatically groups flat datasets into faceted grids based on any key (e.g., Region, Category).
  • Shared Scales: Calculates global min/max domains across the entire dataset to ensure visual consistency between charts.
  • Statistical Sorting: Built-in analytics engine to sort charts by:
    • Total Value (Sum)
    • Volatility (Standard Deviation)
    • Trend Direction (Linear Regression Slope)
    • Custom Logic (User-defined functions)
  • Interactive Search & URL Sync: Filters charts with debouncing and synchronizes state (Search, Sort, Config) with URL query parameters for deep linking.
  • Contextual Drill-Down: Supports clickable charts that can navigate to external dashboards (e.g., waffle-board) with context-specific query parameters.
  • Responsive Layout: CSS Grid-based layout that adapts chart width to available screen space.

📦 Installation

You can use waffle-batch as a standalone library in your React application.

npm install waffle-batch
# OR
npm install git+https://github.com/surprisewaffles-io/waffle-batch.git

Peer Dependencies:

  • react >= 18
  • react-dom >= 18

🛠 Usage

The Trellis Component

The core of the library is the Trellis component.

import { Trellis } from 'waffle-batch';

// 1. Prepare your data (flat array)
const salesData = [
  { region: 'West', month: 'Jan', value: 400 },
  { region: 'West', month: 'Feb', value: 300 },
  // ...
  { region: 'East', month: 'Jan', value: 200 },
];

// 2. Render
<Trellis
  data={salesData}
  facetKey="region" // Group by 'region'
  valueKey="value"  // Metric for scaling/sorting
  ChartComponent={MyChartComponent} // Your chart renderer
  minChartWidth={300}
  height={150}
  sharedScale={true} // Enforce same Y-axis across all charts
  
  // Optional: Sorting
  sortConfig={{
    type: 'trend', // Sort by growth trend
    direction: 'desc'
  }}
  
  // Optional: Drill-Down Interaction
  onChartClick={(key) => {
     window.location.href = `/details?id=${key}`;
  }}
/>

Sorting Config

The sortConfig prop accepts predefined algorithms or custom functions:

// Sort by Volatility (Standard Deviation)
sortConfig={{ type: 'deviation', direction: 'desc' }}

// Sort by Custom Function (e.g., Max Value)
sortConfig={{ 
  type: (data) => Math.max(...data.map(d => d.value)),
  direction: 'desc' 
}}

🏗 Development

The project supports a dual-build workflow:

  1. Demo App (Development):

    npm run dev

    Starts the interactive playground with mock data generation.

  2. Library Build (Distribution):

    npm run build:lib

    Compiles src/index.ts into a redistributable package (dist/lib).

✅ Testing

Unit tests are written in Vitest.

npm test

Includes coverage for:

  • Faceting logic
  • Search debouncing
  • Sorting algorithms (including custom functions)
  • Shared scale calculation

📄 License

MIT