Registry / database / rule-judgment

rule-judgment

JSON →
library1.1.5jsnpmunverified

A MongoDB-like query engine for filtering JavaScript arrays and objects. Version 1.1.5 provides a lightweight, lodash-dependent library that supports a wide range of operators ($lt, $lte, $gt, $gte, $eq, $ne, $regex, $mod, $in, $nin, $_in, $_nin, $size, $exists, $type, $where, $and, $or, $not, $nor) for data filtering. It works in Node.js and browsers, ships TypeScript types, and uses a functional approach (returns a filter function). Compared to full MongoDB drivers or sift.js, it focuses on simplicity and compatibility with MongoDB query syntax.

npm install rule-judgment
INSTALL
IMPORT
SIG · RULE-JUDGMENT
R
rule-judgment
databasejavascriptv1.1.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import ruleJudgment from 'rule-judgment'
✗ const ruleJudgment = require('rule-judgment')
Package supports both ESM and CJS; default export is preferred.
ruleJudgment
✓ import ruleJudgment from 'rule-judgment'
✗ import { ruleJudgment } from 'rule-judgment'
The package does not export named exports; only default export.
type
✓ import type { MongoQuery } from 'rule-judgment'
TypeScript types are included; import type for query parameter type.

Demonstrates basic usage with numbers, objects, and context variables using default import.

import ruleJudgment from 'rule-judgment'; // Filter array of numbers const lessThan5 = ruleJudgment({ $lt: 5 }); const numbers = [1, 3, 5, 7, 9]; console.log(numbers.filter(lessThan5)); // [1, 3] // Filter array of objects const adults = ruleJudgment({ age: { $gte: 18 } }); const people = [ { name: 'Alice', age: 25 }, { name: 'Bob', age: 16 }, { name: 'Charlie', age: 30 } ]; console.log(people.filter(adults)); // [{ name: 'Alice', age: 25 }, { name: 'Charlie', age: 30 }] // Using context for variable substitution const customFilter = ruleJudgment( { username: '$__user' }, { context: { $__user: 'admin' } } ); const users = [ { username: 'admin', role: 'admin' }, { username: 'guest', role: 'guest' } ]; console.log(users.filter(customFilter)); // [{ username: 'admin', role: 'admin' }]
Debug
Known issues
gotchaOperator names with underscore ($_in, $_nin) are undocumented in MongoDB but supported.
fix
Use standard $in/$nin for clarity unless you specifically need array containment check.
affects: >=1.0.0
deprecatedLodash peer dependency may be heavy for browser projects.
fix
Consider alternative libraries like sift.js if bundle size is critical.
affects: >=1.0.0
gotchaThe function only returns filter function; does not provide direct helpers for find/findOne.
fix
Use Array.prototype.filter() with the returned function.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'rule-judgment'
Package not installed or missing from node_modules
fix
npm install rule-judgment
ruleJudgment is not a function
Incorrect import style: attempting named import instead of default
fix
import ruleJudgment from 'rule-judgment' (not { ruleJudgment })
Missing peer dependency lodash
lodash not installed
fix
npm install lodash
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies
lodashoptionalPeer dependency; used internally for deep object comparison and utilities
Agent activity
8 hits · last 30 days
node
6
Resources
rule-judgment — npm install rule-judgment · libregistry