Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/flo-bit.github.io. my personal website, w/ astro, svelte, tailwind, typescript, threlte flo-bit.dev
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}