A lightweight JavaScript library (v0.0.11, stable, infrequent updates) for comparing values using MongoDB-style operators. It provides a simple `compare(value, operator)` function supporting comparison operators ($eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $size, $nsize, $regex, $nregex) and logical operators ($and, $or, $all, $not). Key differentiator: JSON-defined operator objects, making it suitable for rule engines or configurable validation. Minimal dependencies, tiny install size.
npm install easy-compareNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of compare() with various operators: $gte, $and, $in, $regex.
Wrap multiple operators in $and or $or, e.g., { $and: { $gt: 5, $lt: 10 } }.Consider using alternatives like 'sift' or MongoDB's own query engine if acting as a dependency.
Ensure the value is an array for $in/$nin, or use $regex for string containment.
Use easy.compare(value, operator).
Use strict equality checks separately if needed.
Use easy.compare(value, operator) instead of easy(value, operator).
Use default import: import easy from 'easy-compare'; then easy.compare().
Wrap multiple operators: { $and: { $gt: 5, $lt: 10 } }.Use import easy from 'easy-compare'; or switch to CommonJS.
No dependency data recorded yet.