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

glove-sql

v0.2.0

Published

A zero-dependency, pure-JS Postgres-subset SQL engine. Tables built at runtime from ingested data; tokenizer + recursive-descent parser + evaluator covering joins, CTEs, set ops, subqueries, aggregates with FILTER, CASE, window functions, and a scalar-fun

Downloads

683

Readme

glove-sql

A zero-dependency, pure-JS Postgres-subset SQL engine. Tables are built at runtime from whatever data you ingest (no fixed schema), and a small engine — tokenizer → recursive-descent parser → evaluator — runs a defined subset of Postgres over them. The whole store serialises to bytes and back ("computation as a value"), with none of a real database's data-dir overhead.

It is the default backend for glove-scratchpad, extracted into its own package so the SQL surface can be tested and grown independently.

import { MemoryBackend } from "glove-sql";

const db = await MemoryBackend.create();
await db.exec(`CREATE TABLE "t" ("id" bigint, "name" text, "score" double precision)`);
await db.query(`INSERT INTO "t" VALUES ($1,$2,$3),($4,$5,$6)`, [1, "Ada", 9.5, 2, "Linus", 8.0]);

const { rows } = await db.query(
  `SELECT name, ROW_NUMBER() OVER (ORDER BY score DESC) AS rank FROM "t"`,
);
// → [{ name: "Ada", rank: 1 }, { name: "Linus", rank: 2 }]

const bytes = await db.dump();                     // serialise…
const restored = await MemoryBackend.create({ load: bytes }); // …and restore

What it covers

| Area | Supported | | --- | --- | | DDL | CREATE TABLE [IF NOT EXISTS], CREATE TABLE … AS <select>, DROP TABLE [IF EXISTS] … [CASCADE] | | DML | INSERT … VALUES (…), (…), DELETE … [WHERE …] (with $n params) | | Joins | INNER / LEFT / RIGHT / FULL / CROSS | | Clauses | WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, OFFSET (ORDER/GROUP by alias or ordinal), WITH (CTEs) | | Set ops | UNION / UNION ALL / INTERSECT / EXCEPT | | Subqueries | scalar (SELECT …), IN (SELECT …), EXISTS / NOT EXISTS — including correlated | | Expressions | CASE, BETWEEN, IN, IS [NOT] NULL, CAST(x AS t) / ::t, jsonb -> / ->> | | Aggregates | count / sum / avg / min / max, with FILTER (WHERE …) | | Windows | row_number, rank, dense_rank, aggregate OVER (PARTITION BY … ORDER BY …), lag / lead, first_value | | Functions | coalesce, nullif, round, floor, ceil, abs, sqrt, power, mod, greatest, least, lower, upper, length, trim, substr, replace, concat, strpos, … |

Anything outside the subset throws a clear error rather than silently mis-answering. For the long tail (recursive CTEs, GROUPING SETS, DISTINCT ON, explicit window frames, …) bring a real Postgres backend.

API

interface SqlBackend {
  query(sql: string, params?: unknown[]): Promise<SqlResult>;
  exec(sql: string): Promise<void>;
  dump(): Promise<Uint8Array>;
  close(): Promise<void>;
}
interface SqlResult { rows: Record<string, unknown>[]; fields: { name: string }[] }

class MemoryBackend implements SqlBackend {
  static create(opts?: { load?: Uint8Array }): Promise<MemoryBackend>;
}

License

MIT