utilitify-core 1.0.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.
Files changed (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +338 -0
  3. package/dist/async.cjs +25 -0
  4. package/dist/async.cjs.map +1 -0
  5. package/dist/async.d.cts +104 -0
  6. package/dist/async.d.ts +104 -0
  7. package/dist/async.js +4 -0
  8. package/dist/async.js.map +1 -0
  9. package/dist/chunk-2ICNRTSN.cjs +346 -0
  10. package/dist/chunk-2ICNRTSN.cjs.map +1 -0
  11. package/dist/chunk-3DPF72DY.js +170 -0
  12. package/dist/chunk-3DPF72DY.js.map +1 -0
  13. package/dist/chunk-4CV4JOE5.js +24 -0
  14. package/dist/chunk-4CV4JOE5.js.map +1 -0
  15. package/dist/chunk-4SLYNSLH.cjs +783 -0
  16. package/dist/chunk-4SLYNSLH.cjs.map +1 -0
  17. package/dist/chunk-5WP7DWCG.js +1285 -0
  18. package/dist/chunk-5WP7DWCG.js.map +1 -0
  19. package/dist/chunk-BMQ6YPKV.js +876 -0
  20. package/dist/chunk-BMQ6YPKV.js.map +1 -0
  21. package/dist/chunk-BZCMWUKS.cjs +479 -0
  22. package/dist/chunk-BZCMWUKS.cjs.map +1 -0
  23. package/dist/chunk-C5R744DY.cjs +173 -0
  24. package/dist/chunk-C5R744DY.cjs.map +1 -0
  25. package/dist/chunk-C75J62CV.cjs +913 -0
  26. package/dist/chunk-C75J62CV.cjs.map +1 -0
  27. package/dist/chunk-CZLDE2OZ.cjs +28 -0
  28. package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
  29. package/dist/chunk-DSMB6AF6.cjs +193 -0
  30. package/dist/chunk-DSMB6AF6.cjs.map +1 -0
  31. package/dist/chunk-ETWGPOPY.js +426 -0
  32. package/dist/chunk-ETWGPOPY.js.map +1 -0
  33. package/dist/chunk-FQBPVN63.cjs +403 -0
  34. package/dist/chunk-FQBPVN63.cjs.map +1 -0
  35. package/dist/chunk-G4GYQGTW.cjs +178 -0
  36. package/dist/chunk-G4GYQGTW.cjs.map +1 -0
  37. package/dist/chunk-GFDMZDMI.js +486 -0
  38. package/dist/chunk-GFDMZDMI.js.map +1 -0
  39. package/dist/chunk-HOTOYIPB.js +171 -0
  40. package/dist/chunk-HOTOYIPB.js.map +1 -0
  41. package/dist/chunk-HYADH4ZX.js +176 -0
  42. package/dist/chunk-HYADH4ZX.js.map +1 -0
  43. package/dist/chunk-JBN7C5WE.js +255 -0
  44. package/dist/chunk-JBN7C5WE.js.map +1 -0
  45. package/dist/chunk-JNCTPFTD.cjs +25 -0
  46. package/dist/chunk-JNCTPFTD.cjs.map +1 -0
  47. package/dist/chunk-N3BH3BV7.js +21 -0
  48. package/dist/chunk-N3BH3BV7.js.map +1 -0
  49. package/dist/chunk-NFPGAVRQ.js +749 -0
  50. package/dist/chunk-NFPGAVRQ.js.map +1 -0
  51. package/dist/chunk-OFFRGRBN.cjs +1332 -0
  52. package/dist/chunk-OFFRGRBN.cjs.map +1 -0
  53. package/dist/chunk-OZLKYIZL.cjs +490 -0
  54. package/dist/chunk-OZLKYIZL.cjs.map +1 -0
  55. package/dist/chunk-P3NUK46X.js +145 -0
  56. package/dist/chunk-P3NUK46X.js.map +1 -0
  57. package/dist/chunk-P7P2B7ZI.cjs +429 -0
  58. package/dist/chunk-P7P2B7ZI.cjs.map +1 -0
  59. package/dist/chunk-PB6SKSJN.cjs +150 -0
  60. package/dist/chunk-PB6SKSJN.cjs.map +1 -0
  61. package/dist/chunk-R3IXCJR7.js +378 -0
  62. package/dist/chunk-R3IXCJR7.js.map +1 -0
  63. package/dist/chunk-SD6P3WEJ.js +324 -0
  64. package/dist/chunk-SD6P3WEJ.js.map +1 -0
  65. package/dist/chunk-YSCHP26P.js +451 -0
  66. package/dist/chunk-YSCHP26P.js.map +1 -0
  67. package/dist/chunk-ZLMPRPCY.cjs +274 -0
  68. package/dist/chunk-ZLMPRPCY.cjs.map +1 -0
  69. package/dist/common-CBDYNJeh.d.cts +48 -0
  70. package/dist/common-CBDYNJeh.d.ts +48 -0
  71. package/dist/constants.cjs +42 -0
  72. package/dist/constants.cjs.map +1 -0
  73. package/dist/constants.d.cts +60 -0
  74. package/dist/constants.d.ts +60 -0
  75. package/dist/constants.js +5 -0
  76. package/dist/constants.js.map +1 -0
  77. package/dist/country/index.cjs +154 -0
  78. package/dist/country/index.cjs.map +1 -0
  79. package/dist/country/index.d.cts +1 -0
  80. package/dist/country/index.d.ts +1 -0
  81. package/dist/country/index.js +5 -0
  82. package/dist/country/index.js.map +1 -0
  83. package/dist/date/index.cjs +117 -0
  84. package/dist/date/index.cjs.map +1 -0
  85. package/dist/date/index.d.cts +283 -0
  86. package/dist/date/index.d.ts +283 -0
  87. package/dist/date/index.js +4 -0
  88. package/dist/date/index.js.map +1 -0
  89. package/dist/environment/index.cjs +73 -0
  90. package/dist/environment/index.cjs.map +1 -0
  91. package/dist/environment/index.d.cts +127 -0
  92. package/dist/environment/index.d.ts +127 -0
  93. package/dist/environment/index.js +4 -0
  94. package/dist/environment/index.js.map +1 -0
  95. package/dist/form/index.cjs +81 -0
  96. package/dist/form/index.cjs.map +1 -0
  97. package/dist/form/index.d.cts +227 -0
  98. package/dist/form/index.d.ts +227 -0
  99. package/dist/form/index.js +4 -0
  100. package/dist/form/index.js.map +1 -0
  101. package/dist/i18n.cjs +37 -0
  102. package/dist/i18n.cjs.map +1 -0
  103. package/dist/i18n.d.cts +102 -0
  104. package/dist/i18n.d.ts +102 -0
  105. package/dist/i18n.js +4 -0
  106. package/dist/i18n.js.map +1 -0
  107. package/dist/index-BXBmBHyL.d.ts +718 -0
  108. package/dist/index-BYsUCP3u.d.cts +718 -0
  109. package/dist/index-Cl26FrAZ.d.cts +362 -0
  110. package/dist/index-Cl26FrAZ.d.ts +362 -0
  111. package/dist/index.cjs +1265 -0
  112. package/dist/index.cjs.map +1 -0
  113. package/dist/index.d.cts +205 -0
  114. package/dist/index.d.ts +205 -0
  115. package/dist/index.js +277 -0
  116. package/dist/index.js.map +1 -0
  117. package/dist/schema.cjs +13 -0
  118. package/dist/schema.cjs.map +1 -0
  119. package/dist/schema.d.cts +84 -0
  120. package/dist/schema.d.ts +84 -0
  121. package/dist/schema.js +4 -0
  122. package/dist/schema.js.map +1 -0
  123. package/dist/security/index.cjs +94 -0
  124. package/dist/security/index.cjs.map +1 -0
  125. package/dist/security/index.d.cts +216 -0
  126. package/dist/security/index.d.ts +216 -0
  127. package/dist/security/index.js +5 -0
  128. package/dist/security/index.js.map +1 -0
  129. package/dist/string/index.cjs +153 -0
  130. package/dist/string/index.cjs.map +1 -0
  131. package/dist/string/index.d.cts +471 -0
  132. package/dist/string/index.d.ts +471 -0
  133. package/dist/string/index.js +4 -0
  134. package/dist/string/index.js.map +1 -0
  135. package/dist/transform/index.cjs +105 -0
  136. package/dist/transform/index.cjs.map +1 -0
  137. package/dist/transform/index.d.cts +271 -0
  138. package/dist/transform/index.d.ts +271 -0
  139. package/dist/transform/index.js +4 -0
  140. package/dist/transform/index.js.map +1 -0
  141. package/dist/validators/index.cjs +195 -0
  142. package/dist/validators/index.cjs.map +1 -0
  143. package/dist/validators/index.d.cts +2 -0
  144. package/dist/validators/index.d.ts +2 -0
  145. package/dist/validators/index.js +6 -0
  146. package/dist/validators/index.js.map +1 -0
  147. package/package.json +229 -0
@@ -0,0 +1,362 @@
1
+ /**
2
+ * Country information interface
3
+ */
4
+ interface Country {
5
+ /** Country name */
6
+ name: string;
7
+ /** Official country name */
8
+ officialName?: string;
9
+ /** ISO 3166-1 alpha-2 code */
10
+ alpha2: string;
11
+ /** ISO 3166-1 alpha-3 code */
12
+ alpha3: string;
13
+ /** ISO 3166-1 numeric code */
14
+ numeric: string;
15
+ /** Continent */
16
+ continent: string;
17
+ /** Capital city */
18
+ capital?: string;
19
+ /** Languages spoken */
20
+ languages: string[];
21
+ /** Currency code */
22
+ currency: string;
23
+ /** Dialing code */
24
+ dialCode: string;
25
+ /** Flag emoji */
26
+ flag: string;
27
+ }
28
+ /**
29
+ * Currency information
30
+ */
31
+ interface CurrencyInfo {
32
+ /** ISO 4217 currency code */
33
+ code: string;
34
+ /** Currency symbol */
35
+ symbol: string;
36
+ /** Currency name */
37
+ name: string;
38
+ /** Number of decimal places */
39
+ decimals: number;
40
+ /** Symbol position */
41
+ symbolPosition: 'before' | 'after';
42
+ /** Thousands separator */
43
+ thousandsSeparator: string;
44
+ /** Decimal separator */
45
+ decimalSeparator: string;
46
+ }
47
+ /**
48
+ * Timezone information
49
+ */
50
+ interface TimezoneInfo {
51
+ /** IANA timezone name */
52
+ name: string;
53
+ /** UTC offset in hours */
54
+ offset: number;
55
+ /** UTC offset string (e.g., "+05:00") */
56
+ offsetString: string;
57
+ /** Whether DST is currently active */
58
+ isDST: boolean;
59
+ /** Abbreviation (e.g., "PST", "EST") */
60
+ abbreviation: string;
61
+ }
62
+ /**
63
+ * Phone format information by country
64
+ */
65
+ interface PhoneFormat {
66
+ /** Country code */
67
+ countryCode: string;
68
+ /** Dialing code with + */
69
+ dialCode: string;
70
+ /** National number length(s) */
71
+ lengths: number[];
72
+ /** Mobile prefixes */
73
+ mobilePrefixes: string[];
74
+ /** Landline prefixes */
75
+ landlinePrefixes: string[];
76
+ /** Format pattern */
77
+ pattern: string;
78
+ /** Example number */
79
+ example: string;
80
+ /** Area codes for NANP countries (US, Canada, Caribbean) */
81
+ areaCodes?: string[];
82
+ }
83
+ /**
84
+ * Country code conversion types
85
+ */
86
+ type CountryCodeFormat = 'alpha2' | 'alpha3' | 'numeric';
87
+
88
+ /**
89
+ * Get country by alpha-2 code (e.g., "US", "PK")
90
+ *
91
+ * @param code - ISO 3166-1 alpha-2 code
92
+ * @returns Country or null
93
+ */
94
+ declare function getCountryByAlpha2(code: string): Country | null;
95
+ /**
96
+ * Get country by alpha-3 code (e.g., "USA", "PAK")
97
+ *
98
+ * @param code - ISO 3166-1 alpha-3 code
99
+ * @returns Country or null
100
+ */
101
+ declare function getCountryByAlpha3(code: string): Country | null;
102
+ /**
103
+ * Get country by numeric code (e.g., "840", "586")
104
+ *
105
+ * @param code - ISO 3166-1 numeric code
106
+ * @returns Country or null
107
+ */
108
+ declare function getCountryByNumeric(code: string | number): Country | null;
109
+ /**
110
+ * Get country by any code format (alpha-2, alpha-3, or numeric)
111
+ *
112
+ * @param code - Country code in any format (e.g., 'US', 'USA', '840')
113
+ * @returns Country object with details or null if not found
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * getCountry('US'); // returns { name: 'United States', ... }
118
+ * getCountry('USA'); // returns { name: 'United States', ... }
119
+ * getCountry(840); // returns { name: 'United States', ... }
120
+ * ```
121
+ */
122
+ declare function getCountry(code: string | number): Country | null;
123
+ /**
124
+ * Convert country code between formats
125
+ *
126
+ * @param code - Source country code
127
+ * @param to - Target format
128
+ * @returns Converted code or null
129
+ */
130
+ declare function convertCountryCode(code: string | number, to: CountryCodeFormat): string | null;
131
+ /**
132
+ * Get all countries
133
+ *
134
+ * @returns Array of all countries
135
+ */
136
+ declare function getAllCountries(): Country[];
137
+ /**
138
+ * Get countries by continent
139
+ *
140
+ * @param continent - Continent name
141
+ * @returns Array of countries
142
+ */
143
+ declare function getCountriesByContinent(continent: string): Country[];
144
+ /**
145
+ * Get countries by language
146
+ *
147
+ * @param language - Language code
148
+ * @returns Array of countries
149
+ */
150
+ declare function getCountriesByLanguage(language: string): Country[];
151
+ /**
152
+ * Search countries by name
153
+ *
154
+ * @param query - Search query
155
+ * @returns Array of matching countries
156
+ */
157
+ declare function searchCountries(query: string): Country[];
158
+ /**
159
+ * Check if country code is valid
160
+ *
161
+ * @param code - Country code
162
+ * @returns true if valid
163
+ */
164
+ declare function isValidCountryCode(code: string | number): boolean;
165
+
166
+ /**
167
+ * Get all timezones for a country
168
+ *
169
+ * @param countryCode - ISO country code
170
+ * @returns Array of timezone names
171
+ */
172
+ declare function getTimezonesByCountry(countryCode: string): string[];
173
+ /**
174
+ * Get default timezone for a country
175
+ *
176
+ * @param countryCode - ISO country code
177
+ * @returns Default timezone or null
178
+ */
179
+ declare function getDefaultTimezone(countryCode: string): string | null;
180
+ /**
181
+ * Get current time in a country's timezone
182
+ *
183
+ * @param countryCode - ISO country code
184
+ * @returns Date in country's timezone
185
+ */
186
+ declare function getCurrentTimeInCountry(countryCode: string): Date | null;
187
+ /**
188
+ * Get timezone offset for a country
189
+ *
190
+ * @param countryCode - ISO country code
191
+ * @returns Offset string (e.g., "+05:00") or null
192
+ */
193
+ declare function getTimezoneOffset(countryCode: string): string | null;
194
+ /**
195
+ * Convert time between timezones
196
+ *
197
+ * @param date - Date to convert
198
+ * @param fromCountry - Source country code
199
+ * @param toCountry - Target country code
200
+ * @returns Converted date or null
201
+ */
202
+ declare function convertTimeBetweenCountries(date: Date, _fromCountry: string, toCountry: string): Date | null;
203
+ /**
204
+ * Format time for a specific timezone
205
+ *
206
+ * @param date - Date to format
207
+ * @param countryCode - Country code
208
+ * @param options - Intl.DateTimeFormat options
209
+ * @returns Formatted time string
210
+ */
211
+ declare function formatTimeForCountry(date: Date, countryCode: string, options?: Partial<Intl.DateTimeFormatOptions>): string;
212
+
213
+ /**
214
+ * Get currency info by currency code
215
+ *
216
+ * @param currencyCode - ISO 4217 currency code
217
+ * @returns Currency info or null
218
+ */
219
+ declare function getCurrency(currencyCode: string): CurrencyInfo | null;
220
+ /**
221
+ * Get currency by country code
222
+ *
223
+ * @param countryCode - ISO country code
224
+ * @returns Currency info or null
225
+ */
226
+ declare function getCurrencyByCountry(countryCode: string): CurrencyInfo | null;
227
+ /**
228
+ * Format currency amount
229
+ *
230
+ * @param amount - Amount to format
231
+ * @param currencyCode - Currency code or country code
232
+ * @returns Formatted currency string
233
+ */
234
+ declare function formatCurrency(amount: number, currencyCode: string): string;
235
+ /**
236
+ * Parse currency string to number
237
+ *
238
+ * @param value - Currency string
239
+ * @param currencyCode - Currency code
240
+ * @returns Parsed number or NaN
241
+ */
242
+ declare function parseCurrency(value: string, currencyCode: string): number;
243
+ /**
244
+ * Get all supported currencies
245
+ *
246
+ * @returns Array of currency info
247
+ */
248
+ declare function getAllCurrencies(): CurrencyInfo[];
249
+ /**
250
+ * Get currency symbol
251
+ *
252
+ * @param currencyCode - Currency code
253
+ * @returns Symbol or null
254
+ */
255
+ declare function getCurrencySymbol(currencyCode: string): string | null;
256
+ /**
257
+ * Convert amount between currencies (requires exchange rate)
258
+ *
259
+ * @param amount - Amount to convert
260
+ * @param fromCurrency - Source currency code
261
+ * @param toCurrency - Target currency code
262
+ * @param exchangeRate - Exchange rate (from -> to)
263
+ * @returns Converted amount
264
+ */
265
+ declare function convertCurrency(amount: number, _fromCurrency: string, toCurrency: string, exchangeRate: number): number;
266
+
267
+ /**
268
+ * Get flag emoji for a country code
269
+ *
270
+ * @param countryCode - ISO alpha-2 country code
271
+ * @returns Flag emoji or null if invalid
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * getFlagEmoji('US'); // 'πŸ‡ΊπŸ‡Έ'
276
+ * getFlagEmoji('PK'); // 'πŸ‡΅πŸ‡°'
277
+ * ```
278
+ */
279
+ declare function getFlagEmoji(countryCode: string): string | null;
280
+ /**
281
+ * Get country code from flag emoji
282
+ *
283
+ * @param emoji - Flag emoji
284
+ * @returns ISO alpha-2 country code or null
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * getCountryFromEmoji('πŸ‡ΊπŸ‡Έ'); // 'US'
289
+ * getCountryFromEmoji('πŸ‡΅πŸ‡°'); // 'PK'
290
+ * ```
291
+ */
292
+ declare function getCountryFromEmoji(emoji: string): string | null;
293
+ /**
294
+ * Check if string is a valid flag emoji
295
+ *
296
+ * @param str - String to check
297
+ * @returns true if valid flag emoji
298
+ */
299
+ declare function isFlagEmoji(str: string): boolean;
300
+ /**
301
+ * Get all flag emojis
302
+ *
303
+ * @returns Record of country code to flag emoji
304
+ */
305
+ declare function getAllFlags(): Record<string, string>;
306
+
307
+ /**
308
+ * Get dialing code for a country
309
+ *
310
+ * @param countryCode - ISO alpha-2 country code
311
+ * @returns Dialing code (e.g., "+1", "+92") or null
312
+ */
313
+ declare function getDialingCode(countryCode: string): string | null;
314
+ /**
315
+ * Get country code from dialing code
316
+ *
317
+ * @param dialCode - Dialing code (with or without +)
318
+ * @returns Array of possible country codes
319
+ */
320
+ declare function getCountriesByDialingCode(dialCode: string): string[];
321
+ /**
322
+ * Format phone number with dialing code
323
+ *
324
+ * @param nationalNumber - National phone number
325
+ * @param countryCode - ISO country code
326
+ * @returns Formatted international number
327
+ */
328
+ declare function formatWithDialingCode(nationalNumber: string, countryCode: string): string;
329
+ /**
330
+ * Check if phone number includes valid dialing code
331
+ *
332
+ * @param phone - Phone number
333
+ * @returns true if has valid dialing code
334
+ */
335
+ declare function hasValidDialingCode(phone: string): boolean;
336
+
337
+ /**
338
+ * Comprehensive country data - ISO 3166-1
339
+ * Includes all major countries with complete metadata
340
+ */
341
+ declare const COUNTRIES: Country[];
342
+
343
+ /**
344
+ * Currency information by currency code
345
+ */
346
+ declare const CURRENCIES: Record<string, CurrencyInfo>;
347
+
348
+ /**
349
+ * Phone format data by country
350
+ * Includes dial codes, number lengths, and prefixes
351
+ */
352
+ declare const PHONE_FORMATS: Record<string, PhoneFormat>;
353
+ /**
354
+ * Get phone format for a country
355
+ */
356
+ declare function getPhoneFormat(countryCode: string): PhoneFormat | null;
357
+ /**
358
+ * Get all supported country codes
359
+ */
360
+ declare function getSupportedPhoneCountries(): string[];
361
+
362
+ export { getCountryFromEmoji as A, isFlagEmoji as B, type Country as C, getAllFlags as D, getDialingCode as E, getCountriesByDialingCode as F, formatWithDialingCode as G, hasValidDialingCode as H, COUNTRIES as I, CURRENCIES as J, PHONE_FORMATS as K, getPhoneFormat as L, getSupportedPhoneCountries as M, type PhoneFormat as P, type TimezoneInfo as T, type CurrencyInfo as a, type CountryCodeFormat as b, getCountryByAlpha3 as c, getCountryByNumeric as d, getCountry as e, convertCountryCode as f, getCountryByAlpha2 as g, getAllCountries as h, getCountriesByContinent as i, getCountriesByLanguage as j, isValidCountryCode as k, getTimezonesByCountry as l, getDefaultTimezone as m, getCurrentTimeInCountry as n, getTimezoneOffset as o, convertTimeBetweenCountries as p, formatTimeForCountry as q, getCurrency as r, searchCountries as s, getCurrencyByCountry as t, formatCurrency as u, parseCurrency as v, getAllCurrencies as w, getCurrencySymbol as x, convertCurrency as y, getFlagEmoji as z };