Added includes / excludes to search
Some checks failed
Build / Build NPM Project (push) Successful in 1m4s
Build / Publish Documentation (push) Failing after 15s
Build / Tag Version (push) Successful in 23s

This commit is contained in:
2025-07-21 18:15:21 -04:00
parent 1ab8e6424b
commit fd95c0c697
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.26.7",
"version": "0.26.8",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -39,6 +39,8 @@ export function logicTest(target: object, condition: string): boolean {
case '=':
case '==': return a == b;
case '!=': return a != b;
case '+': return a.includes(b);
case '-': return !a.includes(b);
case '>': return a > b;
case '>=': return a >= b;
case '<': return a < b;
@ -53,7 +55,7 @@ export function logicTest(target: object, condition: string): boolean {
const and = p.split('&&').map(p => p.trim()).filter(p => !!p);
return and.filter(p => {
// Boolean operator
const prop = /(\S+)\s*(==?|!=|>=|>|<=|<)\s*(\S+)/g.exec(p);
const prop = /(\S+)\s*(==?|!=|\+|-|>=|>|<=|<)\s*(\S+)/g.exec(p);
if(prop) {
const key = Object.keys(target).find(k => k.toLowerCase() == prop[1].toLowerCase());
return evalBoolean(dotNotation<any>(target, key || prop[1]), prop[2], JSONAttemptParse(prop[3]));