Skip to content

Commit

Permalink
refactor: move regex instance out of loop (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
wise-introvert committed Jan 23, 2023
1 parent e5f0a1b commit 0c517b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export const getkeys = (obj: any, prefix?: any): any => {
export const search = <T = any>(obj: T, query: string): any => {
const keys: string[] = getkeys(obj);

const regex: RegExp = new RegExp(`\\.${query}$`, "gi");
const searchKeys: string[] = keys.filter((field: string): boolean => {
const regex: RegExp = new RegExp(`\\.${query}$`, "gi");
return regex.test(field);
});

Expand Down

0 comments on commit 0c517b1

Please sign in to comment.