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

@osqd/jql

v0.1.2

Published

JSON Query Language — one MongoDB-style query document for every place the OSQD projects filter data, with a zero-dependency TypeScript engine that compiles each query once into a plain predicate.

Readme

JQL — JSON Query Language

One query language for every place the OSQD projects filter data, and a zero-dependency TypeScript engine that runs it.

A query is a JSON document that means the same thing everywhere it is sent — and a query that is not valid JQL is refused with the reason, never run as something that looks like it worked.

npm install @osqd/jql

Node 20 or newer, and TypeScript 5.4 or newer if you use the types: the published declarations use NoInfer, which TypeScript 5.4 added. Nothing else is required — the package has no runtime dependencies.

import "@osqd/jql/global";

const arr = [{ id: 1, tags: ["a"] }, { id: 2, tags: ["b"] }];
arr.jqlSearch({ id: 2 });                                // { id: 2, tags: ["b"] }
Array.jqlSearch(arr, { tags: { $in: ["a", "c"] } });     // any array, iterable, Set or Map
arr.jqlQuery({ where: { id: { $gt: 0 } }, sort: { id: -1 }, limit: 1 });

Contents

What it is

  • A standard. The specification defines the language independently of this code, and conformance/cases.json states it as JSON documents, JSON queries and the answers any implementation must give.
  • A library. Compile a query once into a plain predicate, or use find, filter, count, search, group and friends over arrays, iterables, Maps, Sets, plain objects — and, with the *Async helpers, over a log or a cursor that arrives over time.
  • Explainable. explain(query, item) says which clause decided it, with the values it read; canonical and fingerprint give a saved filter one shape and one short name.
  • Typed. Query<T> checks paths, value types and which operators fit each field, so a typo is a compile error rather than a filter that matches nothing.
  • Fast. Within about 1.1–1.5× of a hand-written loop for most queries, faster than one for top-k sorting, and 2–130× faster than the query-document matchers commonly used in JavaScript.
  • A search box, both ways. @osqd/jql/text turns status:open total:>100 has:rule at:>-1h into a JQL document, and toText turns a stored one back into something somebody can edit.
  • A shell command. jql --text 'level:error' app.jsonl filters JSON lines, with --sort, --group, --omit and --explain.
  • Pushable. plan(query, capabilities) splits a query into the part a store can answer and the part that stays here, with @osqd/jql/mongo as the first target.
  • Extensible where it has to be. A project can add operators of its own, named $x… so a query that needs more than a standard engine says so.

Why this design

| Choice | Instead of | Because | | --- | --- | --- | | Queries are JSON | a text language | data can be stored, sent, generated and validated; text can only be typed | | The conventional operator names | a vocabulary of our own | $gt and $elemMatch carry their meaning with them; where this language differs, the specification says so where the operator is defined | | Refuse anything not understood | ignore it | an ignored $gtt is a filter that silently filters nothing | | Compile to closures | generate code | generated code is blocked by any real Content-Security-Policy | | Array methods behind an import | patch on load | changing built-ins is the application's decision | | A conformance suite in JSON | tests only in TypeScript | a standard other languages can check themselves against | | { "$field": "other" } | an expression language ($expr) | comparing two fields needs a path, not a language | | Relative dates in the query | an instant computed before sending | a saved filter that means "the last hour" goes on meaning it |

More in Decisions.

License

OSQD Non-Resale License — see LICENSE.