diff --git a/package.json b/package.json index 021b321..051e99c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/utils", - "version": "0.26.7", + "version": "0.26.8", "description": "Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/search.ts b/src/search.ts index a86a42a..223acba 100644 --- a/src/search.ts +++ b/src/search.ts @@ -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(target, key || prop[1]), prop[2], JSONAttemptParse(prop[3]));