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 🙏

© 2025 – Pkg Stats / Ryan Hefner

squirreling

v0.6.0

Published

Squirreling SQL Engine

Downloads

3,430

Readme

Squirreling SQL Engine

squirreling engine

npm downloads minzipped workflow status mit license coverage dependencies

Squirreling is a streaming async SQL engine for JavaScript. It is designed to provide efficient streaming of results from pluggable backends for highly efficient retrieval of data for browser applications.

Features

  • Lightweight and fast
  • Easy to integrate with frontend applications
  • Lets you move query execution closer to your users
  • Supports standard SQL queries
  • Async streaming for large datasets
  • Constant memory usage for simple queries with LIMIT
  • Robust error handling and validation designed for LLM tool use
  • In-memory data option for simple use cases
  • Late materialization for efficiency
  • Select only

Usage

Squirreling returns an async generator, allowing you to process rows one at a time without loading everything into memory.

import { executeSql } from 'squirreling'

// In-memory table
const users = [
  { id: 1, name: 'Alice', active: true },
  { id: 2, name: 'Bob', active: false },
  { id: 3, name: 'Charlie', active: true },
  // ...more rows
]

interface AsyncRow {
  columns: string[]
  cells: Record<string, AsyncCell>
}
type AsyncCell = () => Promise<SqlPrimitive>

// Returns an async iterable of rows with async cells
const asyncRows: AsyncIterable<AsyncRow> = executeSql({
  tables: { users },
  query: 'SELECT count(*) as cnt FROM users WHERE active = TRUE LIMIT 10',
})

// Process rows as they arrive (streaming)
for await (const { cnt } of asyncRows) {
  console.log('Count', await cnt())
}

There is an exported helper function collect to gather all rows into an array if needed:

import { collect, executeSql } from 'squirreling'

// Collect all rows and cells into a materialized array
const allUsers: Record<string, SqlPrimitive>[] = await collect(executeSql({
  tables: { users },
  query: 'SELECT * FROM users',
}))
console.log(allUsers)

Supported SQL Features

  • SELECT statements with WHERE, ORDER BY, LIMIT, OFFSET
  • Subqueries in SELECT, FROM, and WHERE clauses
  • JOIN operations: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN
  • GROUP BY and HAVING clauses
  • Aggregate functions: COUNT, SUM, AVG, MIN, MAX, JSON_ARRAYAGG
  • String functions: CONCAT, SUBSTRING, LENGTH, UPPER, LOWER
  • Math functions: ABS, CEIL, FLOOR, ROUND, MOD, RAND, RANDOM, LN, LOG10, EXP, POWER, SQRT, SIN, COS, TAN, COT, ASIN, ACOS, ATAN, ATAN2, DEGREES, RADIANS, PI
  • Date functions: CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, INTERVAL
  • Json functions: JSON_VALUE, JSON_QUERY, JSON_OBJECT
  • Basic expressions and arithmetic operations