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

@tenjot/router

v1.0.0

Published

A tiny trie-based router compatible with URLPattern, forked from Hono's TrieRouter

Readme

@tenjot/router

A tiny, dependency-free trie-based router whose matching results are compatible with URLPattern.

This is a fork of Hono's TrieRouter.

Install

npm install @tenjot/router

Usage

import { createRouter } from "@tenjot/router";

const router = createRouter<string>();

router.add("GET", "/users/:id", "getUser");
router.add("GET", "/files/*", "getFile");

router.match("GET", "/users/42");
// => ["getUser", { id: "42" }]

router.match("GET", "/files/a/b.txt");
// => ["getFile", { 0: "a/b.txt" }]

router.match("POST", "/users/42");
// => null

The handler type T is up to you — it can be a function, a string, or any value.

API

createRouter<T>(): Router<T>

Creates a new router.

router.add(method: string, path: string, handler: T): void

Registers handler for method and path. Methods are arbitrary strings and are matched exactly.

Throws a TypeError if path contains the same named parameter twice (e.g. /:foo/:foo), just like URLPattern.

router.match(method: string, path: string): [T, Params] | null

Returns the matched handler and its parameters, or null if nothing matches. Params is Record<string, string>.

Patterns

| Pattern | Matches | Params | | -------------- | ----------------------- | --------------------------- | | /hello | /hello | {} | | /hello/:name | /hello/world | { name: "world" } | | /hello/* | /hello/, /hello/a/b | { 0: "" }, { 0: "a/b" } | | /a/*/b/* | /a/x/b/c | { 0: "x", 1: "c" } |

  • :name matches exactly one non-empty segment.
  • * matches any number of characters, including /. Unnamed wildcards get numeric keys in order (0, 1, …).
  • Params are the same as new URLPattern({ pathname }).exec({ pathname: path }).pathname.groups; the test suite checks this against the real URLPattern.

Priority

When several routes match, the one registered first wins — not the most specific one.

router.add("GET", "/api/abc", "abc");
router.add("GET", "/api/*", "fallback");

router.match("GET", "/api/abc"); // => ["abc", {}]
router.match("GET", "/api/def"); // => ["fallback", { 0: "def" }]

Register specific routes before fallbacks.

License

MIT

Based on Hono — Copyright (c) 2021 - present, Yusuke Wada and Hono contributors.