diff --git a/src/lib/relative-time-format/index.ts b/src/lib/relative-time-format/index.ts index 2382390..2da1bc9 100644 --- a/src/lib/relative-time-format/index.ts +++ b/src/lib/relative-time-format/index.ts @@ -19,10 +19,9 @@ import { formatNumber, formatNumberToParts } from '../number-format/index.js'; import { getRelativeTimeFormat, isRelativeTimeFormatSupported, - isRelativeTimeFormatToPartsSupported, } from './intl.js'; -export { isRelativeTimeFormatSupported, isRelativeTimeFormatToPartsSupported }; +export { isRelativeTimeFormatSupported }; /** * Formats a relative time with support for various [styles](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#style). @@ -103,7 +102,7 @@ function formatRelativeTimeToPartsFactory(): ( locales?: Locale | Locale[], options?: Intl.RelativeTimeFormatOptions, ) => Intl.RelativeTimeFormatPart[] { - if (!isRelativeTimeFormatToPartsSupported) { + if (!isRelativeTimeFormatSupported) { return (value, unit, locales, options) => { // In runtimes that don't support formatting to parts, the relative time // is formatted using the `Intl.NumberFormat` API instead. diff --git a/src/lib/relative-time-format/intl.ts b/src/lib/relative-time-format/intl.ts index a8d2ea7..dc58439 100644 --- a/src/lib/relative-time-format/intl.ts +++ b/src/lib/relative-time-format/intl.ts @@ -31,21 +31,6 @@ export const isRelativeTimeFormatSupported = (() => { } })(); -/** - * Whether the `Intl`, `Intl.RelativeTimeFormat`, and - * `Intl.RelativeTimeFormat.formatToParts` APIs are supported by the runtime. - */ -export const isRelativeTimeFormatToPartsSupported = (() => { - try { - return ( - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - typeof Intl.RelativeTimeFormat.prototype.formatToParts !== 'undefined' - ); - } catch (error) { - return false; - } -})(); - export const getRelativeTimeFormat = memoize(Intl.RelativeTimeFormat) as ( locales?: Locale | Locale[], options?: Intl.RelativeTimeFormatOptions, diff --git a/src/lib/relative-time-format/tests/unsupported-intl-api.spec.ts b/src/lib/relative-time-format/tests/unsupported-intl-api.spec.ts index 5ee9f91..6a5c51f 100644 --- a/src/lib/relative-time-format/tests/unsupported-intl-api.spec.ts +++ b/src/lib/relative-time-format/tests/unsupported-intl-api.spec.ts @@ -28,7 +28,6 @@ vi.mock('../intl', async () => { return { ...intl, isRelativeTimeFormatSupported: false, - isRelativeTimeFormatToPartsSupported: false, }; });