Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/ui-kit. 🦊 fox ui, svelte 5 and tailwind 4 flo-bit.dev/ui-kit
Something went wrong. Try again.
12345678910111213// keep a cache of formatter per locale, to avoid re-creating them (GC)const formatters = new Map<string, Intl.RelativeTimeFormat>();
// get the Intl.RelativeTimeFormat formatter for the given localeexport function getFormatter(locale: string) { if (formatters.has(locale)) { return formatters.get(locale)!; } const formatter = new Intl.RelativeTimeFormat(locale, { numeric: 'always', style: 'narrow' }); formatters.set(locale, formatter); return formatter;}