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

tafs

v1.5.0

Published

A lightweight, vanilla JavaScript library for adding filtering and sorting capabilities to HTML tables with zero dependencies.

Readme

TaFS - Table Filter & Sort

A lightweight, vanilla JavaScript library for adding filtering and sorting capabilities to HTML tables with zero dependencies.

Features

  • Filter columns - Inline text filtering for each column
  • Multi-level sorting - Click column headers to sort (ascending, descending, or none)
  • Lightweight - Pure JavaScript with no dependencies
  • Easy integration - Just add a class to your table
  • Customizable - Override filter and sort functions per table, and add your own CSS

Installation

Direct Include

<script src="src/tafs.min.js"></script>
<link rel="stylesheet" href="src/tafs.css" />

Usage

Simply add the tafs class to any HTML table:

<table class="tafs">
    <tr>
        <th>Name</th>
        <th>Age</th>
        <th>Active</th>
    </tr>
    <tr>
        <td>Alice</td>
        <td>30</td>
        <td>true</td>
    </tr>
    <tr>
        <td>Bob</td>
        <td>25</td>
        <td>false</td>
    </tr>
</table>

The library automatically initializes on DOMContentLoaded for all tables with the tafs class.

API

For dynamic tables, you can

manually initialize:

tafs.init(document.querySelector('#my-table'));

sort:

tafs.sort(document.querySelector('#my-table'));

and filter:

tafs.filter(document.querySelector('#my-table'));

Customization

Custom Filter Function

Override the default filter function for a specific table:

const table = document.querySelector('#my-table');
table._tafsFilterFunction = (filterString) => {
    return (cell) => {
        // Custom filter logic
        return cell.textContent.startsWith(filterString);
    };
};
tafs.init(table);

Custom Icons, Placeholders and default sort

Set defaults for each concrete table:

const table = document.querySelector('#my-table');
table._tafsFilterPlaceholder = '🔎';      // Filter input placeholder
table._tafsSortNone = '⇅';                // No sort icon
table._tafsSortAsc = '↑';                 // Ascending sort icon
table._tafsSortDesc = '↓';                // Descending sort icon
table._tafsSortColumns = [2,1];           // Sort by 2nd, then by 1st column
table._tafsMulticolumnReversed = true     // Sort first by the last clickec column
table._tafsSortFunction = 'numberPrefix'  // Sort by default comparing a numeric prefix
tafs.init(table);

Or set defaults globally:

tafs.filterPlaceholder = 'Search...';
tafs.sortNone = '⇅';
tafs.sortAsc = '↑';
tafs.sortDesc = '↓';
tafs.sortColumns = [2,1];
tafs.multicolumnReversed =  true;
tafs.sortFunction = 'numberPrefix';

Or set defaults globally using just HTML:

<script src="tafs.js" filter-placeholder="Search..." sort-none="⇅" sort-asc="↑" sort-desc="↓" sort-columns="2 1" multicolumn-reversed="true" sort-function="numberPrefix"></script>

Custom Sort Functions

Override the default sort function globally or per table:

tafs.sortFunction = tafs.sortFunctions.numberPrefix;

const table = document.querySelector('#my-table');
table._tafsSortFunction = (a, b) => {
    // Custom sort logic (e.g., numeric sort)
    return parseFloat(a.textContent) - parseFloat(b.textContent);
};
tafs.init(table);

Or use registered sort functions by referring to them in each TH cell:

<head>
    <script>
        tafs.sortFunctions["myCustomSort"] = (a, b) => { ... };
    </script>
</head>
<body>
    <table>
        <tr>
            <th tafs-sort-function="myCustomSort"></th>
        </tr>
    </table>
</body>

Builtin registered sort functions include:

| Function | Description | |----------|-------------| | number | Parses full numbers (with optional decimal) and compares numerically | | numberPrefix | Parses numeric prefix from text and compares numerically | | bool | Compares boolean values (true/1 vs false/0, case-insensitive) | | date | Parses dates and compares chronologically | | datePrefix | Parses date prefix and compares chronologically | | stringCI | Case-insensitive string comparison | | stringCS | Case-sensitive string comparison | | localeStringCI | Case-insensitive locale-aware string comparison | | localeStringCS | Case-sensitive locale-aware string comparison (default) |

How It Works

  • Filtering: Hover over a column header to reveal a filter input. Type to filter rows based on that column's content. The default filter is case-insensitive and matches partial text.

  • Sorting: Click the sort icon in a column header to cycle through ascending, descending, and no sort. Multiple columns can be sorted simultaneously with priority given to the first clicked column by default.

  • Hidden Rows: Filtered rows receive the tafs-hidden class and are hidden via CSS.

Example

See https://lahteenmaki.net/tafs/example.html for an example.

License

MIT License - Copyright (c) 2025 Jyri-Matti Lähteenmäki

See LICENSE for details.