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

@rapiq/adapter-memory

v2.2.0

Published

Evaluate a rapiq query against in-memory objects & arrays by compiling the AST into plain functions.

Readme


Part of rapiq. Typed REST queries: build, transport, validate, execute. Same visitor-pattern surface as the SQL/TypeORM adapters, but the visitors compile the AST into plain functions (predicate, comparator, projector, slicer), so the same query filters a database and an array.

  • Compile once, run many: the AST is turned into closures up front; apply them across large collections without re-walking the tree.
  • 🧪 No database required: perfect for tests, mock servers, edge/serverless caches, or filtering data you already hold in memory.
  • 🤝 Backend-parity semantics: matches @rapiq/adapter-sql for positive operators and the complement law for negations (ne / nin / not* match null & missing), same-element binding for dotted paths over arrays.
  • 🧱 Whole-query or à la carte: applyQuery runs everything, or compile just the filters / sorts / fields / pagination on their own.
import { and, eq, gte } from '@rapiq/core';
import { compileFilters } from '@rapiq/adapter-memory';

const matches = compileFilters(and(eq('name', 'Peter'), gte('age', 18)));

matches({ name: 'Peter', age: 28 }); // true
matches({ name: 'Peter', age: 16 }); // false

Installation

npm install @rapiq/core @rapiq/adapter-memory

Usage

Apply a whole query to a collection:

import { defineQuery } from '@rapiq/core';
import { applyQuery } from '@rapiq/adapter-memory';

const query = defineQuery<User>({
    filters: { age: { $gte: 18 } },
    sorts: { name: 'ASC' },
    pagination: { limit: 10 },
    fields: ['id', 'name'],
});

const { data, total, pagination } = applyQuery(query, users);

Or compile individual parameters:

import {
    compileFields,
    compileFilters,
    compilePagination,
    compileSorts,
} from '@rapiq/adapter-memory';

const predicate = compileFilters(query.filters);    // (input) => boolean
const comparator = compileSorts(query.sorts);       // (a, b) => number
const projector = compileFields(query.fields);      // (input) => projected
const slicer = compilePagination(query.pagination); // (data) => data page

The rapiq family

| Package | Purpose | |---|---| | @rapiq/core | Query AST, typed build layer & schema system (the shared foundation) | | @rapiq/parser-simple | Parse plain object/array input (the "simple" dialect) | | @rapiq/parser-expression | Parse filter expressions like and(eq(name,'John'), gte(age,'18')) | | @rapiq/parser-mongo | Parse MongoDB-style filter documents like { age: { $gte: 18 } } | | @rapiq/codec-url | URL query-string transport codec | | @rapiq/adapter-sql | Dialect-agnostic SQL fragment adapter (pg, mysql, sqlite, mssql, oracle) | | @rapiq/adapter-typeorm | Apply a query to a TypeORM SelectQueryBuilder | | @rapiq/adapter-prisma | Serialize a query into a Prisma argument object | | @rapiq/adapter-drizzle | Serialize a query into a Drizzle relational query config | | @rapiq/adapter-memory | Evaluate a query against in-memory objects & arrays |

Documentation

To find out more, head over to the documentation.

License

Published under the MIT License.