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

@maayanpolitzer/rules-engine

v1.0.3

Published

A lightweight, powerful and flexible rule evaluation engine designed for simple or complex logical operations. Perfect for projects requiring customizable validation, dynamic conditions, or decision trees based on json. inspired by MongoDB filters.

Readme

RuleEngine

A lightweight, powerful and flexible rule evaluation engine designed for simple or complex logical operations.
Perfect for projects requiring customizable validation, dynamic conditions, or decision trees based on json. inspired by MongoDB filters.

Features

  • Built-in operators: $eq, $gt, $gte, $lt, $lte, $ne, $and, $or, $in
  • Easy nesting of rules
  • Context-aware value resolution
  • Zero dependencies
  • 100% JavaScript (Node.js)

Installation

npm install @maayanpolitzer/rules-engine

Or clone the github repository for local development.


Usage


import { evaluateRules } from "@maayanpolitzer/rules-engine";       // ES Modules
// OR
const { evaluateRules } = require("@maayanpolitzer/rules-engine");  // CommonJS

const context = {
  user: {
    age: 25,
    role: "admin",
  },
};

const rules = [
  { $lt: ["{{user.age}}", 25] },          // false
  { $gte: ["{{user.age}}", 18] },         // true
  { $eq: ["{{user.role}}", "admin"] },    // won't be checked... The top level rules array perform as $OR operations by default.
];

const result = evaluateRules(rules, context);

console.log(result);    // true

Supported Operators

| Operator | Description | | :------- | :------------------------------------------- | | $eq | Checks if all values are strictly equal | | $gt | Checks if first value > second value | | $gte | Checks if first value >= second value | | $lt | Checks if first value < second value | | $lte | Checks if first value <= second value | | $ne | Checks if two values are not equal | | $and | Returns true if all rules are true | | $or | Returns true if at least one rule is true | | $in | Checks if a value is inside a provided array |


Want To Use ? You Must Know This:

By default, "evaluateRules" function can get a rule object or a rule objects array as arguments. In cases of multiple top level rules, the function perform an $OR operation which means that if one of the rules is true, the whole function returns true. If you want to return true only if all the top level rules array are true, wrap them with $AND.


Why use $AND over $EQ ?

Clone the Github Repo and run tests/performance/eq-vs-and test or

npm run benchmark

Important Notes

  • Context Values: To pull a dynamic value from the context, wrap it in double curly braces: Example: "{{user.age}}"
  • Nested Rules: You can nest rules inside one another for complex logic.
  • Error Handling: Invalid paths or unsupported operators will throw clear errors.

Development & Testing

Run all tests:

npm run test

Run performance benchmarks:

npm run benchmark

License

MIT License — Free for personal or commercial use.


Contributing

Feel free to open issues or submit pull requests!
Ideas for new operators, better performance, or features are welcome.