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

cascading-column-filter

v1.0.0

Published

Headless, Excel-style cascading column filtering engine for JavaScript and TypeScript.

Readme

cascading-column-filter

Headless, Excel-style cascading column filtering engine for JavaScript and TypeScript.

This library provides only the filtering logic — no UI — so you can integrate it with React, Vue, Angular, Next.js, or plain JavaScript tables and dropdowns.

Why use this

  • Decoupled logic: Implement UI however you like; the engine handles filter logic.
  • Cascading filters: Filtering a column updates available options for downstream columns.
  • Type-safe: Built with TypeScript-first APIs.

Contents

  • Installation: add to your project
  • Quick Start: small example showing typical usage
  • API: methods and behavior
  • Development & Tests: how to run the test suite

Installation

  • npm: npm install cascading-column-filter
  • yarn: yarn add cascading-column-filter
  • pnpm: pnpm add cascading-column-filter

Quick Start (TypeScript)

import { createFilterEngine } from "cascading-column-filter";

type Row = { country: string; city: string; population: number };

const data: Row[] = [
  { country: "USA", city: "New York", population: 8_000_000 },
  { country: "USA", city: "Los Angeles", population: 4_000_000 },
  { country: "Canada", city: "Toronto", population: 2_700_000 },
];

const engine = createFilterEngine<Row>(data, ["country", "city"]);

// Set a filter on `country`
engine.setFilter("country", ["USA"]);

// Then get available options for `city` (only cities in USA remain)
const cityOptions = engine.getOptions("city");

// Get the filtered rows
const filtered = engine.getFilteredData();

API Reference

  • createFilterEngine<T>(data: T[], columns: (keyof T)[]) — Create a new engine instance for the provided data and column order.

The returned engine exposes these methods:

  • setFilter(column: keyof T, values: string[]) — Apply a filter on column using the provided list of string-selected values. Setting a filter for a column will drop filters for any columns that were applied after it (to preserve cascading correctness).

  • clearFilter(column: keyof T) — Remove the filter on column. This also clears any cached downstream options.

  • getOptions(column: keyof T): string[] — Compute and return the available option values for column given the current filters. If column itself is filtered, it returns the cached/original options.

  • getFilteredData(): T[] — Return the dataset after applying the current filters.

Notes on behavior:

  • Filters are stored and enforced in the order they are applied. Refiltering an earlier column automatically invalidates later filters.
  • All option values and filter comparisons use string coercion (values are handled as string) to keep the engine simple and predictable.

Development & Tests

Install dependencies and run tests:

npm install
npm test

Build (if available):

npm run build

Contributing

  • Please open issues for bugs or feature requests.
  • Pull requests are welcome — keep changes focused and add tests for new behavior.

README for the excel-filter-engine package. See source in src/createFilteringEngine.ts for the implementation details.