{"id":43774,"library":"rule-judgment","title":"rule-judgment","description":"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.","status":"active","version":"1.1.5","language":"javascript","source_language":"en","source_url":"https://github.com/kenote/rule-judgment","tags":["javascript","query","json","filter","typescript"],"install":[{"cmd":"npm install rule-judgment","lang":"bash","label":"npm"},{"cmd":"yarn add rule-judgment","lang":"bash","label":"yarn"},{"cmd":"pnpm add rule-judgment","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; used internally for deep object comparison and utilities","package":"lodash","optional":true}],"imports":[{"note":"Package supports both ESM and CJS; default export is preferred.","wrong":"const ruleJudgment = require('rule-judgment')","symbol":"default","correct":"import ruleJudgment from 'rule-judgment'"},{"note":"The package does not export named exports; only default export.","wrong":"import { ruleJudgment } from 'rule-judgment'","symbol":"ruleJudgment","correct":"import ruleJudgment from 'rule-judgment'"},{"note":"TypeScript types are included; import type for query parameter type.","wrong":"","symbol":"type","correct":"import type { MongoQuery } from 'rule-judgment'"}],"quickstart":{"code":"import ruleJudgment from 'rule-judgment';\n\n// Filter array of numbers\nconst lessThan5 = ruleJudgment({ $lt: 5 });\nconst numbers = [1, 3, 5, 7, 9];\nconsole.log(numbers.filter(lessThan5)); // [1, 3]\n\n// Filter array of objects\nconst adults = ruleJudgment({ age: { $gte: 18 } });\nconst people = [\n  { name: 'Alice', age: 25 },\n  { name: 'Bob', age: 16 },\n  { name: 'Charlie', age: 30 }\n];\nconsole.log(people.filter(adults));\n// [{ name: 'Alice', age: 25 }, { name: 'Charlie', age: 30 }]\n\n// Using context for variable substitution\nconst customFilter = ruleJudgment(\n  { username: '$__user' },\n  { context: { $__user: 'admin' } }\n);\nconst users = [\n  { username: 'admin', role: 'admin' },\n  { username: 'guest', role: 'guest' }\n];\nconsole.log(users.filter(customFilter)); // [{ username: 'admin', role: 'admin' }]","lang":"typescript","description":"Demonstrates basic usage with numbers, objects, and context variables using default import."},"warnings":[{"fix":"Use standard $in/$nin for clarity unless you specifically need array containment check.","message":"Operator names with underscore ($_in, $_nin) are undocumented in MongoDB but supported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider alternative libraries like sift.js if bundle size is critical.","message":"Lodash peer dependency may be heavy for browser projects.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use Array.prototype.filter() with the returned function.","message":"The function only returns filter function; does not provide direct helpers for find/findOne.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.5':17 'approach':68 'array':13 'browser':60 'compar':73 'compat':85 'data':53 'depend':23 'driver':77 'engin':9 'eq':36 'exist':45 'filter':11,54,71,93 'focus':81 'full':75 'function':67,72 'gt':34 'gte':35 'javascript':12,90 'json':92 'judgment':3 'librari':24 'lightweight':20 'like':7 'lodash':22 'lodash-depend':21 'lt':32 'lte':33 'mod':39 'mongodb':6,76,87 'mongodb-lik':5 'ne':37 'nin':41,43 'node.js':58 'object':15 'oper':31 'provid':18 'queri':8,88,91 'rang':29 'regex':38 'return':69 'rule':2 'rule-judg':1 'ship':61 'sift.js':79 'simplic':83 'size':44 'support':26 'syntax':89 'type':46,63 'typescript':62,94 'use':65 'version':16 'wide':28 'work':56","created_at":"2026-06-05T17:01:24.628767+00:00","updated_at":"2026-06-05T17:01:24.628767+00:00","problems":[{"fix":"npm install rule-judgment","cause":"Package not installed or missing from node_modules","error":"Cannot find module 'rule-judgment'"},{"fix":"import ruleJudgment from 'rule-judgment' (not { ruleJudgment })","cause":"Incorrect import style: attempting named import instead of default","error":"ruleJudgment is not a function"},{"fix":"npm install lodash","cause":"lodash not installed","error":"Missing peer dependency lodash"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/kenote/rule-judgment#readme","github":"https://github.com/kenote/rule-judgment","docs":null,"changelog":null,"pypi":null,"npm":"rule-judgment","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}