⚡ perf(runner): better regex match search
started using flags instead of any-character expressions between characters
This commit is contained in:
@@ -39,11 +39,17 @@ const plugins = new Set<Runner.Plugin>();
|
||||
|
||||
export function close() { instance?.close(); }
|
||||
|
||||
export function regExMatch(search: string, item: string): boolean {
|
||||
export function regExMatch(search: string, item: (string|number)): boolean {
|
||||
search = search.replace(/[\\^$.*?()[\]{}|]/g, "\\$&");
|
||||
|
||||
if(typeof item === "number")
|
||||
return new RegExp(`${search.split('').map(c =>
|
||||
`.*${c}.*`).join('')}`,
|
||||
"g").test(item.toString());
|
||||
|
||||
return new RegExp(`${search.split('').map(c =>
|
||||
`.*(${c.toLowerCase()}|${c.toUpperCase()}).*`).join('')}`
|
||||
).test(item);
|
||||
`.*${c}.*`).join('')}`,
|
||||
"gi").test(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user