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