@rtorcato/js-common 2.8.1 → 3.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 (141) hide show
  1. package/AGENTS.md +116 -0
  2. package/CHANGELOG.md +30 -0
  3. package/CONTRIBUTORS.md +5 -0
  4. package/README.md +71 -22
  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.d.ts +2 -0
  8. package/dist/arrays/arrays.test-d.d.ts.map +1 -0
  9. package/dist/arrays/arrays.test-d.js +1 -0
  10. package/dist/arrays/index.js +1 -1
  11. package/dist/boolean/index.d.ts +18 -6
  12. package/dist/boolean/index.d.ts.map +1 -1
  13. package/dist/boolean/index.js +1 -1
  14. package/dist/chunks/chunk-5IA77ERW.js +1 -0
  15. package/dist/chunks/chunk-7JQSIREC.js +1 -0
  16. package/dist/chunks/chunk-ARW46OJS.js +1 -0
  17. package/dist/chunks/chunk-MFJ5XPUX.js +1 -0
  18. package/dist/chunks/chunk-RBXTRLWB.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/index.d.ts +0 -14
  28. package/dist/currency/index.d.ts.map +1 -1
  29. package/dist/currency/index.js +1 -1
  30. package/dist/date/index.d.ts +16 -0
  31. package/dist/date/index.d.ts.map +1 -1
  32. package/dist/datetime/index.d.ts +21 -9
  33. package/dist/datetime/index.d.ts.map +1 -1
  34. package/dist/datetime/index.js +1 -1
  35. package/dist/emails/index.d.ts +22 -0
  36. package/dist/emails/index.d.ts.map +1 -1
  37. package/dist/emails/index.js +1 -1
  38. package/dist/env/index.d.ts +24 -0
  39. package/dist/env/index.d.ts.map +1 -1
  40. package/dist/errors/index.d.ts +30 -2
  41. package/dist/errors/index.d.ts.map +1 -1
  42. package/dist/events/index.d.ts +25 -1
  43. package/dist/events/index.d.ts.map +1 -1
  44. package/dist/events/index.js +1 -1
  45. package/dist/fetch/index.d.ts +25 -0
  46. package/dist/fetch/index.d.ts.map +1 -1
  47. package/dist/file/index.d.ts +20 -0
  48. package/dist/file/index.d.ts.map +1 -1
  49. package/dist/functions/functions.test-d.d.ts +2 -0
  50. package/dist/functions/functions.test-d.d.ts.map +1 -0
  51. package/dist/functions/functions.test-d.js +1 -0
  52. package/dist/functions/index.d.ts +32 -2
  53. package/dist/functions/index.d.ts.map +1 -1
  54. package/dist/functions/index.js +1 -1
  55. package/dist/geometry/index.d.ts +21 -0
  56. package/dist/geometry/index.d.ts.map +1 -1
  57. package/dist/html/index.d.ts +38 -0
  58. package/dist/html/index.d.ts.map +1 -1
  59. package/dist/html/index.js +1 -1
  60. package/dist/i18n/index.d.ts +23 -7
  61. package/dist/i18n/index.d.ts.map +1 -1
  62. package/dist/i18n/index.js +1 -1
  63. package/dist/interval/index.d.ts +15 -0
  64. package/dist/interval/index.d.ts.map +1 -1
  65. package/dist/json/index.d.ts +27 -0
  66. package/dist/json/index.d.ts.map +1 -1
  67. package/dist/logger/index.js +1 -1
  68. package/dist/logger/logger.d.ts +12 -2
  69. package/dist/logger/logger.d.ts.map +1 -1
  70. package/dist/logger/logger.js +1 -1
  71. package/dist/logging/index.d.ts +19 -0
  72. package/dist/logging/index.d.ts.map +1 -1
  73. package/dist/maps/index.d.ts +21 -0
  74. package/dist/maps/index.d.ts.map +1 -1
  75. package/dist/mime-types/index.d.ts +20 -0
  76. package/dist/mime-types/index.d.ts.map +1 -1
  77. package/dist/node/index.d.ts +0 -9
  78. package/dist/node/index.d.ts.map +1 -1
  79. package/dist/node/index.js +1 -1
  80. package/dist/numbers/index.d.ts +28 -12
  81. package/dist/numbers/index.d.ts.map +1 -1
  82. package/dist/numbers/index.js +1 -1
  83. package/dist/objects/index.d.ts +23 -0
  84. package/dist/objects/index.d.ts.map +1 -1
  85. package/dist/objects/index.js +1 -1
  86. package/dist/objects/objects.test-d.d.ts +2 -0
  87. package/dist/objects/objects.test-d.d.ts.map +1 -0
  88. package/dist/objects/objects.test-d.js +1 -0
  89. package/dist/os/index.d.ts +18 -0
  90. package/dist/os/index.d.ts.map +1 -1
  91. package/dist/process/index.d.ts +18 -0
  92. package/dist/process/index.d.ts.map +1 -1
  93. package/dist/promises/index.d.ts +29 -2
  94. package/dist/promises/index.d.ts.map +1 -1
  95. package/dist/promises/index.js +1 -1
  96. package/dist/promises/promises.test-d.d.ts +2 -0
  97. package/dist/promises/promises.test-d.d.ts.map +1 -0
  98. package/dist/promises/promises.test-d.js +1 -0
  99. package/dist/random/index.d.ts +21 -0
  100. package/dist/random/index.d.ts.map +1 -1
  101. package/dist/regex/index.d.ts +23 -0
  102. package/dist/regex/index.d.ts.map +1 -1
  103. package/dist/security/index.d.ts +36 -4
  104. package/dist/security/index.d.ts.map +1 -1
  105. package/dist/security/index.js +1 -1
  106. package/dist/sets/index.d.ts +19 -0
  107. package/dist/sets/index.d.ts.map +1 -1
  108. package/dist/sleep/index.d.ts +20 -0
  109. package/dist/sleep/index.d.ts.map +1 -1
  110. package/dist/strings/index.d.ts +0 -52
  111. package/dist/strings/index.d.ts.map +1 -1
  112. package/dist/strings/index.js +1 -1
  113. package/dist/system/index.d.ts +18 -0
  114. package/dist/system/index.d.ts.map +1 -1
  115. package/dist/time/index.d.ts +23 -4
  116. package/dist/time/index.d.ts.map +1 -1
  117. package/dist/try/trycatch.d.ts +24 -0
  118. package/dist/try/trycatch.d.ts.map +1 -1
  119. package/dist/try/trycatch.test-d.d.ts +2 -0
  120. package/dist/try/trycatch.test-d.d.ts.map +1 -0
  121. package/dist/try/trycatch.test-d.js +1 -0
  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 +10 -0
  127. package/dist/uuid/index.d.ts.map +1 -1
  128. package/dist/validation/index.d.ts +25 -0
  129. package/dist/validation/index.d.ts.map +1 -1
  130. package/dist/validation/index.js +1 -1
  131. package/package.json +25 -23
  132. package/dist/chunks/chunk-6J7HIWG6.js +0 -1
  133. package/dist/formatting/index.d.ts +0 -40
  134. package/dist/formatting/index.d.ts.map +0 -1
  135. package/dist/formatting/index.js +0 -1
  136. package/dist/math/index.d.ts +0 -37
  137. package/dist/math/index.d.ts.map +0 -1
  138. package/dist/math/index.js +0 -1
  139. package/dist/try/attempt.d.ts +0 -8
  140. package/dist/try/attempt.d.ts.map +0 -1
  141. package/dist/try/attempt.js +0 -1
@@ -1,5 +1,12 @@
1
1
  /**
2
2
  * Adds an event listener and returns a function to remove it.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const off = on(button, 'click', (event) => console.log(event.clientX))
7
+ * off() // listener removed
8
+ * ```
9
+ *
3
10
  * @param target The event target.
4
11
  * @param type The event type.
5
12
  * @param handler The event handler.
@@ -9,6 +16,13 @@
9
16
  export declare function on<K extends keyof HTMLElementEventMap>(target: EventTarget, type: K, handler: (event: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): () => void;
10
17
  /**
11
18
  * Dispatches a custom event on the target.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * on(window, 'click', () => {})
23
+ * emit(window, 'cart:add', { sku: 'A1' }) // true (nothing called preventDefault)
24
+ * ```
25
+ *
12
26
  * @param target The event target.
13
27
  * @param type The event type.
14
28
  * @param detail Optional detail data.
@@ -17,11 +31,21 @@ export declare function on<K extends keyof HTMLElementEventMap>(target: EventTar
17
31
  export declare function emit(target: EventTarget, type: string, detail?: unknown): boolean;
18
32
  /**
19
33
  * Waits for a single event to occur and resolves a promise.
34
+ *
35
+ * Named `onceEvent` rather than `once` so it cannot be confused with
36
+ * `functions.once`, which memoises a call rather than awaiting an event.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const event = await onceEvent(button, 'click')
41
+ * event.type // 'click'
42
+ * ```
43
+ *
20
44
  * @param target The event target.
21
45
  * @param type The event type.
22
46
  * @returns {Promise<Event>} Resolves with the event object.
23
47
  */
24
- export declare function once<K extends keyof HTMLElementEventMap>(target: EventTarget, type: K): Promise<HTMLElementEventMap[K]>;
48
+ export declare function onceEvent<K extends keyof HTMLElementEventMap>(target: EventTarget, type: K): Promise<HTMLElementEventMap[K]>;
25
49
  /**
26
50
  * Prevents the default action for an event.
27
51
  * @param event The event object.
@@ -1 +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,OAAO,GAAG,OAAO,CAEjF;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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;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;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAEjF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAC5D,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"}
@@ -1 +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};
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 onceEvent,a as preventDefault,s as stopPropagation};
@@ -1,5 +1,13 @@
1
1
  /**
2
2
  * Fetches a resource with a timeout.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * await fetchWithTimeout('https://api.example.com/health') // { status: 'ok' }
7
+ * await fetchWithTimeout('https://slow.example.com', {}, 500)
8
+ * // rejects with AbortError after 500ms
9
+ * ```
10
+ *
3
11
  * @param url The URL to fetch.
4
12
  * @param options Fetch options.
5
13
  * @param timeout Timeout in milliseconds (default: 8000).
@@ -8,6 +16,16 @@
8
16
  export declare function fetchWithTimeout(url: string, options?: RequestInit, timeout?: number): Promise<unknown>;
9
17
  /**
10
18
  * Sends a POST request with a JSON body.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const user = await postJson<{ name: string }, { id: number }>(
23
+ * 'https://api.example.com/users',
24
+ * { name: 'Ada' }
25
+ * )
26
+ * user.id // 42
27
+ * ```
28
+ *
11
29
  * @param url The URL to post to.
12
30
  * @param body The body to send.
13
31
  * @param options Additional fetch options.
@@ -16,6 +34,13 @@ export declare function fetchWithTimeout(url: string, options?: RequestInit, tim
16
34
  export declare function postJson<T = unknown, R = unknown>(url: string, body: T, options?: RequestInit): Promise<R>;
17
35
  /**
18
36
  * Sends a GET request and returns JSON.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const user = await getJson<{ id: number }>('https://api.example.com/users/42')
41
+ * user.id // 42
42
+ * ```
43
+ *
19
44
  * @param url The URL to fetch.
20
45
  * @param options Additional fetch options.
21
46
  * @returns The parsed JSON response.
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,OAAO,SAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;;;;;;;;;;;;;;GAgBG;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;;;;;;;;;;;;GAYG;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"}
@@ -1,11 +1,24 @@
1
1
  /**
2
2
  * Reads a file as a string (UTF-8).
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * await readFileAsString('./package.json') // '{\n "name": "@rtorcato/js-common",\n ...'
7
+ * ```
8
+ *
3
9
  * @param {string} filePath - The path to the file.
4
10
  * @returns {Promise<string>} The file contents as a string.
5
11
  */
6
12
  export declare function readFileAsString(filePath: string): Promise<string>;
7
13
  /**
8
14
  * Writes a string to a file (UTF-8).
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * await writeFileAsString('./out.txt', 'hello')
19
+ * await readFileAsString('./out.txt') // 'hello'
20
+ * ```
21
+ *
9
22
  * @param {string} filePath - The path to the file.
10
23
  * @param {string} data - The string data to write.
11
24
  * @returns {Promise<void>}
@@ -13,6 +26,13 @@ export declare function readFileAsString(filePath: string): Promise<string>;
13
26
  export declare function writeFileAsString(filePath: string, data: string): Promise<void>;
14
27
  /**
15
28
  * Checks if a file exists.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * await fileExists('./package.json') // true
33
+ * await fileExists('./nope.txt') // false
34
+ * ```
35
+ *
16
36
  * @param {string} filePath - The path to the file.
17
37
  * @returns {Promise<boolean>} True if the file exists, false otherwise.
18
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErF;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=functions.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.test-d.d.ts","sourceRoot":"","sources":["../../src/functions/functions.test-d.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{a as s,b as n,c as u}from"../chunks/chunk-RBXTRLWB.js";import"../chunks/chunk-ANN5UYCF.js";import{describe as f,expectTypeOf as t,it as o}from"vitest";f("functions \u2014 types",()=>{o("once preserves the wrapped function signature",()=>{let e=s((a,p)=>({id:a,label:p}));t(e).toEqualTypeOf(),t(e).parameters.toEqualTypeOf(),t(e).returns.toEqualTypeOf(),e("1","a")}),o("debounce preserves the wrapped function parameters",()=>{let e=n((a,p)=>{},100);t(e).parameters.toEqualTypeOf(),t(e).returns.toEqualTypeOf(),e(1,"a")}),o("throttle preserves the wrapped function parameters",()=>{let e=u(a=>{},100);t(e).parameters.toEqualTypeOf(),t(e).returns.toEqualTypeOf(),e({y:1})}),o("debounce/throttle return void even when the wrapped function returns a value",()=>{let r=e=>e*2;t(n(r,10)).returns.toEqualTypeOf(),t(u(r,10)).returns.toEqualTypeOf(),t(n(r,10)).parameters.toEqualTypeOf()})});
@@ -1,23 +1,53 @@
1
1
  /**
2
2
  * Returns a function that only calls the original function once.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * let calls = 0
7
+ * const init = once(() => ++calls)
8
+ * init() // 1
9
+ * init() // 1 (cached, not called again)
10
+ * calls // 1
11
+ * ```
12
+ *
3
13
  * @param fn The function to wrap.
4
14
  * @returns {Function}
5
15
  */
6
16
  export declare function once<T extends (...args: any[]) => any>(fn: T): T;
7
17
  /**
8
18
  * Returns a debounced version of a function.
19
+ * The wrapper defers the call, so it always returns `undefined` — never `fn`'s return value.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const search = debounce((term: string) => console.log(term), 300)
24
+ * search('a')
25
+ * search('ab')
26
+ * search('abc') // only 'abc' is logged, 300ms after the last call
27
+ * ```
28
+ *
9
29
  * @param fn The function to debounce.
10
30
  * @param wait Milliseconds to wait.
11
31
  * @returns {Function}
12
32
  */
13
- export declare function debounce<T extends (...args: any[]) => void>(fn: T, wait: number): T;
33
+ export declare function debounce<T extends (...args: any[]) => void>(fn: T, wait: number): (...args: Parameters<T>) => void;
14
34
  /**
15
35
  * Returns a throttled version of a function.
36
+ * The wrapper drops calls inside the window, so it always returns `undefined` — never `fn`'s
37
+ * return value.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const onScroll = throttle(() => console.log(window.scrollY), 100)
42
+ * window.addEventListener('scroll', onScroll)
43
+ * // fires at most once every 100ms, leading edge first
44
+ * ```
45
+ *
16
46
  * @param fn The function to throttle.
17
47
  * @param wait Milliseconds to wait between calls.
18
48
  * @returns {Function}
19
49
  */
20
- export declare function throttle<T extends (...args: any[]) => void>(fn: T, wait: number): T;
50
+ export declare function throttle<T extends (...args: any[]) => void>(fn: T, wait: number): (...args: Parameters<T>) => void;
21
51
  /**
22
52
  * Composes functions from right to left.
23
53
  * @param fns Functions to compose.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAUhE;AAED;;;;;GAKG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAMnF;AAED;;;;;GAKG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CASnF;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAEnE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAUhE;AAED;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAC1D,EAAE,EAAE,CAAC,EACL,IAAI,EAAE,MAAM,GACV,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAMlC;AAED;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAC1D,EAAE,EAAE,CAAC,EACL,IAAI,EAAE,MAAM,GACV,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CASlC;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAEnE"}
@@ -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;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED;;;;;;;GAOG;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;;;;;;;GAOG;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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geometry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,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
  * Runs a function repeatedly at a specified interval (cross-platform).
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const id = runInterval(() => console.log('tick'), 1000)
7
+ * // logs 'tick' once a second until cleared
8
+ * clearIntervalById(id)
9
+ * ```
10
+ *
3
11
  * @param fn The function to run.
4
12
  * @param ms The interval in milliseconds.
5
13
  * @returns The interval ID (NodeJS.Timeout or number).
@@ -7,6 +15,13 @@
7
15
  export declare function runInterval(fn: () => void, ms: number): ReturnType<typeof setInterval>;
8
16
  /**
9
17
  * Cancels an interval by its ID (cross-platform).
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const id = runInterval(() => console.log('tick'), 1000)
22
+ * clearIntervalById(id) // no more ticks
23
+ * ```
24
+ *
10
25
  * @param id The interval ID (NodeJS.Timeout or number).
11
26
  */
12
27
  export declare function clearIntervalById(id: ReturnType<typeof setInterval>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interval/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAEtF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,IAAI,CAE1E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interval/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAEtF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,IAAI,CAE1E"}
@@ -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,6 +33,14 @@ 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
  */
@@ -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;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAE5C"}
@@ -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{a as o}from"../chunks/chunk-MFJ5XPUX.js";import"../chunks/chunk-FBDKWWIQ.js";import"../chunks/chunk-ANN5UYCF.js";export{o as logger};
@@ -1,7 +1,17 @@
1
1
  import pino from 'pino';
2
2
  /**
3
- * Pre-configured Pino logger — pretty-printed with colors in development, plain JSON
4
- * at `info` level in production.
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
+ * ```
5
15
  */
6
16
  export declare const logger: pino.Logger<never, boolean>;
7
17
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAGvB;;;GAGG;AACH,eAAO,MAAM,MAAM,6BAyBO,CAAA"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;AAgBvB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,6BA0BQ,CAAA"}
@@ -1 +1 @@
1
- import{a}from"../chunks/chunk-6J7HIWG6.js";import"../chunks/chunk-FBDKWWIQ.js";import"../chunks/chunk-ANN5UYCF.js";export{a as logger};
1
+ import{a}from"../chunks/chunk-MFJ5XPUX.js";import"../chunks/chunk-FBDKWWIQ.js";import"../chunks/chunk-ANN5UYCF.js";export{a 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
  */