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

aka-query-lib

v1.0.1

Published

A Typescript library for query strings.

Readme

aka-query-lib

A Typescript library for query strings.

npm install aka-query-lib

Short Description

This library simplifies working with query strings, dynamically typechecks them and enforces that they match a query interface.

See an example at example/example.ts

Overview

The user must instantiate a QuerySpec class from the following:

  • A query interface, which lists all desired parameters to a query
  • A type environment, which defines at least all types in the interface By default a type environment for basic plain-old-data types is provided for the user. Using the QuerySpec, the user can parse query strings and turn querys back into strings.

Query Interfaces

A query interface is a list of 3/4 tuples of the form:

  1. The name of the parameter (must be unique)
  2. The type of the parameter (must exist in the associated type environment)
  3. The default value of the parameter
  4. A function which constrains the possible values of the parameter (OPTIONAL)

Query Type Environments

A query type environment is a Map from type names (strings) to a tuple defining the type T with two functions:

  1. string -> T: where we convert a string to T and typecheck, this can fail so the return type is an Option type.
  2. T -> string: we convert the type T into a string so it can be embedded into a query string.

Technical Properties of a QuerySpec

A query spec ensures the following properties:

  1. A query made from any query string is guaranteed to adhere to the spec
  2. Likewise a query string made from any query is guaranteed to adhere to the spec

Adherence to the spec is defined as:

  1. Returning zero or more parameters listed in the interface
  2. Excluding all non-conforming parameters

Parameters can be non-conforming if:

  1. They are missing from the query
  2. They fail their type check
  3. They fail their constraint check

In summary, the QuerySpec sanitizes all queries and forces adherence an interface and type environment