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

@judo/idem

v0.1.7

Published

A powerful and expressive query language designed for filtering and manipulating data

Downloads

15

Readme

Idem Query Language

EPL-2.0 license

Overview

Idem is a powerful and expressive query language designed for filtering and manipulating data. This library provides a lightweight parser and evaluator for the Idem language, built with TypeScript and ANTLR4.

It is designed to be easily integrated into any JavaScript or TypeScript project, whether it's running in Node.js or the browser.

Features

  • Expressive Syntax: A clear and concise syntax for complex queries.
  • TypeScript Native: Fully written in TypeScript with type definitions included.
  • Cross-platform: Works in both Node.js and modern browsers.
  • Extensible: The ANTLR grammar is available for extension and integration with other tools.

Installation

You can install the library using your favorite package manager:

npm install idem
pnpm install idem
...

This library has antlr4ng as a peer dependency. You will need to install it alongside this library if you haven't already.

npm install antlr4ng
pnpm install antlr4ng
...

Usage

The primary way to use the library is by creating an evalExpr function using the createEvalExpr factory. This allows you to provide your own implementation for helper functions, such as date manipulation.

The createEvalExpr function requires an object with a dateFunctions property, which you can implement using a library like date-fns or with your own custom functions.

Here is a simple example:

import { createEvalExpr } from 'idem';
import { addDays, subDays, parseISO, differenceInDays, differenceInSeconds } from 'date-fns';

// Create a configured version of the evaluator
const evalExpr = createEvalExpr({ dateFunctions: { addDays, subDays, parseISO, differenceInDays, differenceInSeconds, } });

// The context object contains the data you want to query.
// The 'self' property is the root of the data.
const context = {
  self: { a: 1.5, b: 2, items: [1, 2, 3], },
};

// --- Example 1: Simple Arithmetic ---
const result1 = evalExpr('20 - 5');
console.log(result1); // Output: 15

// --- Example 2: Checking for an item in a list ---
const result2 = evalExpr('2 in self.items', context);
console.log(result2); // Output: true

The evalExpr function has an optional T generic type, but keep in mind, that whatever generic type we provide to the function, the result is never guaranteed!

The evalExpr function will always catch Errors and in such cases an undefined value will be returned.

Development

This project uses TypeScript, Vite for bundling, and Vitest for testing.

Project Structure

  • src/: Main source code of the library.
  • src/generated/: ANTLR-generated parser files from Idem.g4.
  • Idem.g4: The ANTLR grammar definition for the Idem language.
  • vite.config.ts: Vite build configuration.
  • vitest.config.ts: Vitest test configuration.

Available Scripts

The following scripts are available:

  • pnpm dev: Starts the Vite development server.
  • pnpm build: Compiles TypeScript and builds the library for production.
  • pnpm generate:antlr: Regenerates the ANTLR parser from Idem.g4.
  • pnpm test: Runs the test suite using Vitest.
  • pnpm coverage: Runs tests and generates a coverage report.
  • pnpm format: Formats, and fixes the code using Biome.
  • pnpm lint: Lints the code using Biome.

Contributing

Contributions are welcome! We thank the following contributors for their work on this project:

Please feel free to open an issue or submit a pull request.

License

This project is licensed under the Eclipse Public License 2.0. See the LICENSE.txt file.