Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -0,0 +1,28 @@
const MAX_FORMATTER_CACHE_SIZE = 128;
export function getCachedFormatter<TFormatter>(
cache: Map<string, TFormatter>,
locale: string,
options: Record<string, unknown>,
create: (locale: string, options: Record<string, unknown>) => TFormatter
): TFormatter {
const key = `${locale}|${stableOptionsKey(options)}`;
const cached = cache.get(key);
if (cached) return cached;
const formatter = create(locale, options);
if (cache.size >= MAX_FORMATTER_CACHE_SIZE) {
const oldestKey = cache.keys().next().value;
if (oldestKey) cache.delete(oldestKey);
}
cache.set(key, formatter);
return formatter;
}
function stableOptionsKey(options: Record<string, unknown>): string {
return JSON.stringify(
Object.entries(options)
.filter(([, value]) => value !== undefined)
.sort(([left], [right]) => left.localeCompare(right))
);
}