Added search transform
Some checks failed
Build / Build NPM Project (push) Successful in 43s
Build / Publish Documentation (push) Failing after 4s
Build / Tag Version (push) Successful in 9s

This commit is contained in:
2025-07-22 14:16:18 -04:00
parent 9ec70430a5
commit c36af83918
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.26.14",
"version": "0.26.15",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -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);
}
});
}