@formatjs/intl-relativetimeformat
Advanced tools
Comparing version 9.2.3 to 9.3.0
@@ -9,4 +9,17 @@ function supportedLocalesOf(locale) { | ||
} | ||
function hasResolvedOptionsNumberingSystem(locale) { | ||
try { | ||
return ('numberingSystem' in | ||
new Intl.RelativeTimeFormat(locale || 'en', { | ||
numeric: 'auto', | ||
}).resolvedOptions()); | ||
} | ||
catch (_) { | ||
return false; | ||
} | ||
} | ||
export function shouldPolyfill(locale) { | ||
return !('RelativeTimeFormat' in Intl) || !supportedLocalesOf(locale); | ||
return (!('RelativeTimeFormat' in Intl) || | ||
!supportedLocalesOf(locale) || | ||
!hasResolvedOptionsNumberingSystem(locale)); | ||
} |
{ | ||
"name": "@formatjs/intl-relativetimeformat", | ||
"version": "9.2.3", | ||
"version": "9.3.0", | ||
"description": "Formats JavaScript dates to relative time strings.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -844,4 +844,13 @@ (function() { | ||
} | ||
function hasResolvedOptionsNumberingSystem(locale) { | ||
try { | ||
return "numberingSystem" in new Intl.RelativeTimeFormat(locale || "en", { | ||
numeric: "auto" | ||
}).resolvedOptions(); | ||
} catch (_) { | ||
return false; | ||
} | ||
} | ||
function shouldPolyfill(locale) { | ||
return !("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale); | ||
return !("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale) || !hasResolvedOptionsNumberingSystem(locale); | ||
} | ||
@@ -848,0 +857,0 @@ |
@@ -12,5 +12,18 @@ "use strict"; | ||
} | ||
function hasResolvedOptionsNumberingSystem(locale) { | ||
try { | ||
return ('numberingSystem' in | ||
new Intl.RelativeTimeFormat(locale || 'en', { | ||
numeric: 'auto', | ||
}).resolvedOptions()); | ||
} | ||
catch (_) { | ||
return false; | ||
} | ||
} | ||
function shouldPolyfill(locale) { | ||
return !('RelativeTimeFormat' in Intl) || !supportedLocalesOf(locale); | ||
return (!('RelativeTimeFormat' in Intl) || | ||
!supportedLocalesOf(locale) || | ||
!hasResolvedOptionsNumberingSystem(locale)); | ||
} | ||
exports.shouldPolyfill = shouldPolyfill; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2740267
13737