@formatjs/intl-listformat 8.1.1 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +63 -63
- package/index.js +207 -206
- package/package.json +6 -6
- package/polyfill-force.js +6 -6
- package/polyfill.iife.js +2307 -3071
- package/polyfill.js +8 -8
- package/should-polyfill.js +11 -13
- package/supported-locales.generated.js +572 -572
package/polyfill.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import ListFormat from
|
|
2
|
-
import { shouldPolyfill } from
|
|
1
|
+
import ListFormat from "./index.js";
|
|
2
|
+
import { shouldPolyfill } from "./should-polyfill.js";
|
|
3
3
|
if (shouldPolyfill()) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
Object.defineProperty(Intl, "ListFormat", {
|
|
5
|
+
value: ListFormat,
|
|
6
|
+
writable: true,
|
|
7
|
+
enumerable: false,
|
|
8
|
+
configurable: true
|
|
9
|
+
});
|
|
10
10
|
}
|
package/should-polyfill.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { match } from
|
|
2
|
-
import { supportedLocales } from
|
|
1
|
+
import { match } from "@formatjs/intl-localematcher";
|
|
2
|
+
import { supportedLocales } from "./supported-locales.generated.js";
|
|
3
3
|
function supportedLocalesOf(locale) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
locales.length);
|
|
4
|
+
if (!locale) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
const locales = Array.isArray(locale) ? locale : [locale];
|
|
8
|
+
return Intl.ListFormat.supportedLocalesOf(locales).length === locales.length;
|
|
10
9
|
}
|
|
11
|
-
export function shouldPolyfill(locale) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
10
|
+
export function shouldPolyfill(locale = "en") {
|
|
11
|
+
if (!("ListFormat" in Intl) || !supportedLocalesOf(locale)) {
|
|
12
|
+
return locale ? match([locale], supportedLocales, "en") : undefined;
|
|
13
|
+
}
|
|
16
14
|
}
|