@esmate/utils 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/locale.js +11 -8
  2. package/package.json +1 -1
package/dist/locale.js CHANGED
@@ -31,27 +31,30 @@ function getLanguageList(locale = "en-US") {
31
31
  type: "language"
32
32
  }).of(code);
33
33
  return {
34
- name: name || "",
34
+ name: name === code ? __WEBPACK_EXTERNAL_MODULE_iso_639_1_39eb3c8b__["default"].getName(code) : name,
35
35
  value: code
36
36
  };
37
- }).filter((lang)=>lang.name).sort((a, b)=>a.name.localeCompare(b.name));
37
+ }).sort((a, b)=>a.name.localeCompare(b.name));
38
38
  }
39
39
  function getCurrentLanguage() {
40
40
  return (navigator.language || "en-US").split("-")[0];
41
41
  }
42
42
  function getCountryList(locale = "en-US") {
43
- const codes = __WEBPACK_EXTERNAL_MODULE_iso_3166_1_0ebcf719__["default"].all().map((country)=>country.alpha2).sort((a, b)=>a.localeCompare(b));
44
- return codes.map((code)=>{
43
+ const countryList = __WEBPACK_EXTERNAL_MODULE_iso_3166_1_0ebcf719__["default"].all().map((country)=>({
44
+ name: country.country,
45
+ code: country.alpha2
46
+ }));
47
+ return countryList.map((country)=>{
45
48
  const name = new Intl.DisplayNames([
46
49
  locale
47
50
  ], {
48
51
  type: "region"
49
- }).of(code);
52
+ }).of(country.code);
50
53
  return {
51
- name: name || "",
52
- value: code
54
+ name: name === country.code ? country.name : name,
55
+ value: country.code
53
56
  };
54
- }).filter((country)=>country.name).sort((a, b)=>a.name.localeCompare(b.name));
57
+ }).sort((a, b)=>a.name.localeCompare(b.name));
55
58
  }
56
59
  function getCurrentCountry() {
57
60
  return (navigator.language || "en-US").split("-")[1];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@esmate/utils",
3
3
  "type": "module",
4
- "version": "1.0.5",
4
+ "version": "1.0.7",
5
5
  "description": "JavaScript/TypeScript utils, functions, and classes in one package.",
6
6
  "license": "MIT",
7
7
  "repository": {