@rtorcato/js-common 1.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.
Files changed (170) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/CONTRIBUTORS.md +97 -0
  3. package/LICENSE +21 -0
  4. package/README.md +199 -0
  5. package/dist/abortController/index.d.ts +29 -0
  6. package/dist/abortController/index.d.ts.map +1 -0
  7. package/dist/abortController/index.js +1 -0
  8. package/dist/arrays/index.d.ts +44 -0
  9. package/dist/arrays/index.d.ts.map +1 -0
  10. package/dist/arrays/index.js +1 -0
  11. package/dist/boolean/index.d.ts +41 -0
  12. package/dist/boolean/index.d.ts.map +1 -0
  13. package/dist/boolean/index.js +1 -0
  14. package/dist/chunks/chunk-7MXMG6WN.js +1 -0
  15. package/dist/chunks/chunk-ANN5UYCF.js +1 -0
  16. package/dist/chunks/chunk-DCFILRIS.js +1 -0
  17. package/dist/chunks/chunk-W72HFHZY.js +1 -0
  18. package/dist/chunks/chunk-XAQ7VMV4.js +1 -0
  19. package/dist/cli/index.cjs +3711 -0
  20. package/dist/colors/index.d.ts +63 -0
  21. package/dist/colors/index.d.ts.map +1 -0
  22. package/dist/colors/index.js +1 -0
  23. package/dist/console/index.d.ts +16 -0
  24. package/dist/console/index.d.ts.map +1 -0
  25. package/dist/console/index.js +1 -0
  26. package/dist/crypto/index.d.ts +34 -0
  27. package/dist/crypto/index.d.ts.map +1 -0
  28. package/dist/crypto/index.js +1 -0
  29. package/dist/currency/currencies.d.ts +16 -0
  30. package/dist/currency/currencies.d.ts.map +1 -0
  31. package/dist/currency/currencies.js +1 -0
  32. package/dist/currency/index.d.ts +52 -0
  33. package/dist/currency/index.d.ts.map +1 -0
  34. package/dist/currency/index.js +1 -0
  35. package/dist/date/index.d.ts +44 -0
  36. package/dist/date/index.d.ts.map +1 -0
  37. package/dist/date/index.js +1 -0
  38. package/dist/datetime/index.d.ts +52 -0
  39. package/dist/datetime/index.d.ts.map +1 -0
  40. package/dist/datetime/index.js +1 -0
  41. package/dist/emails/banned/index.d.ts +9 -0
  42. package/dist/emails/banned/index.d.ts.map +1 -0
  43. package/dist/emails/index.d.ts +26 -0
  44. package/dist/emails/index.d.ts.map +1 -0
  45. package/dist/emails/index.js +1 -0
  46. package/dist/env/index.d.ts +63 -0
  47. package/dist/env/index.d.ts.map +1 -0
  48. package/dist/env/index.js +3 -0
  49. package/dist/errors/index.d.ts +39 -0
  50. package/dist/errors/index.d.ts.map +1 -0
  51. package/dist/errors/index.js +1 -0
  52. package/dist/events/index.d.ts +35 -0
  53. package/dist/events/index.d.ts.map +1 -0
  54. package/dist/events/index.js +1 -0
  55. package/dist/fetch/index.d.ts +38 -0
  56. package/dist/fetch/index.d.ts.map +1 -0
  57. package/dist/fetch/index.js +1 -0
  58. package/dist/file/index.d.ts +32 -0
  59. package/dist/file/index.d.ts.map +1 -0
  60. package/dist/file/index.js +1 -0
  61. package/dist/formatting/index.d.ts +52 -0
  62. package/dist/formatting/index.d.ts.map +1 -0
  63. package/dist/formatting/index.js +1 -0
  64. package/dist/functions/index.d.ts +33 -0
  65. package/dist/functions/index.d.ts.map +1 -0
  66. package/dist/functions/index.js +1 -0
  67. package/dist/geometry/index.d.ts +58 -0
  68. package/dist/geometry/index.d.ts.map +1 -0
  69. package/dist/geometry/index.js +1 -0
  70. package/dist/html/index.d.ts +31 -0
  71. package/dist/html/index.d.ts.map +1 -0
  72. package/dist/html/index.js +1 -0
  73. package/dist/i18n/index.d.ts +37 -0
  74. package/dist/i18n/index.d.ts.map +1 -0
  75. package/dist/i18n/index.js +1 -0
  76. package/dist/index.d.ts +3 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +1 -0
  79. package/dist/interval/index.d.ts +13 -0
  80. package/dist/interval/index.d.ts.map +1 -0
  81. package/dist/interval/index.js +1 -0
  82. package/dist/json/index.d.ts +28 -0
  83. package/dist/json/index.d.ts.map +1 -0
  84. package/dist/json/index.js +1 -0
  85. package/dist/logger/logger.d.ts +3 -0
  86. package/dist/logger/logger.d.ts.map +1 -0
  87. package/dist/logging/index.d.ts +28 -0
  88. package/dist/logging/index.d.ts.map +1 -0
  89. package/dist/logging/index.js +1 -0
  90. package/dist/logging/index1.d.ts +33 -0
  91. package/dist/logging/index1.d.ts.map +1 -0
  92. package/dist/logging/index1.js +1 -0
  93. package/dist/maps/index.d.ts +32 -0
  94. package/dist/maps/index.d.ts.map +1 -0
  95. package/dist/maps/index.js +1 -0
  96. package/dist/math/index.d.ts +3 -0
  97. package/dist/math/index.d.ts.map +1 -0
  98. package/dist/math/index.js +1 -0
  99. package/dist/math/math.d.ts +37 -0
  100. package/dist/math/math.d.ts.map +1 -0
  101. package/dist/math/math.js +1 -0
  102. package/dist/math/sum/index.d.ts +3 -0
  103. package/dist/math/sum/index.d.ts.map +1 -0
  104. package/dist/mime-types/db.d.ts +4605 -0
  105. package/dist/mime-types/db.d.ts.map +1 -0
  106. package/dist/mime-types/db.js +1 -0
  107. package/dist/mime-types/index.d.ts +25 -0
  108. package/dist/mime-types/index.d.ts.map +1 -0
  109. package/dist/mime-types/index.js +7 -0
  110. package/dist/node/index.d.ts +52 -0
  111. package/dist/node/index.d.ts.map +1 -0
  112. package/dist/node/index.js +1 -0
  113. package/dist/numbers/index.d.ts +74 -0
  114. package/dist/numbers/index.d.ts.map +1 -0
  115. package/dist/numbers/index.js +1 -0
  116. package/dist/obects/index.d.ts +34 -0
  117. package/dist/obects/index.d.ts.map +1 -0
  118. package/dist/obects/index.js +1 -0
  119. package/dist/os/index.d.ts +26 -0
  120. package/dist/os/index.d.ts.map +1 -0
  121. package/dist/os/index.js +1 -0
  122. package/dist/process/index.d.ts +31 -0
  123. package/dist/process/index.d.ts.map +1 -0
  124. package/dist/process/index.js +1 -0
  125. package/dist/promises/index.d.ts +39 -0
  126. package/dist/promises/index.d.ts.map +1 -0
  127. package/dist/promises/index.js +1 -0
  128. package/dist/random/index.d.ts +33 -0
  129. package/dist/random/index.d.ts.map +1 -0
  130. package/dist/random/index.js +1 -0
  131. package/dist/regex/index.d.ts +36 -0
  132. package/dist/regex/index.d.ts.map +1 -0
  133. package/dist/regex/index.js +1 -0
  134. package/dist/security/index.d.ts +14 -0
  135. package/dist/security/index.d.ts.map +1 -0
  136. package/dist/security/index.js +1 -0
  137. package/dist/sets/index.d.ts +48 -0
  138. package/dist/sets/index.d.ts.map +1 -0
  139. package/dist/sets/index.js +1 -0
  140. package/dist/sleep/index.d.ts +27 -0
  141. package/dist/sleep/index.d.ts.map +1 -0
  142. package/dist/sleep/index.js +1 -0
  143. package/dist/strings/index.d.ts +74 -0
  144. package/dist/strings/index.d.ts.map +1 -0
  145. package/dist/strings/index.js +1 -0
  146. package/dist/system/index.d.ts +36 -0
  147. package/dist/system/index.d.ts.map +1 -0
  148. package/dist/system/index.js +1 -0
  149. package/dist/time/index.d.ts +36 -0
  150. package/dist/time/index.d.ts.map +1 -0
  151. package/dist/time/index.js +1 -0
  152. package/dist/try/attempt.d.ts +8 -0
  153. package/dist/try/attempt.d.ts.map +1 -0
  154. package/dist/try/attempt.js +1 -0
  155. package/dist/try/index.d.ts +2 -0
  156. package/dist/try/index.d.ts.map +1 -0
  157. package/dist/try/index.js +1 -0
  158. package/dist/try/trycatch.d.ts +12 -0
  159. package/dist/try/trycatch.d.ts.map +1 -0
  160. package/dist/try/trycatch.js +1 -0
  161. package/dist/url/index.d.ts +40 -0
  162. package/dist/url/index.d.ts.map +1 -0
  163. package/dist/url/index.js +1 -0
  164. package/dist/uuid/index.d.ts +40 -0
  165. package/dist/uuid/index.d.ts.map +1 -0
  166. package/dist/uuid/index.js +1 -0
  167. package/dist/validation/index.d.ts +49 -0
  168. package/dist/validation/index.d.ts.map +1 -0
  169. package/dist/validation/index.js +1 -0
  170. package/package.json +290 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Generates a random hex color string.
3
+ *
4
+ * @returns {string} A string representing a random color in hexadecimal format (e.g., `#a1b2c3`).
5
+ */
6
+ export declare function randomColor(): string;
7
+ /**
8
+ * Generates a random color with a given alpha value.
9
+ *
10
+ * @export
11
+ * @param {string} color
12
+ * @return {*}
13
+ */
14
+ export declare function matchingTextColor(color: string): "#000" | "#fff";
15
+ /**
16
+ * Converts a hex color string to an RGB object.
17
+ *
18
+ * @export
19
+ * @param {string} hex
20
+ * @return {*} {({ r: number; g: number; b: number } | null)}
21
+ */
22
+ export declare function hexToRgb(hex: string): {
23
+ r: number;
24
+ g: number;
25
+ b: number;
26
+ } | null;
27
+ /**
28
+ * Converts RGB values to a hex color string.
29
+ *
30
+ * @export
31
+ * @param {number} r
32
+ * @param {number} g
33
+ * @param {number} b
34
+ * @return {*} {string}
35
+ */
36
+ export declare function rgbToHex(r: number, g: number, b: number): string;
37
+ /**
38
+ * Converts a hex color string to an HSL object.
39
+ *
40
+ * @export
41
+ * @param {string} hex
42
+ * @return {*} {({ h: number; s: number; l: number } | null)}
43
+ */
44
+ export declare function isValidHex(hex: string): boolean;
45
+ /**
46
+ * Darkens a hex color by a given percentage.
47
+ *
48
+ * @export
49
+ * @param {string} hex
50
+ * @param {number} percent
51
+ * @return {*} {string}
52
+ */
53
+ export declare function darken(hex: string, percent: number): string;
54
+ /**
55
+ * Lightens a hex color by a given percentage.
56
+ *
57
+ * @export
58
+ * @param {string} hex
59
+ * @param {number} percent
60
+ * @return {*} {string}
61
+ */
62
+ export declare function lighten(hex: string, percent: number): string;
63
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/colors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAKpC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,mBAO9C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQhF;AAED;;;;;;;;GAQG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOhE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAO5D"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";function u(){return`#${Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}`}function f(r){let t=Number.parseInt(r.slice(1,3),16),n=Number.parseInt(r.slice(3,5),16),e=Number.parseInt(r.slice(5,7),16);return(t*299+n*587+e*114)/1e3>=128?"#000":"#fff"}function i(r){let t=r.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);return t?{r:Number.parseInt(t[1]||"",16),g:Number.parseInt(t[2]||"",16),b:Number.parseInt(t[3]||"",16)}:null}function s(r,t,n){return`#${[r,t,n].map(e=>{let o=e.toString(16);return o.length===1?`0${o}`:o}).join("")}`}function b(r){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(r)}function g(r,t){let n=i(r);if(!n)return r;let e=Math.max(0,Math.floor(n.r*(1-t))),o=Math.max(0,Math.floor(n.g*(1-t))),a=Math.max(0,Math.floor(n.b*(1-t)));return s(e,o,a)}function m(r,t){let n=i(r);if(!n)return r;let e=Math.min(255,Math.floor(n.r+(255-n.r)*t)),o=Math.min(255,Math.floor(n.g+(255-n.g)*t)),a=Math.min(255,Math.floor(n.b+(255-n.b)*t));return s(e,o,a)}export{g as darken,i as hexToRgb,b as isValidHex,m as lighten,f as matchingTextColor,u as randomColor,s as rgbToHex};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @fileoverview Console utility functions for logging and disabling console output in production.
3
+ * @module console
4
+ */
5
+ /**
6
+ * Disables console output in production environment.
7
+ */
8
+ export declare const disableConsole: () => void;
9
+ /**
10
+ * Clears the console.
11
+ *
12
+ * @export
13
+ * @return {*} {void}
14
+ */
15
+ export declare const clearConsole: () => void;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/console/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,YAK1B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAA"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";var o=()=>{process.env.NODE_ENV==="production"&&(console.log=()=>{})},e=()=>{process.stdout.write("\x1B[2J\x1B[0f")};export{e as clearConsole,o as disableConsole};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Hashes a string using the specified algorithm.
3
+ * @param str The string to hash.
4
+ * @param algorithm The hash algorithm (default: 'sha256').
5
+ * @returns The hex-encoded hash.
6
+ */
7
+ export declare function hashString(str: string, algorithm?: string): string;
8
+ /**
9
+ * Generates a random hex string of the specified length (in bytes).
10
+ * @param length The number of bytes (not hex chars).
11
+ * @returns A random hex string.
12
+ */
13
+ export declare function randomHex(length?: number): string;
14
+ /**
15
+ * Creates an HMAC hash of a string using a secret and algorithm.
16
+ * @param str The string to hash.
17
+ * @param secret The secret key.
18
+ * @param algorithm The hash algorithm (default: 'sha256').
19
+ * @returns The hex-encoded HMAC.
20
+ */
21
+ export declare function hmacHash(str: string, secret: string, algorithm?: string): string;
22
+ /**
23
+ * Encodes a string to base64.
24
+ * @param str The string to encode.
25
+ * @returns The base64-encoded string.
26
+ */
27
+ export declare function base64Encode(str: string): string;
28
+ /**
29
+ * Decodes a base64 string.
30
+ * @param b64 The base64 string to decode.
31
+ * @returns The decoded string.
32
+ */
33
+ export declare function base64Decode(b64: string): string;
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAW,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAK,GAAG,MAAM,CAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAW,GAAG,MAAM,CAElF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";import{createHash as n,createHmac as i,randomBytes as s}from"node:crypto";function a(t,r="sha256"){return n(r).update(t).digest("hex")}function g(t=16){return s(t).toString("hex")}function u(t,r,e="sha256"){return i(e,r).update(t).digest("hex")}function f(t){return Buffer.from(t,"utf-8").toString("base64")}function c(t){return Buffer.from(t,"base64").toString("utf-8")}export{c as base64Decode,f as base64Encode,a as hashString,u as hmacHash,g as randomHex};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * List of supported currency codes.
3
+ *
4
+ * This array contains ISO 4217 currency codes and some special codes
5
+ * (such as precious metals and testing codes) used in financial applications.
6
+ *
7
+ * @remarks
8
+ * - Some codes represent fiat currencies (e.g., 'USD', 'EUR').
9
+ * - Some codes represent precious metals (e.g., 'XAU' for gold).
10
+ * - Some codes are reserved for testing or special purposes (e.g., 'XTS', 'XXX').
11
+ *
12
+ * @see {@link https://www.iso.org/iso-4217-currency-codes.html ISO 4217 Currency Codes}
13
+ */
14
+ export declare const currencies: string[];
15
+ export default currencies;
16
+ //# sourceMappingURL=currencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currencies.d.ts","sourceRoot":"","sources":["../../src/currency/currencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,UA6CtB,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ import{a,b}from"../chunks/chunk-7MXMG6WN.js";import"../chunks/chunk-ANN5UYCF.js";export{a as currencies,b as default};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Returns the currency symbol for a given ISO 4217 currency code.
3
+ *
4
+ * Utilizes the `Intl.NumberFormat` API to format a number as currency and extract the symbol.
5
+ *
6
+ * @param currency - The ISO 4217 currency code (e.g., 'USD', 'EUR', 'JPY').
7
+ * @returns The currency symbol as a string (e.g., '$', '€', '¥'), or `undefined` if the symbol cannot be determined.
8
+ */
9
+ export declare const getCurrencySymbol: (currency: string) => string | undefined;
10
+ /**
11
+ * Formats a given price value into a localized currency string.
12
+ *
13
+ * @param price - The numeric value or string representation of the price to format.
14
+ * @param currency - The currency code to use for formatting. Supported values are 'USD', 'EUR', 'GBP', and 'BDT'. Defaults to 'USD'.
15
+ * @param notation - The formatting notation style. Can be 'compact', 'engineering', 'scientific', or 'standard'. Defaults to 'standard'.
16
+ * @returns The formatted currency string according to the specified locale, currency, and notation.
17
+ */
18
+ export declare function formatPrice(price: number | string, currency?: 'USD' | 'EUR' | 'GBP' | 'BDT', notation?: 'compact' | 'engineering' | 'scientific' | 'standard'): string;
19
+ /**
20
+ * Parses a given price string and returns its numeric value.
21
+ *
22
+ * @param value - The price string to parse.
23
+ * @returns The numeric value of the price, or `null` if the value cannot be parsed.
24
+ */
25
+ export declare function parsePrice(value: string): number | null;
26
+ /**
27
+ * Converts a given amount from one currency to another using the provided exchange rate.
28
+ *
29
+ * @param amount - The amount of money to convert.
30
+ * @param rate - The exchange rate to use for the conversion.
31
+ * @param decimals - The number of decimal places to include in the result. Defaults to 2.
32
+ * @returns The converted amount as a number.
33
+ */
34
+ export declare function convertCurrency(amount: number, rate: number, decimals?: number): number;
35
+ /**
36
+ * Checks if the provided currency code is valid.
37
+ *
38
+ * Converts the input code to uppercase and verifies if it exists in the list of supported currencies.
39
+ *
40
+ * @param code - The currency code to validate (e.g., 'USD', 'eur').
41
+ * @returns `true` if the currency code is valid; otherwise, `false`.
42
+ */
43
+ export declare function isValidCurrencyCode(code: string): boolean;
44
+ /**
45
+ * Rounds a given number to a specified number of decimal places.
46
+ *
47
+ * @param value - The number to be rounded.
48
+ * @param decimals - The number of decimal places to round to. Defaults to 2.
49
+ * @returns The rounded number.
50
+ */
51
+ export declare function roundTo(value: number, decimals?: number): number;
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,SAQ7D,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,GAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAa,EAC/C,QAAQ,GAAE,SAAS,GAAG,aAAa,GAAG,YAAY,GAAG,UAAuB,UAO5E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIvD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAElF;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAG3D"}
@@ -0,0 +1 @@
1
+ import{b as t}from"../chunks/chunk-7MXMG6WN.js";import"../chunks/chunk-ANN5UYCF.js";var o=r=>{let n=new Intl.NumberFormat("en",{currency:r,style:"currency"}).formatToParts(0).find(e=>e.type==="currency");return n?.value==="\xA4"?void 0:n?.value};function c(r,n="USD",e="standard"){return new Intl.NumberFormat("en-US",{style:"currency",currency:n,notation:e}).format(Number(r))}function i(r){let n=r.replace(/[^0-9.-]+/g,""),e=Number.parseFloat(n);return Number.isNaN(e)?null:e}function a(r,n,e=2){return Number.parseFloat((r*n).toFixed(e))}function s(r){return t.includes(r.toUpperCase())}function m(r,n=2){let e=10**n;return Math.round(r*e)/e}export{a as convertCurrency,c as formatPrice,o as getCurrencySymbol,s as isValidCurrencyCode,i as parsePrice,m as roundTo};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Returns today's date as a YYYY-MM-DD string.
3
+ * @returns {string}
4
+ */
5
+ export declare function today(): string;
6
+ /**
7
+ * Returns a Date object from a YYYY-MM-DD string.
8
+ * @param dateStr The date string.
9
+ * @returns {Date}
10
+ */
11
+ export declare function parseDate(dateStr: string): Date;
12
+ /**
13
+ * Formats a Date object as YYYY-MM-DD.
14
+ * @param date The Date object.
15
+ * @returns {string}
16
+ */
17
+ export declare function formatDate(date: Date): string;
18
+ /**
19
+ * Returns the difference in days between two dates (date2 - date1).
20
+ * @param date1 The first date (string or Date).
21
+ * @param date2 The second date (string or Date).
22
+ * @returns {number}
23
+ */
24
+ export declare function daysBetween(date1: string | Date, date2: string | Date): number;
25
+ /**
26
+ * Checks if a year is a leap year.
27
+ * @param year The year (number or Date).
28
+ * @returns {boolean}
29
+ */
30
+ export declare function isLeapYear(year: number | Date): boolean;
31
+ /**
32
+ * Adds days to a date and returns a new Date object.
33
+ * @param date The date (string or Date).
34
+ * @param days Number of days to add.
35
+ * @returns {Date}
36
+ */
37
+ export declare function addDays(date: string | Date, days: number): Date;
38
+ /**
39
+ * Returns the day of the week for a date (0=Sunday, 6=Saturday).
40
+ * @param date The date (string or Date).
41
+ * @returns {number}
42
+ */
43
+ export declare function getDayOfWeek(date: string | Date): number;
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,IAAI,MAAM,CAG9B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAI9E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAI/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGxD"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";function i(){return new Date().toISOString().slice(0,10)}function r(t){return new Date(`${t}T00:00:00`)}function s(t){return t.toISOString().slice(0,10)}function a(t,e){let n=typeof t=="string"?r(t):t,o=typeof e=="string"?r(e):e;return Math.floor((o.getTime()-n.getTime())/(1e3*60*60*24))}function g(t){let e=t instanceof Date?t.getUTCFullYear():t;return e%4===0&&e%100!==0||e%400===0}function u(t,e){let n=typeof t=="string"?r(t):new Date(t);return n.setDate(n.getDate()+e),n}function D(t){return(typeof t=="string"?r(t):t).getDay()}export{u as addDays,a as daysBetween,s as formatDate,D as getDayOfWeek,g as isLeapYear,r as parseDate,i as today};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Returns the current date and time as an ISO string (YYYY-MM-DDTHH:mm:ss.sssZ).
3
+ */
4
+ export declare function nowIso(): string;
5
+ /**
6
+ * Parses an ISO date-time string to a Date object. Returns null if invalid.
7
+ * @param iso The ISO string.
8
+ */
9
+ export declare function parseIsoDateTime(iso: string): Date | null;
10
+ /**
11
+ * Formats a Date as YYYY-MM-DD HH:mm:ss (local time).
12
+ * @param date The Date object.
13
+ */
14
+ export declare function formatDateTimeLocal(date: Date): string;
15
+ /**
16
+ * Returns the timezone offset in minutes for a given date (local - UTC).
17
+ * @param date The Date object.
18
+ */
19
+ export declare function getTimezoneOffset(date?: Date): number;
20
+ /**
21
+ * Returns the UTC equivalent of a local Date.
22
+ * @param date The local Date object.
23
+ */
24
+ export declare function toUtcDate(date: Date): Date;
25
+ /**
26
+ * Returns the number of seconds since the Unix epoch (UTC).
27
+ */
28
+ export declare function unixTimestamp(): number;
29
+ /**
30
+ * Returns the number of milliseconds since the Unix epoch.
31
+ */
32
+ export declare function unixMillis(): number;
33
+ /**
34
+ * Returns the difference in seconds between two Date objects.
35
+ * @param a First date.
36
+ * @param b Second date.
37
+ */
38
+ export declare function secondsBetween(a: Date, b: Date): number;
39
+ /**
40
+ * Returns the ISO week number (1–53) of a given date using UTC.
41
+ * @param date A JavaScript Date object.
42
+ */
43
+ export declare function getIsoWeek(date: Date): number;
44
+ /**
45
+ * Returns ISO week number and ISO week year (which may differ from calendar year).
46
+ * @param date Date object (UTC-safe)
47
+ */
48
+ export declare function getIsoWeekInfo(date: Date): {
49
+ week: number;
50
+ year: number;
51
+ };
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datetime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGzD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAMtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,IAAiB,GAAG,MAAM,CAEjE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAY1C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAoB7C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAmBzE"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";function i(){return new Date().toISOString()}function c(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function T(e){let t=n=>n.toString().padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}function l(e=new Date){return e.getTimezoneOffset()}function f(e){return new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}function m(){return Math.floor(Date.now()/1e3)}function w(){return Date.now()}function U(e,t){return Math.floor((t.getTime()-e.getTime())/1e3)}function C(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay(),s=n===0?7:n;t.setUTCDate(t.getUTCDate()+4-s);let o=new Date(Date.UTC(t.getUTCFullYear(),0,1)).getUTCDay(),a=o===0?7:o,D=new Date(Date.UTC(t.getUTCFullYear(),0,1+(4-a))),u=t.getTime()-D.getTime();return 1+Math.round(u/(10080*60*1e3))}function y(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()));t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7));let n=t.getUTCFullYear(),r=new Date(Date.UTC(n,0,1)).getUTCDay()||7,o=new Date(Date.UTC(n,0,1-r+1+(r>4?7:0))),a=t.getTime()-o.getTime();return{week:Math.floor(a/(10080*60*1e3))+1,year:n}}export{T as formatDateTimeLocal,C as getIsoWeek,y as getIsoWeekInfo,l as getTimezoneOffset,i as nowIso,c as parseIsoDateTime,U as secondsBetween,f as toUtcDate,w as unixMillis,m as unixTimestamp};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Checks if the domain part of the given email is present in a list of forbidden domains.
3
+ *
4
+ * @param email - The email address to check.
5
+ * @param forbiddenEmails - A newline-separated string of forbidden email domains.
6
+ * @throws Will throw an error if the email is not formatted properly or if the domain is forbidden.
7
+ */
8
+ export declare const isEmailinBannedDomains: (email: string, forbiddenEmails: string) => void;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/emails/banned/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,EAAE,iBAAiB,MAAM,SAW5E,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Validates if a string is a valid email address (simple regex).
3
+ * @param email The email address to validate.
4
+ * @returns True if valid, false otherwise.
5
+ */
6
+ export declare function isValidEmail(email: string): boolean;
7
+ /**
8
+ * Normalizes an email address by trimming and converting to lowercase.
9
+ * @param email The email address to normalize.
10
+ * @returns The normalized email address.
11
+ */
12
+ export declare function normalizeEmail(email: string): string;
13
+ /**
14
+ * Masks an email address for privacy (e.g., j***@domain.com).
15
+ * @param email The email address to mask.
16
+ * @returns The masked email address.
17
+ */
18
+ export declare function maskEmail(email: string): string;
19
+ /**
20
+ * Extracts the domain from an email address.
21
+ * @param email The email address.
22
+ * @returns The domain part of the email, or an empty string if invalid.
23
+ */
24
+ export declare function getEmailDomain(email: string): string;
25
+ export declare function isFreeEmailProvider(email: string): boolean;
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/emails/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAiBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1D"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";function e(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function s(t){return t.trim().toLowerCase()}function a(t){let[o,r]=t.split("@");return!o||!r?t:o.length<=1?`*@${r}`:`${o[0]}${"*".repeat(Math.max(1,o.length-1))}@${r}`}function n(t){let o=t.split("@");return o.length===2?o[1]??"":""}var i=["gmail.com","yahoo.com","outlook.com","hotmail.com","icloud.com","aol.com","zoho.com","mail.com"];function m(t){return i.includes(n(t))}export{n as getEmailDomain,m as isFreeEmailProvider,e as isValidEmail,a as maskEmail,s as normalizeEmail};
@@ -0,0 +1,63 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Retrieves the value of an environment variable by its key.
4
+ *
5
+ * @param key - The name of the environment variable to retrieve.
6
+ * @param defaultValue - An optional default value to return if the environment variable is not defined.
7
+ * @returns The value of the environment variable if it exists, otherwise the default value if provided.
8
+ * @throws {Error} If the environment variable is undefined and no default value is provided.
9
+ */
10
+ export declare const getENV: (key: string, defaultValue?: string) => string;
11
+ /**
12
+ * Determines if the current environment is set to development.
13
+ *
14
+ * @returns {boolean} `true` if `process.env.NODE_ENV` is `'development'`, otherwise `false`.
15
+ */
16
+ export declare const isDev: () => boolean;
17
+ /**
18
+ * Determines if the current environment is set to production.
19
+ *
20
+ * @returns {boolean} `true` if `process.env.NODE_ENV` is `'production'`, otherwise `false`.
21
+ */
22
+ export declare const isProd: () => boolean;
23
+ /**
24
+ * Determines if the current environment is set to test.
25
+ *
26
+ * @returns {boolean} `true` if `process.env.NODE_ENV` is `'test'`, otherwise `false`.
27
+ */
28
+ export declare const isTest: () => boolean;
29
+ /**
30
+ * Returns the current NODE_ENV value, or 'development' if not set.
31
+ *
32
+ * @returns {string}
33
+ */
34
+ export declare const getNodeEnv: () => string;
35
+ /**
36
+ *
37
+ * Validates the environment variables against a Zod schema.
38
+ * Throws an error if any required variables are missing or invalid.
39
+ * @param {z.ZodObject<T>} EnvSchema - The Zod schema to validate against.
40
+ * @param {Record<string, string | undefined>} buildEnv - The environment variables to validate, defaults to `process.env`.
41
+ * @throws {Error} If validation fails, an error with a message listing missing variables is thrown.
42
+ */
43
+ export declare function checkEnv<T extends z.ZodRawShape>(EnvSchema: z.ZodObject<T>, buildEnv?: Record<string, string | undefined>): z.core.$InferObjectOutput<T, {}>;
44
+ /**
45
+ * Schema for validating the root environment variables.
46
+ * It includes NODE_ENV, LOG_LEVEL, and PORT with their respective types and defaults.
47
+ */
48
+ export declare const RootApiEnvSchema: z.ZodObject<{
49
+ NODE_ENV: z.ZodDefault<z.ZodEnum<{
50
+ test: "test";
51
+ development: "development";
52
+ production: "production";
53
+ }>>;
54
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
55
+ debug: "debug";
56
+ info: "info";
57
+ warn: "warn";
58
+ error: "error";
59
+ }>>;
60
+ PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
61
+ }, z.core.$strip>;
62
+ export type RootApiEnvSchema = z.infer<typeof RootApiEnvSchema>;
63
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,EAAE,eAAe,MAAM,WAUxD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAAO,OAExB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAC/C,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACzB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,oCAc1D;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;iBAI3B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";import{z as n}from"zod";var c=(r,o)=>{let e=process.env[r.toString()];if(e===void 0&&o!==void 0)return o;if(e===void 0){let t=`Undefined ENV variable - ${r.toString()}`;throw new Error(t)}return e},d=()=>process.env.NODE_ENV==="development",p=()=>process.env.NODE_ENV==="production",E=()=>process.env.NODE_ENV==="test",u=()=>process.env.NODE_ENV||"development";function a(r,o=process.env){try{return r.parse(o)}catch(e){if(e instanceof n.ZodError){let t=`Missing required values in .env:
2
+ `;t+=Object.keys(e.flatten().fieldErrors).join(`
3
+ `);let s=new Error(t);throw s.stack="",s}throw e}}var f=n.object({NODE_ENV:n.enum(["development","test","production"]).default("development"),LOG_LEVEL:n.enum(["debug","info","warn","error"]).default("info"),PORT:n.coerce.number().default(3e3)});export{f as RootApiEnvSchema,a as checkEnv,c as getENV,u as getNodeEnv,d as isDev,p as isProd,E as isTest};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Creates a new Error with a custom name and message.
3
+ * @param name The error name.
4
+ * @param message The error message.
5
+ * @returns The custom Error object.
6
+ */
7
+ export declare function createCustomError(name: string, message: string): Error;
8
+ /**
9
+ * Checks if an error is an instance of a specific error name.
10
+ * @param error The error to check.
11
+ * @param name The error name to match.
12
+ * @returns True if the error matches the name, false otherwise.
13
+ */
14
+ export declare function isErrorName(error: unknown, name: string): boolean;
15
+ /**
16
+ * Gets the error message from an unknown error value.
17
+ * @param error The error value.
18
+ * @returns The error message, or a stringified version if not an Error.
19
+ */
20
+ export declare function getErrorMessage(error: unknown): string;
21
+ /**
22
+ * Throws an error if the condition is false.
23
+ * @param condition The condition to check.
24
+ * @param message The error message to throw if the condition is false.
25
+ */
26
+ export declare function assert(condition: any, message: string): asserts condition;
27
+ /**
28
+ * Wraps a function and catches errors, returning a fallback value if an error occurs.
29
+ * @param fn The function to wrap.
30
+ * @param fallback The fallback value to return on error.
31
+ *
32
+ * @example
33
+ * const result = await tryCatch(async () => {
34
+ * // some code that might throw
35
+ * return await fetchData();
36
+ * }, []);
37
+ * // result will be [] if fetchData throws an error*/
38
+ export declare function tryCatch<T>(fn: () => Promise<T> | T, fallback: T): Promise<T>;
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAItE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQtD;AAED;;;;GAIG;AAEH,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAIzE;AAED;;;;;;;;;;sDAUsD;AACtD,wBAAsB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMnF"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";function e(n,r){let t=new Error(r);return t.name=n,t}function o(n,r){return n instanceof Error&&n.name===r}function i(n){if(n instanceof Error)return n.message;if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}function s(n,r){if(!n)throw new Error(r)}async function a(n,r){try{return await n()}catch{return r}}export{s as assert,e as createCustomError,i as getErrorMessage,o as isErrorName,a as tryCatch};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Adds an event listener and returns a function to remove it.
3
+ * @param target The event target.
4
+ * @param type The event type.
5
+ * @param handler The event handler.
6
+ * @param options Event listener options.
7
+ * @returns {() => void} Unsubscribe function.
8
+ */
9
+ export declare function on<K extends keyof HTMLElementEventMap>(target: EventTarget, type: K, handler: (event: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): () => void;
10
+ /**
11
+ * Dispatches a custom event on the target.
12
+ * @param target The event target.
13
+ * @param type The event type.
14
+ * @param detail Optional detail data.
15
+ * @returns {boolean} True if not canceled.
16
+ */
17
+ export declare function emit(target: EventTarget, type: string, detail?: any): boolean;
18
+ /**
19
+ * Waits for a single event to occur and resolves a promise.
20
+ * @param target The event target.
21
+ * @param type The event type.
22
+ * @returns {Promise<Event>} Resolves with the event object.
23
+ */
24
+ export declare function once<K extends keyof HTMLElementEventMap>(target: EventTarget, type: K): Promise<HTMLElementEventMap[K]>;
25
+ /**
26
+ * Prevents the default action for an event.
27
+ * @param event The event object.
28
+ */
29
+ export declare function preventDefault(event: Event): void;
30
+ /**
31
+ * Stops propagation for an event.
32
+ * @param event The event object.
33
+ */
34
+ export declare function stopPropagation(event: Event): void;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACrD,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,EAChD,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GACzC,MAAM,IAAI,CAGZ;AAED;;;;;;GAMG;AAEH,wBAAgB,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAE7E;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACvD,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,CAAC,GACL,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAQjC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAEjD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAElD"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";function r(e,n,t,o){return e.addEventListener(n,t,o),()=>e.removeEventListener(n,t,o)}function E(e,n,t){return e.dispatchEvent(new CustomEvent(n,{detail:t}))}function i(e,n){return new Promise(t=>{let o=v=>{e.removeEventListener(n,o),t(v)};e.addEventListener(n,o)})}function a(e){e.preventDefault()}function s(e){e.stopPropagation()}export{E as emit,r as on,i as once,a as preventDefault,s as stopPropagation};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Fetches a resource with a timeout.
3
+ * @param url The URL to fetch.
4
+ * @param options Fetch options.
5
+ * @param timeout Timeout in milliseconds (default: 8000).
6
+ * @returns The parsed JSON response.
7
+ */
8
+ export declare function fetchWithTimeout(url: string, options?: RequestInit, timeout?: number): Promise<unknown>;
9
+ /**
10
+ * Sends a POST request with a JSON body.
11
+ * @param url The URL to post to.
12
+ * @param body The body to send.
13
+ * @param options Additional fetch options.
14
+ * @returns The parsed JSON response.
15
+ */
16
+ export declare function postJson<T = unknown, R = unknown>(url: string, body: T, options?: RequestInit): Promise<R>;
17
+ /**
18
+ * Sends a GET request and returns JSON.
19
+ * @param url The URL to fetch.
20
+ * @param options Additional fetch options.
21
+ * @returns The parsed JSON response.
22
+ */
23
+ export declare function getJson<T = unknown>(url: string, options?: RequestInit): Promise<T>;
24
+ /**
25
+ * Fetches a resource and returns the response as text.
26
+ * @param url The URL to fetch.
27
+ * @param options Fetch options.
28
+ * @returns The response as text.
29
+ */
30
+ export declare function fetchText(url: string, options?: RequestInit): Promise<string>;
31
+ /**
32
+ * Handles fetch errors and returns a fallback value or throws.
33
+ * @param promise The fetch promise.
34
+ * @param fallback The fallback value to return on error.
35
+ * @returns The resolved value or the fallback.
36
+ */
37
+ export declare function handleApiError<T>(promise: Promise<T>, fallback?: T): Promise<T>;
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,OAAO,SAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EACtD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,EACP,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAG7F;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGvF;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOrF"}
@@ -0,0 +1 @@
1
+ import"../chunks/chunk-ANN5UYCF.js";async function i(n,t={},e=8e3){let o=new AbortController,r=setTimeout(()=>o.abort(),e);try{let s=await fetch(n,{...t,signal:o.signal});return clearTimeout(r),await s.json()}finally{clearTimeout(r)}}async function a(n,t,e={}){return await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify(t),...e})).json()}async function c(n,t={}){return await(await fetch(n,{...t,method:"GET"})).json()}async function u(n,t={}){return await(await fetch(n,t)).text()}async function p(n,t){try{return await n}catch(e){if(t!==void 0)return t;throw e}}export{u as fetchText,i as fetchWithTimeout,c as getJson,p as handleApiError,a as postJson};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Reads a file as a string (UTF-8).
3
+ * @param {string} filePath - The path to the file.
4
+ * @returns {Promise<string>} The file contents as a string.
5
+ */
6
+ export declare function readFileAsString(filePath: string): Promise<string>;
7
+ /**
8
+ * Writes a string to a file (UTF-8).
9
+ * @param {string} filePath - The path to the file.
10
+ * @param {string} data - The string data to write.
11
+ * @returns {Promise<void>}
12
+ */
13
+ export declare function writeFileAsString(filePath: string, data: string): Promise<void>;
14
+ /**
15
+ * Checks if a file exists.
16
+ * @param {string} filePath - The path to the file.
17
+ * @returns {Promise<boolean>} True if the file exists, false otherwise.
18
+ */
19
+ export declare function fileExists(filePath: string): Promise<boolean>;
20
+ /**
21
+ * Deletes a file.
22
+ * @param {string} filePath - The path to the file.
23
+ * @returns {Promise<void>}
24
+ */
25
+ export declare function deleteFile(filePath: string): Promise<void>;
26
+ /**
27
+ * Gets the file extension from a file path.
28
+ * @param {string} filePath - The path to the file.
29
+ * @returns {string} The file extension (including the dot), or an empty string if none.
30
+ */
31
+ export declare function getFileExtension(filePath: string): string;
32
+ //# sourceMappingURL=index.d.ts.map