Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(locales = [])
{
// Convert `locales` to an array.
if (typeof locales === 'string') {
locales = [locales]
}
// Choose the most appropriate locale
// (one of the previously added ones)
// based on the list of preferred `locales` supplied by the user.
this.locale = chooseLocale(
locales.concat(RelativeTimeFormat.getDefaultLocale()),
getLocaleData
)
// Use `Intl.NumberFormat` for formatting numbers (when available).
if (typeof Intl !== 'undefined' && Intl.NumberFormat) {
this.numberFormat = new Intl.NumberFormat(this.locale)
}
// Cache `Intl.RelativeTimeFormat` instance.
this.relativeTimeFormatCache = new Cache()
}