mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
11 lines
270 B
TypeScript
11 lines
270 B
TypeScript
const cachedRegexes = new Map<string, RegExp>();
|
|
|
|
export function createCachedRegex(pattern: string) {
|
|
const cached = cachedRegexes.get(pattern);
|
|
if (cached) return cached;
|
|
|
|
const regex = new RegExp(pattern);
|
|
cachedRegexes.set(pattern, regex);
|
|
return regex;
|
|
}
|