Added includes / excludes to search
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/utils",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.26.7",
|
"version": "0.26.8",
|
||||||
"description": "Utility library",
|
"description": "Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -39,6 +39,8 @@ export function logicTest(target: object, condition: string): boolean {
|
|||||||
case '=':
|
case '=':
|
||||||
case '==': return a == b;
|
case '==': return a == b;
|
||||||
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;
|
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);
|
const and = p.split('&&').map(p => p.trim()).filter(p => !!p);
|
||||||
return and.filter(p => {
|
return and.filter(p => {
|
||||||
// Boolean operator
|
// Boolean operator
|
||||||
const prop = /(\S+)\s*(==?|!=|>=|>|<=|<)\s*(\S+)/g.exec(p);
|
const prop = /(\S+)\s*(==?|!=|\+|-|>=|>|<=|<)\s*(\S+)/g.exec(p);
|
||||||
if(prop) {
|
if(prop) {
|
||||||
const key = Object.keys(target).find(k => k.toLowerCase() == prop[1].toLowerCase());
|
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]));
|
return evalBoolean(dotNotation<any>(target, key || prop[1]), prop[2], JSONAttemptParse(prop[3]));
|
||||||
|
Reference in New Issue
Block a user