@rtorcato/js-common 2.8.2 → 4.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 (160) hide show
  1. package/AGENTS.md +114 -0
  2. package/CHANGELOG.md +23 -0
  3. package/CONTRIBUTORS.md +5 -0
  4. package/README.md +75 -26
  5. package/dist/abortController/index.d.ts +30 -0
  6. package/dist/abortController/index.d.ts.map +1 -1
  7. package/dist/arrays/arrays.test-d.js +1 -1
  8. package/dist/arrays/index.d.ts +0 -63
  9. package/dist/arrays/index.d.ts.map +1 -1
  10. package/dist/arrays/index.js +1 -1
  11. package/dist/boolean/index.d.ts +10 -33
  12. package/dist/boolean/index.d.ts.map +1 -1
  13. package/dist/boolean/index.js +1 -1
  14. package/dist/chunks/chunk-AVPQVYSA.js +1 -0
  15. package/dist/chunks/chunk-H7PB4TAW.js +1 -0
  16. package/dist/chunks/chunk-HUTZTT4Y.js +1 -0
  17. package/dist/chunks/chunk-RBXTRLWB.js +1 -0
  18. package/dist/chunks/chunk-UQBVI52L.js +1 -0
  19. package/dist/cli/catalog.js +131 -0
  20. package/dist/cli/cli.mjs +16 -109
  21. package/dist/colors/index.d.ts +23 -3
  22. package/dist/colors/index.d.ts.map +1 -1
  23. package/dist/console/index.d.ts +12 -0
  24. package/dist/console/index.d.ts.map +1 -1
  25. package/dist/crypto/index.d.ts +23 -0
  26. package/dist/crypto/index.d.ts.map +1 -1
  27. package/dist/currency/currencies.d.ts +1 -1
  28. package/dist/currency/currencies.d.ts.map +1 -1
  29. package/dist/currency/currencies.js +1 -1
  30. package/dist/currency/index.d.ts +0 -14
  31. package/dist/currency/index.d.ts.map +1 -1
  32. package/dist/currency/index.js +1 -1
  33. package/dist/date/index.d.ts +16 -0
  34. package/dist/date/index.d.ts.map +1 -1
  35. package/dist/datetime/index.d.ts +21 -9
  36. package/dist/datetime/index.d.ts.map +1 -1
  37. package/dist/datetime/index.js +1 -1
  38. package/dist/emails/index.d.ts +22 -0
  39. package/dist/emails/index.d.ts.map +1 -1
  40. package/dist/emails/index.js +1 -1
  41. package/dist/env/index.d.ts +24 -0
  42. package/dist/env/index.d.ts.map +1 -1
  43. package/dist/errors/index.d.ts +30 -2
  44. package/dist/errors/index.d.ts.map +1 -1
  45. package/dist/events/index.d.ts +25 -1
  46. package/dist/events/index.d.ts.map +1 -1
  47. package/dist/events/index.js +1 -1
  48. package/dist/fetch/index.d.ts +25 -0
  49. package/dist/fetch/index.d.ts.map +1 -1
  50. package/dist/file/index.d.ts +20 -0
  51. package/dist/file/index.d.ts.map +1 -1
  52. package/dist/functions/functions.test-d.d.ts +2 -0
  53. package/dist/functions/functions.test-d.d.ts.map +1 -0
  54. package/dist/functions/functions.test-d.js +1 -0
  55. package/dist/functions/index.d.ts +32 -2
  56. package/dist/functions/index.d.ts.map +1 -1
  57. package/dist/functions/index.js +1 -1
  58. package/dist/geometry/index.d.ts +21 -0
  59. package/dist/geometry/index.d.ts.map +1 -1
  60. package/dist/html/index.d.ts +38 -0
  61. package/dist/html/index.d.ts.map +1 -1
  62. package/dist/html/index.js +1 -1
  63. package/dist/i18n/index.d.ts +23 -7
  64. package/dist/i18n/index.d.ts.map +1 -1
  65. package/dist/i18n/index.js +1 -1
  66. package/dist/json/index.d.ts +27 -7
  67. package/dist/json/index.d.ts.map +1 -1
  68. package/dist/json/index.js +1 -1
  69. package/dist/logger/index.d.ts +16 -1
  70. package/dist/logger/index.d.ts.map +1 -1
  71. package/dist/logger/index.js +1 -1
  72. package/dist/logging/index.d.ts +19 -0
  73. package/dist/logging/index.d.ts.map +1 -1
  74. package/dist/maps/index.d.ts +21 -0
  75. package/dist/maps/index.d.ts.map +1 -1
  76. package/dist/mime-types/db.d.ts +5 -922
  77. package/dist/mime-types/db.d.ts.map +1 -1
  78. package/dist/mime-types/db.js +1 -1
  79. package/dist/mime-types/index.d.ts +20 -0
  80. package/dist/mime-types/index.d.ts.map +1 -1
  81. package/dist/mime-types/index.js +1 -1
  82. package/dist/node/index.d.ts +0 -9
  83. package/dist/node/index.d.ts.map +1 -1
  84. package/dist/node/index.js +1 -1
  85. package/dist/numbers/index.d.ts +28 -36
  86. package/dist/numbers/index.d.ts.map +1 -1
  87. package/dist/numbers/index.js +1 -1
  88. package/dist/objects/index.d.ts +23 -7
  89. package/dist/objects/index.d.ts.map +1 -1
  90. package/dist/objects/index.js +1 -1
  91. package/dist/objects/objects.test-d.js +1 -1
  92. package/dist/os/index.d.ts +18 -0
  93. package/dist/os/index.d.ts.map +1 -1
  94. package/dist/process/index.d.ts +18 -0
  95. package/dist/process/index.d.ts.map +1 -1
  96. package/dist/promises/index.d.ts +21 -26
  97. package/dist/promises/index.d.ts.map +1 -1
  98. package/dist/promises/index.js +1 -1
  99. package/dist/promises/promises.test-d.d.ts +2 -0
  100. package/dist/promises/promises.test-d.d.ts.map +1 -0
  101. package/dist/promises/promises.test-d.js +1 -0
  102. package/dist/random/index.d.ts +21 -0
  103. package/dist/random/index.d.ts.map +1 -1
  104. package/dist/regex/index.d.ts +23 -0
  105. package/dist/regex/index.d.ts.map +1 -1
  106. package/dist/security/index.d.ts +36 -4
  107. package/dist/security/index.d.ts.map +1 -1
  108. package/dist/security/index.js +1 -1
  109. package/dist/sleep/index.d.ts +20 -0
  110. package/dist/sleep/index.d.ts.map +1 -1
  111. package/dist/strings/index.d.ts +0 -75
  112. package/dist/strings/index.d.ts.map +1 -1
  113. package/dist/strings/index.js +1 -1
  114. package/dist/system/index.d.ts +18 -0
  115. package/dist/system/index.d.ts.map +1 -1
  116. package/dist/time/index.d.ts +23 -4
  117. package/dist/time/index.d.ts.map +1 -1
  118. package/dist/try/index.d.ts +52 -1
  119. package/dist/try/index.d.ts.map +1 -1
  120. package/dist/try/index.js +1 -1
  121. package/dist/try/trycatch.test-d.js +1 -1
  122. package/dist/types/index.d.ts +0 -1
  123. package/dist/url/index.d.ts +23 -0
  124. package/dist/url/index.d.ts.map +1 -1
  125. package/dist/url/index.js +1 -1
  126. package/dist/uuid/index.d.ts +5 -5
  127. package/dist/uuid/index.d.ts.map +1 -1
  128. package/dist/uuid/index.js +1 -1
  129. package/dist/validation/index.d.ts +25 -0
  130. package/dist/validation/index.d.ts.map +1 -1
  131. package/dist/validation/index.js +1 -1
  132. package/package.json +23 -37
  133. package/dist/chunks/chunk-5IA77ERW.js +0 -1
  134. package/dist/chunks/chunk-6J7HIWG6.js +0 -1
  135. package/dist/chunks/chunk-ARW46OJS.js +0 -1
  136. package/dist/chunks/chunk-W72HFHZY.js +0 -1
  137. package/dist/emails/banned/index.d.ts +0 -9
  138. package/dist/emails/banned/index.d.ts.map +0 -1
  139. package/dist/formatting/index.d.ts +0 -40
  140. package/dist/formatting/index.d.ts.map +0 -1
  141. package/dist/formatting/index.js +0 -1
  142. package/dist/interval/index.d.ts +0 -13
  143. package/dist/interval/index.d.ts.map +0 -1
  144. package/dist/interval/index.js +0 -1
  145. package/dist/logger/logger.d.ts +0 -7
  146. package/dist/logger/logger.d.ts.map +0 -1
  147. package/dist/logger/logger.js +0 -1
  148. package/dist/math/index.d.ts +0 -37
  149. package/dist/math/index.d.ts.map +0 -1
  150. package/dist/math/index.js +0 -1
  151. package/dist/sets/index.d.ts +0 -48
  152. package/dist/sets/index.d.ts.map +0 -1
  153. package/dist/sets/index.js +0 -1
  154. package/dist/try/attempt.d.ts +0 -8
  155. package/dist/try/attempt.d.ts.map +0 -1
  156. package/dist/try/attempt.js +0 -1
  157. package/dist/try/trycatch.d.ts +0 -29
  158. package/dist/try/trycatch.d.ts.map +0 -1
  159. package/dist/try/trycatch.js +0 -1
  160. /package/dist/chunks/{chunk-XAQ7VMV4.js → chunk-J4C2KNK5.js} +0 -0
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function o(n){let t=!1,e;return function(...r){return t||(t=!0,e=n.apply(this,r)),e}}function T(n,t){let e;return function(...r){clearTimeout(e),e=setTimeout(()=>n.apply(this,r),t)}}function u(n,t){let e=0;return function(...r){let a=Date.now();a-e>=t&&(e=a,n.apply(this,r))}}function i(...n){return t=>n.reduceRight((e,r)=>r(e),t)}function s(...n){return t=>n.reduce((e,r)=>r(e),t)}export{i as compose,T as debounce,o as once,s as pipe,u as throttle};
1
+ import{a,b,c,d,e}from"../chunks/chunk-RBXTRLWB.js";import"../chunks/chunk-ANN5UYCF.js";export{d as compose,b as debounce,a as once,e as pipe,c as throttle};
@@ -1,5 +1,12 @@
1
1
  /**
2
2
  * Calculates the distance between two points in 2D space.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * distance2D(0, 0, 3, 4) // 5
7
+ * distance2D(1, 1, 1, 1) // 0
8
+ * ```
9
+ *
3
10
  * @param x1 X coordinate of first point.
4
11
  * @param y1 Y coordinate of first point.
5
12
  * @param x2 X coordinate of second point.
@@ -9,6 +16,13 @@
9
16
  export declare function distance2D(x1: number, y1: number, x2: number, y2: number): number;
10
17
  /**
11
18
  * Calculates the midpoint between two points in 2D space.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * midpoint2D(0, 0, 4, 6) // [2, 3]
23
+ * midpoint2D(-2, 5, 2, 5) // [0, 5]
24
+ * ```
25
+ *
12
26
  * @param x1 X coordinate of first point.
13
27
  * @param y1 Y coordinate of first point.
14
28
  * @param x2 X coordinate of second point.
@@ -18,6 +32,13 @@ export declare function distance2D(x1: number, y1: number, x2: number, y2: numbe
18
32
  export declare function midpoint2D(x1: number, y1: number, x2: number, y2: number): [number, number];
19
33
  /**
20
34
  * Calculates the angle (in radians) between two points in 2D space.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * angle2D(0, 0, 1, 0) // 0
39
+ * angle2D(0, 0, 0, 1) // 1.5707963267948966 (Math.PI / 2)
40
+ * ```
41
+ *
21
42
  * @param x1 X coordinate of first point.
22
43
  * @param y1 Y coordinate of first point.
23
44
  * @param x2 X coordinate of second point.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geometry/index.ts"],"names":[],"mappings":"AAAA;;;;;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,GAAG,MAAM,CAEjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAC1B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACR,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC3B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACR,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CAY9D"}
@@ -1,17 +1,50 @@
1
1
  /**
2
2
  * Escapes special HTML characters in a string to prevent XSS attacks.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * escapeHtml('<script>alert("x")</script>')
7
+ * // '&lt;script&gt;alert(&quot;x&quot;)&lt;/script&gt;'
8
+ * escapeHtml("Tom & Jerry's") // 'Tom &amp; Jerry&#39;s'
9
+ * ```
10
+ *
3
11
  * @param str The string to escape.
4
12
  * @returns The escaped string.
5
13
  */
6
14
  export declare function escapeHtml(str: string): string;
7
15
  /**
8
16
  * Unescapes HTML entities in a string.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * unescapeHtml('&lt;b&gt;hi&lt;/b&gt;') // '<b>hi</b>'
21
+ * unescapeHtml('Tom &amp; Jerry') // 'Tom & Jerry'
22
+ * unescapeHtml('a&#x2F;b&nbsp;c') // 'a/b c'
23
+ * ```
24
+ *
9
25
  * @param str The string to unescape.
10
26
  * @returns The unescaped string.
11
27
  */
12
28
  export declare function unescapeHtml(str: string): string;
13
29
  /**
14
30
  * Strips all HTML tags from a string.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * stripHtmlTags('<p>Hello <b>world</b></p>') // 'Hello world'
35
+ * stripHtmlTags('plain text') // 'plain text'
36
+ *
37
+ * // Strips `<…>` spans, so ragged input leaves residue — not a sanitizer.
38
+ * stripHtmlTags('<<a>script>') // 'script>'
39
+ * stripHtmlTags('<scr<x>ipt>') // 'ipt>'
40
+ * ```
41
+ *
42
+ * Removes `<…>` spans and nothing else: it does not decode entities and does
43
+ * not understand attributes or quoting, so ragged or nested markup leaves
44
+ * attacker-controlled residue behind rather than a safe string. Not a
45
+ * substitute for a real sanitizer such as DOMPurify when rendering untrusted
46
+ * HTML — this produces display text, it does not make untrusted markup safe.
47
+ *
15
48
  * @param str The string to strip tags from.
16
49
  * @returns The plain text string.
17
50
  */
@@ -24,6 +57,11 @@ export declare function stripHtmlTags(str: string): string;
24
57
  export declare function textToHtml(str: string): string;
25
58
  /**
26
59
  * Checks if a string contains any HTML tags.
60
+ *
61
+ * A heuristic for "does this look like markup", not a security gate: it only
62
+ * looks for a non-empty `<…>` span, so `'a<b'` and `'<>'` are both false. Do
63
+ * not use it to decide whether untrusted input is safe to render.
64
+ *
27
65
  * @param str The string to check.
28
66
  * @returns True if the string contains HTML tags, false otherwise.
29
67
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/html/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/html/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAehD;AAkBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMjD"}
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function t(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function r(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function n(e){return e.replace(/<[^>]*>/g,"")}function g(e){return e.replace(/\n/g,"<br>")}function p(e){return/<[^>]+>/.test(e)}export{p as containsHtml,t as escapeHtml,n as stripHtmlTags,g as textToHtml,r as unescapeHtml};
1
+ import"../chunks/chunk-ANN5UYCF.js";function o(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function c(e){let n={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#x27;":"'","&#x2F;":"/","&nbsp;":" "};return e.replace(/&(?:amp|lt|gt|quot|#39|#x27|#x2F|nbsp);/g,t=>n[t]??t)}function l(e,n){let t=e.indexOf("<",n);if(t===-1)return null;let r=e.indexOf(">",t+1);return r===-1?null:{open:t,close:r}}function i(e){let n="",t=0;for(let r=l(e,t);r;r=l(e,t))n+=e.slice(t,r.open),t=r.close+1;return n+e.slice(t)}function s(e){return e.replace(/\n/g,"<br>")}function g(e){for(let n=l(e,0);n;n=l(e,n.close+1))if(n.close>n.open+1)return!0;return!1}export{g as containsHtml,o as escapeHtml,i as stripHtmlTags,s as textToHtml,c as unescapeHtml};
@@ -1,10 +1,25 @@
1
1
  /**
2
2
  * Detects the user's preferred language from the browser or Node.js environment.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * detectLanguage() // 'en' (from navigator.language 'en-GB' or LANG 'en_US.UTF-8')
7
+ * detectLanguage('fr') // 'fr' when nothing can be detected
8
+ * ```
9
+ *
3
10
  * @returns {string} The language code (e.g., 'en', 'fr').
4
11
  */
5
12
  export declare function detectLanguage(defaultLang?: string): string;
6
13
  /**
7
14
  * Formats a number as a localized string.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * formatNumber(1234.5, 'en-US') // '1,234.5'
19
+ * formatNumber(1234.5, 'de-DE') // '1.234,5'
20
+ * formatNumber(0.42, 'en-US', { style: 'percent' }) // '42%'
21
+ * ```
22
+ *
8
23
  * @param value The number to format.
9
24
  * @param locale The locale code (e.g., 'en-US').
10
25
  * @param options Intl.NumberFormat options.
@@ -13,6 +28,14 @@ export declare function detectLanguage(defaultLang?: string): string;
13
28
  export declare function formatNumber(value: number, locale?: string, options?: Intl.NumberFormatOptions): string;
14
29
  /**
15
30
  * Formats a date as a localized string.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const d = new Date('2026-08-11T12:00:00Z')
35
+ * formatDateI18n(d, 'en-US', { timeZone: 'UTC' }) // '8/11/2026'
36
+ * formatDateI18n(d, 'en-GB', { timeZone: 'UTC' }) // '11/08/2026'
37
+ * ```
38
+ *
16
39
  * @param date The date to format.
17
40
  * @param locale The locale code (e.g., 'en-US').
18
41
  * @param options Intl.DateTimeFormat options.
@@ -27,11 +50,4 @@ export declare function formatDateI18n(date: Date, locale?: string, options?: In
27
50
  * @returns {string}
28
51
  */
29
52
  export declare function t(key: string, dict: Record<string, Record<string, string>>, lang?: string): string;
30
- /**
31
- * Pluralizes a word based on a count (basic English only).
32
- * @param word The word to pluralize.
33
- * @param count The count.
34
- * @returns {string}
35
- */
36
- export declare function pluralize(word: string, count: number): string;
37
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,GAAE,MAAa,GAAG,MAAM,CAQjE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAChC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAClC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,CAAC,CAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC5C,IAAI,CAAC,EAAE,MAAM,GACX,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,WAAW,GAAE,MAAa,GAAG,MAAM,CAQjE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAChC,MAAM,CAER;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAClC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,CAAC,CAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC5C,IAAI,CAAC,EAAE,MAAM,GACX,MAAM,CAGR"}
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function i(n="en"){return typeof navigator<"u"&&navigator.language?navigator.language.split("-")[0]||n:typeof process<"u"&&process.env.LANG&&(process.env.LANG??"en").split("_")[0]||n}function o(n,t,r){return new Intl.NumberFormat(t,r).format(n)}function s(n,t,r){return new Intl.DateTimeFormat(t,r).format(n)}function a(n,t,r){let e=r||i();return t[e]?.[n]||t.en?.[n]||n}function g(n,t){return t===1?n:`${n}s`}export{i as detectLanguage,s as formatDateI18n,o as formatNumber,g as pluralize,a as t};
1
+ import"../chunks/chunk-ANN5UYCF.js";function i(n="en"){return typeof navigator<"u"&&navigator.language?navigator.language.split("-")[0]||n:typeof process<"u"&&process.env.LANG&&(process.env.LANG??"en").split("_")[0]||n}function o(n,t,r){return new Intl.NumberFormat(t,r).format(n)}function s(n,t,r){return new Intl.DateTimeFormat(t,r).format(n)}function a(n,t,r){let e=r||i();return t[e]?.[n]||t.en?.[n]||n}export{i as detectLanguage,s as formatDateI18n,o as formatNumber,a as t};
@@ -1,5 +1,13 @@
1
1
  /**
2
2
  * Safely parses a JSON string, returning a fallback value if parsing fails.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * safeJsonParse('{"a":1}') // { a: 1 }
7
+ * safeJsonParse('{oops') // null
8
+ * safeJsonParse('{oops', {}) // {}
9
+ * ```
10
+ *
3
11
  * @param {string} str - The JSON string to parse.
4
12
  * @param {any} [fallback=null] - The value to return if parsing fails.
5
13
  * @returns The parsed object or the fallback value.
@@ -7,6 +15,17 @@
7
15
  export declare function safeJsonParse<T = any>(str: string, fallback?: T | null): T | null;
8
16
  /**
9
17
  * Safely stringifies a value to JSON, returning a fallback value if stringification fails.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * safeJsonStringify({ a: 1 }) // '{"a":1}'
22
+ *
23
+ * const circular: any = {}
24
+ * circular.self = circular
25
+ * safeJsonStringify(circular) // null
26
+ * safeJsonStringify(circular, '{}') // '{}'
27
+ * ```
28
+ *
10
29
  * @param {any} value - The value to stringify.
11
30
  * @param {string} [fallback=null] - The value to return if stringification fails.
12
31
  * @returns The JSON string or the fallback value.
@@ -14,15 +33,16 @@ export declare function safeJsonParse<T = any>(str: string, fallback?: T | null)
14
33
  export declare function safeJsonStringify(value: any, fallback?: string | null): string | null;
15
34
  /**
16
35
  * Checks if a string is valid JSON.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * isValidJson('{"a":1}') // true
40
+ * isValidJson('[1,2]') // true
41
+ * isValidJson('{oops') // false
42
+ * ```
43
+ *
17
44
  * @param {string} str - The string to check.
18
45
  * @returns {boolean} True if the string is valid JSON, false otherwise.
19
46
  */
20
47
  export declare function isValidJson(str: string): boolean;
21
- /**
22
- * Deep clones a value using JSON serialization.
23
- * Note: Only works for JSON-safe values (no functions, undefined, etc).
24
- * @param {T} value - The value to clone.
25
- * @returns {T} The deep-cloned value.
26
- */
27
- export declare function deepCloneJson<T>(value: T): T;
28
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,CAAC,GAAG,IAAW,GAAG,CAAC,GAAG,IAAI,CAMvF;AAED;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,GAAG,IAAI,CAM3F;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOhD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAE5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,CAAC,GAAG,IAAW,GAAG,CAAC,GAAG,IAAI,CAMvF;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,GAAG,IAAI,CAM3F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOhD"}
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function t(n,r=null){try{return JSON.parse(n)}catch{return r}}function e(n,r=null){try{return JSON.stringify(n)}catch{return r}}function s(n){try{return JSON.parse(n),!0}catch{return!1}}function u(n){return JSON.parse(JSON.stringify(n))}export{u as deepCloneJson,s as isValidJson,t as safeJsonParse,e as safeJsonStringify};
1
+ import"../chunks/chunk-ANN5UYCF.js";function t(n,r=null){try{return JSON.parse(n)}catch{return r}}function e(n,r=null){try{return JSON.stringify(n)}catch{return r}}function s(n){try{return JSON.parse(n),!0}catch{return!1}}export{s as isValidJson,t as safeJsonParse,e as safeJsonStringify};
@@ -1,2 +1,17 @@
1
- export * from './logger';
1
+ import pino from 'pino';
2
+ /**
3
+ * Pre-configured Pino logger — pretty-printed with colors in development (when
4
+ * `pino-pretty` is installed), plain JSON at `info` level in production.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * logger.info('server started')
9
+ * // dev: 14:03:27 INFO: server started
10
+ * // prod: {"level":30,"msg":"server started"}
11
+ *
12
+ * logger.error({ err }, 'upload failed')
13
+ * logger.debug('only visible in development')
14
+ * ```
15
+ */
16
+ export declare const logger: pino.Logger<never, boolean>;
2
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;AAgBvB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,6BA0BQ,CAAA"}
@@ -1 +1 @@
1
- import{a as o}from"../chunks/chunk-6J7HIWG6.js";import"../chunks/chunk-FBDKWWIQ.js";import"../chunks/chunk-ANN5UYCF.js";export{o as logger};
1
+ import{b as e}from"../chunks/chunk-FBDKWWIQ.js";import"../chunks/chunk-ANN5UYCF.js";import{createRequire as t}from"node:module";import r from"pino";function o(){try{return t(import.meta.url).resolve("pino-pretty"),!0}catch{return!1}}var s=e()&&o()?r({level:"debug",transport:{target:"pino-pretty",options:{colorize:!0,ignore:"pid,hostname,time",levelFirst:!1,singleLine:!0,customColors:"err:red,info:blue",translateTime:"HH:MM:ss"}}}):r({level:"info"});export{s as logger};
@@ -1,16 +1,35 @@
1
1
  /**
2
2
  * Logs a message with a timestamp.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * logWithTimestamp('server started') // [2026-08-11T14:03:27.913Z] server started
7
+ * logWithTimestamp('disk almost full', 'warn') // via console.warn
8
+ * ```
9
+ *
3
10
  * @param message The message to log.
4
11
  * @param level The log level (default: 'info').
5
12
  */
6
13
  export declare function logWithTimestamp(message: string, level?: 'info' | 'warn' | 'error'): void;
7
14
  /**
8
15
  * Logs a warning message.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * warn('deprecated option') // [WARN] deprecated option
20
+ * ```
21
+ *
9
22
  * @param message The warning message.
10
23
  */
11
24
  export declare function warn(message: string): void;
12
25
  /**
13
26
  * Logs an error message.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * error('upload failed') // [ERROR] upload failed
31
+ * ```
32
+ *
14
33
  * @param message The error message.
15
34
  */
16
35
  export declare function error(message: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,MAAM,GAAG,OAAgB,GAAG,IAAI,CAIjG;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG1C;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG3C;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG1C;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GACxD,MAAM,IAAI,CAgBZ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,MAAM,GAAG,OAAgB,GAAG,IAAI,CAIjG;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG3C;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG1C;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GACxD,MAAM,IAAI,CAgBZ"}
@@ -1,11 +1,25 @@
1
1
  /**
2
2
  * Inverts a Map (swaps keys and values). If duplicate values exist, later keys overwrite earlier ones.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * invertMap(new Map([['a', 1], ['b', 2]]))
7
+ * // Map { 1 => 'a', 2 => 'b' }
8
+ * ```
9
+ *
3
10
  * @param map The map to invert.
4
11
  * @returns {Map<any, any>} The inverted map.
5
12
  */
6
13
  export declare function invertMap<K, V>(map: Map<K, V>): Map<V, K>;
7
14
  /**
8
15
  * Maps the values of a Map using a function.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * mapValues(new Map([['a', 1], ['b', 2]]), (v) => v * 10)
20
+ * // Map { 'a' => 10, 'b' => 20 }
21
+ * ```
22
+ *
9
23
  * @param map The map to map over.
10
24
  * @param fn The function to apply to each value.
11
25
  * @returns {Map<K, U>} A new map with mapped values.
@@ -13,6 +27,13 @@ export declare function invertMap<K, V>(map: Map<K, V>): Map<V, K>;
13
27
  export declare function mapValues<K, V, U>(map: Map<K, V>, fn: (value: V, key: K) => U): Map<K, U>;
14
28
  /**
15
29
  * Merges two or more maps. Later maps overwrite earlier keys.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * mergeMaps(new Map([['a', 1]]), new Map([['a', 9], ['b', 2]]))
34
+ * // Map { 'a' => 9, 'b' => 2 }
35
+ * ```
36
+ *
16
37
  * @param maps The maps to merge.
17
38
  * @returns {Map<K, V>} The merged map.
18
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/maps/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAMzD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAMzF;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,C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