Added search transform
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.26.14",
|
||||
"version": "0.26.15",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -13,8 +13,8 @@ export function search(rows: any[], search: string, regex?: boolean, transform:
|
||||
if(!rows) return [];
|
||||
return rows.filter(r => {
|
||||
// Empty search
|
||||
const value = transform(r);
|
||||
if(!search) return true;
|
||||
const value = transform(r);
|
||||
// Regex search
|
||||
if(regex) {
|
||||
return !!Object.values(value).filter((v: any) => {
|
||||
@ -22,7 +22,7 @@ export function search(rows: any[], search: string, regex?: boolean, transform:
|
||||
catch { return false; }
|
||||
}).length
|
||||
} else {
|
||||
return logicTest(r, search);
|
||||
return logicTest(value, search);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user