@esmate/utils 1.0.7 → 1.1.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/dist/locale.d.ts CHANGED
@@ -3,23 +3,23 @@ export interface TimeZone {
3
3
  value: string;
4
4
  offset: string;
5
5
  }
6
- export declare function getTimeZoneList(locale?: string): TimeZone[];
6
+ export declare function getTimeZones(locale?: string): TimeZone[];
7
7
  export declare function getCurrentTimeZone(): string;
8
8
  interface Language {
9
9
  name: string;
10
10
  value: string;
11
11
  }
12
- export declare function getLanguageList(locale?: string): Language[];
12
+ export declare function getLanguages(locale?: string): Language[];
13
13
  export declare function getCurrentLanguage(): string;
14
14
  interface Country {
15
15
  name: string;
16
16
  value: string;
17
17
  }
18
- export declare function getCountryList(locale?: string): Country[];
18
+ export declare function getCountries(locale?: string): Country[];
19
19
  export declare function getCurrentCountry(): string;
20
20
  interface Currency {
21
21
  name: string;
22
22
  value: string;
23
23
  }
24
- export declare function getCurrencyList(locale?: string): Currency[];
24
+ export declare function getCurrencies(locale?: string): Currency[];
25
25
  export {};
package/dist/locale.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_iso_3166_1_0ebcf719__ from "iso-3166-1";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE_iso_639_1_39eb3c8b__ from "iso-639-1";
3
- function getTimeZoneList(locale = "en-US") {
3
+ function getTimeZones(locale = "en-US") {
4
4
  const timeZones = Intl.supportedValuesOf("timeZone");
5
5
  const getOffset = (timeZone)=>{
6
6
  const offset = new Intl.DateTimeFormat(locale, {
@@ -22,7 +22,7 @@ function getTimeZoneList(locale = "en-US") {
22
22
  function getCurrentTimeZone() {
23
23
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
24
24
  }
25
- function getLanguageList(locale = "en-US") {
25
+ function getLanguages(locale = "en-US") {
26
26
  const codes = __WEBPACK_EXTERNAL_MODULE_iso_639_1_39eb3c8b__["default"].getAllCodes().sort((a, b)=>a.localeCompare(b));
27
27
  return codes.map((code)=>{
28
28
  const name = new Intl.DisplayNames([
@@ -39,7 +39,7 @@ function getLanguageList(locale = "en-US") {
39
39
  function getCurrentLanguage() {
40
40
  return (navigator.language || "en-US").split("-")[0];
41
41
  }
42
- function getCountryList(locale = "en-US") {
42
+ function getCountries(locale = "en-US") {
43
43
  const countryList = __WEBPACK_EXTERNAL_MODULE_iso_3166_1_0ebcf719__["default"].all().map((country)=>({
44
44
  name: country.country,
45
45
  code: country.alpha2
@@ -59,7 +59,7 @@ function getCountryList(locale = "en-US") {
59
59
  function getCurrentCountry() {
60
60
  return (navigator.language || "en-US").split("-")[1];
61
61
  }
62
- function getCurrencyList(locale = "en-US") {
62
+ function getCurrencies(locale = "en-US") {
63
63
  const codes = Intl.supportedValuesOf("currency");
64
64
  return codes.map((code)=>{
65
65
  const name = new Intl.DisplayNames([
@@ -74,4 +74,4 @@ function getCurrencyList(locale = "en-US") {
74
74
  };
75
75
  }).sort((a, b)=>a.name.localeCompare(b.name));
76
76
  }
77
- export { getCountryList, getCurrencyList, getCurrentCountry, getCurrentLanguage, getCurrentTimeZone, getLanguageList, getTimeZoneList };
77
+ export { getCountries, getCurrencies, getCurrentCountry, getCurrentLanguage, getCurrentTimeZone, getLanguages, getTimeZones };
@@ -0,0 +1 @@
1
+ export * from "es-toolkit";
@@ -0,0 +1 @@
1
+ export * from "es-toolkit";
package/dist/text.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { Configuration, Locale } from "typopo";
2
+ /**
3
+ * Formats a string to be used as a title.
4
+ * @param str The string to format.
5
+ * @param options The options to use.
6
+ * @returns The formatted string.
7
+ */
8
+ export declare function titleize(str: string, options?: {
9
+ locale?: "en";
10
+ special?: string[];
11
+ }): string;
12
+ /**
13
+ * Fixes typos in a string using typopo.
14
+ * @param str The string to fix.
15
+ * @param options The options to use.
16
+ * @returns The fixed string.
17
+ */
18
+ export declare function fixTypos(str: string, options?: Configuration & {
19
+ locale?: Locale;
20
+ }): string;
package/dist/text.js ADDED
@@ -0,0 +1,13 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_es_toolkit_string_d01e99ad__ from "es-toolkit/string";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_title__ from "title";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_typopo__ from "typopo";
4
+ function titleize(str, options) {
5
+ str = str.replace(/\s+/g, " ");
6
+ if (options?.locale === "en") return (0, __WEBPACK_EXTERNAL_MODULE_title__["default"])(str, options);
7
+ const specialWordsLower = options?.special?.map((s)=>s.toLocaleLowerCase());
8
+ return str.split(" ").map((word)=>specialWordsLower?.includes(word.toLocaleLowerCase()) ? word : (0, __WEBPACK_EXTERNAL_MODULE_es_toolkit_string_d01e99ad__.capitalize)(word)).join(" ");
9
+ }
10
+ function fixTypos(str, options) {
11
+ return __WEBPACK_EXTERNAL_MODULE_typopo__["default"].fixTypos(str, options?.locale, options).replace(/\u00A0/g, " ").trim();
12
+ }
13
+ export { fixTypos, titleize };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@esmate/utils",
3
3
  "type": "module",
4
- "version": "1.0.7",
4
+ "version": "1.1.0",
5
5
  "description": "JavaScript/TypeScript utils, functions, and classes in one package.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -32,33 +32,33 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@types/typopo": "^2.5.4",
35
+ "es-toolkit": "^1.43.0",
35
36
  "iso-3166-1": "^2.1.1",
36
37
  "iso-639-1": "^3.1.5",
37
38
  "tiny-invariant": "^1.3.3",
38
39
  "title": "^4.0.1",
39
- "typopo": "^2.7.1"
40
+ "typopo": "^2.8.0"
40
41
  },
41
42
  "devDependencies": {
42
- "@esmate/eslint": "^1.1.2",
43
- "@esmate/prettier": "^1.0.5",
43
+ "@esmate/eslint": "^1.2.2",
44
+ "@esmate/prettier": "^1.0.6",
44
45
  "@rslib/core": "^0.7.1",
45
46
  "@types/fs-extra": "^11.0.4",
46
- "@types/node": "^22.18.7",
47
- "@types/react": "^18.3.24",
47
+ "@types/node": "^22.19.3",
48
+ "@types/react": "^18.3.27",
48
49
  "@types/react-dom": "^18.3.7",
49
- "eslint": "^9.36.0",
50
- "fs-extra": "^11.3.2",
50
+ "eslint": "^9.39.2",
51
+ "fs-extra": "^11.3.3",
51
52
  "globby": "^14.1.0",
52
- "prettier": "^3.6.2",
53
+ "prettier": "^3.7.4",
53
54
  "react": "^18.3.1",
54
55
  "react-dom": "^18.3.1",
55
- "tsx": "^4.20.6",
56
- "typescript": "^5.9.2"
56
+ "tsx": "^4.21.0",
57
+ "typescript": "^5.9.3"
57
58
  },
58
59
  "scripts": {
59
60
  "build": "tsx export.ts && rslib build",
60
61
  "dev": "rslib build --watch",
61
- "start": "astro preview",
62
62
  "fix": "prettier --write . && eslint --fix .",
63
63
  "check": "tsc && prettier --check . && eslint ."
64
64
  }