Added includes / excludes to search
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.26.7",
|
||||
"version": "0.26.8",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -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]));
|
||||
|
Reference in New Issue
Block a user