tiny-essentials 1.28.0 → 1.28.2

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 (323) hide show
  1. package/changelog/1/28/1.md +23 -0
  2. package/changelog/1/28/2.md +43 -0
  3. package/dist/_/numbers.d.mts +91 -16
  4. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  5. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  6. package/dist/v1/TinyAnalogClock.min.js +1 -1
  7. package/dist/v1/TinyBasicsEs.min.js +1 -1
  8. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  9. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  10. package/dist/v1/TinyDragger.min.js +1 -1
  11. package/dist/v1/TinyElementObserver.min.js +1 -1
  12. package/dist/v1/TinyEssentials.min.js +1 -1
  13. package/dist/v1/TinyGamepad.min.js +1 -1
  14. package/dist/v1/TinyHtml.min.js +1 -1
  15. package/dist/v1/TinyI18.min.js +1 -1
  16. package/dist/v1/TinyIframeEvents.min.js +1 -1
  17. package/dist/v1/TinyLocalStorage.min.js +1 -1
  18. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  19. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  20. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  21. package/dist/v1/TinyRadioFm.min.js +1 -1
  22. package/dist/v1/TinyRateLimiter.min.js +1 -1
  23. package/dist/v1/TinySmartScroller.min.js +1 -1
  24. package/dist/v1/TinyTextDiffer.min.js +1 -1
  25. package/dist/v1/TinyTextarea.min.js +1 -1
  26. package/dist/v1/TinyTimeout.min.js +1 -1
  27. package/dist/v1/TinyToastNotify.min.js +1 -1
  28. package/dist/v1/TinyUploadClicker.min.js +1 -1
  29. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  30. package/dist/v1/basics/array.cjs +57 -9
  31. package/dist/v1/basics/array.d.mts +28 -12
  32. package/dist/v1/basics/array.mjs +51 -9
  33. package/dist/v1/basics/clock.cjs +94 -42
  34. package/dist/v1/basics/clock.d.mts +22 -22
  35. package/dist/v1/basics/clock.mjs +91 -54
  36. package/dist/v1/basics/collision.d.mts +245 -104
  37. package/dist/v1/basics/deprecated/html.cjs +246 -0
  38. package/dist/v1/basics/deprecated/html.d.mts +63 -0
  39. package/dist/v1/basics/deprecated/html.mjs +190 -0
  40. package/dist/v1/basics/extendObjType/Buffer.d.mts +1 -1
  41. package/dist/v1/basics/fullScreen.d.mts +47 -7
  42. package/dist/v1/basics/html.cjs +149 -130
  43. package/dist/v1/basics/html.d.mts +69 -113
  44. package/dist/v1/basics/html.mjs +113 -105
  45. package/dist/v1/basics/index.cjs +2 -0
  46. package/dist/v1/basics/index.d.mts +11 -65
  47. package/dist/v1/basics/index.mjs +3 -3
  48. package/dist/v1/basics/mediaContent.cjs +116 -32
  49. package/dist/v1/basics/mediaContent.d.mts +143 -159
  50. package/dist/v1/basics/mediaContent.mjs +105 -33
  51. package/dist/v1/basics/objChecker.cjs +7 -5
  52. package/dist/v1/basics/objChecker.d.mts +5 -4
  53. package/dist/v1/basics/objChecker.mjs +6 -6
  54. package/dist/v1/basics/objFilter.cjs +71 -14
  55. package/dist/v1/basics/objFilter.d.mts +16 -19
  56. package/dist/v1/basics/objFilter.mjs +63 -14
  57. package/dist/v1/basics/simpleMath.cjs +81 -25
  58. package/dist/v1/basics/simpleMath.d.mts +22 -22
  59. package/dist/v1/basics/simpleMath.mjs +70 -27
  60. package/dist/v1/basics/text.cjs +76 -31
  61. package/dist/v1/basics/text.d.mts +64 -14
  62. package/dist/v1/basics/text.mjs +62 -31
  63. package/dist/v1/build/ColorSafeStringify.d.mts +1 -1
  64. package/dist/v1/build/TinyAdvancedRaffle.d.mts +1 -1
  65. package/dist/v1/build/TinyAfterScrollWatcher.d.mts +1 -1
  66. package/dist/v1/build/TinyAnalogClock.d.mts +1 -1
  67. package/dist/v1/build/TinyArrayComparator.d.mts +1 -1
  68. package/dist/v1/build/TinyArrayPaginator.d.mts +1 -1
  69. package/dist/v1/build/TinyClassManager.d.mts +1 -1
  70. package/dist/v1/build/TinyClipboard.d.mts +1 -1
  71. package/dist/v1/build/TinyColorConverter.d.mts +1 -1
  72. package/dist/v1/build/TinyColorValidator.d.mts +1 -1
  73. package/dist/v1/build/TinyCookieConsent.d.mts +1 -1
  74. package/dist/v1/build/TinyDayNightCycle.d.mts +1 -1
  75. package/dist/v1/build/TinyDomReadyManager.d.mts +1 -1
  76. package/dist/v1/build/TinyDragDropDetector.d.mts +1 -1
  77. package/dist/v1/build/TinyDragger.d.mts +1 -1
  78. package/dist/v1/build/TinyElementObserver.d.mts +1 -1
  79. package/dist/v1/build/TinyGamepad.d.mts +1 -1
  80. package/dist/v1/build/TinyHtml.d.mts +1 -1
  81. package/dist/v1/build/TinyI18.d.mts +1 -1
  82. package/dist/v1/build/TinyIframeEvents.d.mts +1 -1
  83. package/dist/v1/build/TinyInventory.d.mts +1 -1
  84. package/dist/v1/build/TinyInventoryTrader.d.mts +1 -1
  85. package/dist/v1/build/TinyLevelUp.d.mts +1 -1
  86. package/dist/v1/build/TinyLoadingScreen.d.mts +1 -1
  87. package/dist/v1/build/TinyLocalStorage.d.mts +1 -1
  88. package/dist/v1/build/TinyMediaPlayer.d.mts +1 -1
  89. package/dist/v1/build/TinyNeedBar.d.mts +1 -1
  90. package/dist/v1/build/TinyNewWinEvents.d.mts +1 -1
  91. package/dist/v1/build/TinyNotifications.d.mts +1 -1
  92. package/dist/v1/build/TinyNotifyCenter.d.mts +1 -1
  93. package/dist/v1/build/TinyPromiseQueue.d.mts +1 -1
  94. package/dist/v1/build/TinyRadioFm.d.mts +1 -1
  95. package/dist/v1/build/TinyRateLimiter.d.mts +1 -1
  96. package/dist/v1/build/TinySimpleDice.d.mts +1 -1
  97. package/dist/v1/build/TinySmartScroller.d.mts +1 -1
  98. package/dist/v1/build/TinyTextDiffer.d.mts +1 -1
  99. package/dist/v1/build/TinyTextRangeEditor.d.mts +1 -1
  100. package/dist/v1/build/TinyTextarea.d.mts +1 -1
  101. package/dist/v1/build/TinyTimeout.d.mts +1 -1
  102. package/dist/v1/build/TinyToastNotify.d.mts +1 -1
  103. package/dist/v1/build/TinyUploadClicker.d.mts +1 -1
  104. package/dist/v1/build/UltraRandomMsgGen.d.mts +1 -1
  105. package/dist/v1/fileManager/asyncFuncs.d.mts +13 -13
  106. package/dist/v1/fileManager/index.d.mts +3 -29
  107. package/dist/v1/fileManager/normalFuncs.d.mts +22 -22
  108. package/dist/v1/index.cjs +4 -0
  109. package/dist/v1/index.d.mts +54 -137
  110. package/dist/v1/index.mjs +4 -3
  111. package/dist/v1/libs/ColorSafeStringify.d.mts +3 -12
  112. package/dist/v1/libs/TinyAdvancedRaffle.cjs +64 -50
  113. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +64 -116
  114. package/dist/v1/libs/TinyAdvancedRaffle.mjs +62 -49
  115. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
  116. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +15 -19
  117. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
  118. package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
  119. package/dist/v1/libs/TinyAnalogClock.d.mts +12 -9
  120. package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
  121. package/dist/v1/libs/TinyArrayComparator.d.mts +14 -20
  122. package/dist/v1/libs/TinyArrayPaginator.d.mts +22 -26
  123. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +8 -8
  124. package/dist/v1/libs/TinyClassManager.cjs +5 -7
  125. package/dist/v1/libs/TinyClassManager.d.mts +16 -16
  126. package/dist/v1/libs/TinyClassManager.mjs +5 -6
  127. package/dist/v1/libs/TinyClipboard.cjs +2 -0
  128. package/dist/v1/libs/TinyClipboard.d.mts +12 -5
  129. package/dist/v1/libs/TinyClipboard.mjs +2 -0
  130. package/dist/v1/libs/TinyColorConverter.cjs +1 -0
  131. package/dist/v1/libs/TinyColorConverter.d.mts +10 -32
  132. package/dist/v1/libs/TinyColorConverter.mjs +1 -0
  133. package/dist/v1/libs/TinyColorValidator.d.mts +145 -184
  134. package/dist/v1/libs/TinyCookieConsent.d.mts +17 -17
  135. package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
  136. package/dist/v1/libs/TinyDayNightCycle.d.mts +87 -117
  137. package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
  138. package/dist/v1/libs/TinyDomReadyManager.d.mts +8 -16
  139. package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
  140. package/dist/v1/libs/TinyDragDropDetector.d.mts +32 -26
  141. package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
  142. package/dist/v1/libs/TinyDragger.cjs +46 -19
  143. package/dist/v1/libs/TinyDragger.d.mts +82 -81
  144. package/dist/v1/libs/TinyDragger.mjs +45 -18
  145. package/dist/v1/libs/TinyElementObserver.cjs +39 -0
  146. package/dist/v1/libs/TinyElementObserver.d.mts +28 -25
  147. package/dist/v1/libs/TinyElementObserver.mjs +36 -0
  148. package/dist/v1/libs/TinyGamepad.cjs +131 -2
  149. package/dist/v1/libs/TinyGamepad.d.mts +50 -122
  150. package/dist/v1/libs/TinyGamepad.mjs +129 -2
  151. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.cjs +2 -25
  152. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.d.mts +19 -25
  153. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.mjs +3 -27
  154. package/dist/v1/libs/TinyHtml/TinyHtmlButton.cjs +2 -1
  155. package/dist/v1/libs/TinyHtml/TinyHtmlButton.d.mts +55 -55
  156. package/dist/v1/libs/TinyHtml/TinyHtmlButton.mjs +2 -1
  157. package/dist/v1/libs/TinyHtml/TinyHtmlCanvas.d.mts +6 -6
  158. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.cjs +8 -4
  159. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.d.mts +19 -21
  160. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.mjs +7 -4
  161. package/dist/v1/libs/TinyHtml/TinyHtmlEmbed.d.mts +8 -8
  162. package/dist/v1/libs/TinyHtml/TinyHtmlForm.d.mts +18 -18
  163. package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +5 -6
  164. package/dist/v1/libs/TinyHtml/TinyHtmlIframe.d.mts +19 -19
  165. package/dist/v1/libs/TinyHtml/TinyHtmlImage.cjs +0 -28
  166. package/dist/v1/libs/TinyHtml/TinyHtmlImage.d.mts +22 -28
  167. package/dist/v1/libs/TinyHtml/TinyHtmlImage.mjs +1 -27
  168. package/dist/v1/libs/TinyHtml/TinyHtmlInput.d.mts +11 -11
  169. package/dist/v1/libs/TinyHtml/TinyHtmlLink.d.mts +23 -23
  170. package/dist/v1/libs/TinyHtml/TinyHtmlMedia.d.mts +26 -26
  171. package/dist/v1/libs/TinyHtml/TinyHtmlScript.cjs +4 -30
  172. package/dist/v1/libs/TinyHtml/TinyHtmlScript.d.mts +20 -26
  173. package/dist/v1/libs/TinyHtml/TinyHtmlScript.mjs +5 -32
  174. package/dist/v1/libs/TinyHtml/TinyHtmlSelect.d.mts +19 -19
  175. package/dist/v1/libs/TinyHtml/TinyHtmlStyle.d.mts +8 -8
  176. package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +26 -28
  177. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.cjs +14 -15
  178. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +32 -32
  179. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.mjs +15 -15
  180. package/dist/v1/libs/TinyHtml/index.d.mts +102 -45
  181. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.cjs +11 -9
  182. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.d.mts +21 -21
  183. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.mjs +11 -9
  184. package/dist/v1/libs/TinyHtml/input/TinyHtmlFileInput.d.mts +11 -11
  185. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.cjs +4 -4
  186. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.d.mts +17 -13
  187. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.mjs +4 -4
  188. package/dist/v1/libs/TinyHtml/input/TinyHtmlImageInput.d.mts +21 -21
  189. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.cjs +5 -4
  190. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.d.mts +14 -14
  191. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.mjs +5 -4
  192. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.cjs +4 -3
  193. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.d.mts +10 -10
  194. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.mjs +4 -3
  195. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.cjs +4 -3
  196. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.d.mts +19 -19
  197. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.mjs +4 -3
  198. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.cjs +5 -4
  199. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.d.mts +11 -11
  200. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.mjs +5 -4
  201. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.cjs +4 -3
  202. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.d.mts +15 -11
  203. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.mjs +4 -3
  204. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.cjs +49 -21
  205. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.d.mts +34 -20
  206. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.mjs +45 -20
  207. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.cjs +1 -1
  208. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.d.mts +14 -14
  209. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.mjs +1 -1
  210. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.cjs +1 -1
  211. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.d.mts +14 -14
  212. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.mjs +1 -1
  213. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.cjs +48 -25
  214. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.d.mts +27 -21
  215. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.mjs +40 -27
  216. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.cjs +1 -1
  217. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.d.mts +14 -14
  218. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.mjs +1 -1
  219. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlNumberInput.d.mts +14 -14
  220. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlRangeInput.d.mts +14 -14
  221. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlEmailInput.d.mts +25 -21
  222. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlPasswordInput.d.mts +18 -18
  223. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlSearchInput.d.mts +33 -29
  224. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTelInput.d.mts +22 -22
  225. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTextInput.d.mts +18 -18
  226. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlUrlInput.d.mts +31 -27
  227. package/dist/v1/libs/TinyHtml/media/TinyHtmlAudio.d.mts +35 -11
  228. package/dist/v1/libs/TinyHtml/media/TinyHtmlObject.d.mts +10 -10
  229. package/dist/v1/libs/TinyHtml/media/TinyHtmlSource.d.mts +12 -12
  230. package/dist/v1/libs/TinyHtml/media/TinyHtmlVideo.d.mts +35 -27
  231. package/dist/v1/libs/TinyHtml.cjs +4 -5
  232. package/dist/v1/libs/TinyHtml.d.mts +1503 -1731
  233. package/dist/v1/libs/TinyHtml.mjs +5 -6
  234. package/dist/v1/libs/TinyI18.cjs +61 -0
  235. package/dist/v1/libs/TinyI18.d.mts +34 -58
  236. package/dist/v1/libs/TinyI18.mjs +55 -0
  237. package/dist/v1/libs/TinyIframeEvents.cjs +19 -2
  238. package/dist/v1/libs/TinyIframeEvents.d.mts +29 -38
  239. package/dist/v1/libs/TinyIframeEvents.mjs +19 -2
  240. package/dist/v1/libs/TinyInventory.d.mts +78 -141
  241. package/dist/v1/libs/TinyInventoryTrader.d.mts +19 -22
  242. package/dist/v1/libs/TinyLevelUp.d.mts +10 -13
  243. package/dist/v1/libs/TinyLoadingScreen.d.mts +21 -31
  244. package/dist/v1/libs/TinyLocalStorage.cjs +48 -0
  245. package/dist/v1/libs/TinyLocalStorage.d.mts +11 -30
  246. package/dist/v1/libs/TinyLocalStorage.mjs +45 -0
  247. package/dist/v1/libs/TinyMamdaniInferenceSystem.d.mts +37 -23
  248. package/dist/v1/libs/TinyMediaPlayer.cjs +77 -3
  249. package/dist/v1/libs/TinyMediaPlayer.d.mts +109 -106
  250. package/dist/v1/libs/TinyMediaPlayer.mjs +71 -3
  251. package/dist/v1/libs/TinyNeedBar.d.mts +25 -37
  252. package/dist/v1/libs/TinyNewWinEvents.cjs +29 -0
  253. package/dist/v1/libs/TinyNewWinEvents.d.mts +32 -29
  254. package/dist/v1/libs/TinyNewWinEvents.mjs +26 -0
  255. package/dist/v1/libs/TinyNotifications.d.mts +6 -6
  256. package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
  257. package/dist/v1/libs/TinyNotifyCenter.d.mts +15 -15
  258. package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
  259. package/dist/v1/libs/TinyPromiseQueue.d.mts +11 -11
  260. package/dist/v1/libs/TinyRadioFm.cjs +70 -12
  261. package/dist/v1/libs/TinyRadioFm.d.mts +45 -80
  262. package/dist/v1/libs/TinyRadioFm.mjs +64 -12
  263. package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
  264. package/dist/v1/libs/TinyRateLimiter.d.mts +29 -36
  265. package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
  266. package/dist/v1/libs/TinySimpleDice.d.mts +17 -36
  267. package/dist/v1/libs/TinySmartScroller.cjs +52 -3
  268. package/dist/v1/libs/TinySmartScroller.d.mts +62 -70
  269. package/dist/v1/libs/TinySmartScroller.mjs +51 -5
  270. package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
  271. package/dist/v1/libs/TinyTextDiffer.d.mts +11 -13
  272. package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
  273. package/dist/v1/libs/TinyTextRangeEditor.d.mts +8 -8
  274. package/dist/v1/libs/TinyTextarea.cjs +19 -0
  275. package/dist/v1/libs/TinyTextarea.d.mts +34 -28
  276. package/dist/v1/libs/TinyTextarea.mjs +17 -0
  277. package/dist/v1/libs/TinyTimeout.cjs +11 -1
  278. package/dist/v1/libs/TinyTimeout.d.mts +14 -14
  279. package/dist/v1/libs/TinyTimeout.mjs +9 -1
  280. package/dist/v1/libs/TinyToastNotify.cjs +36 -1
  281. package/dist/v1/libs/TinyToastNotify.d.mts +15 -17
  282. package/dist/v1/libs/TinyToastNotify.mjs +32 -1
  283. package/dist/v1/libs/TinyUploadClicker.cjs +19 -0
  284. package/dist/v1/libs/TinyUploadClicker.d.mts +38 -8
  285. package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
  286. package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
  287. package/dist/v1/libs/UltraRandomMsgGen.d.mts +52 -78
  288. package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
  289. package/dist/v1/libs/utils.cjs +21 -0
  290. package/dist/v1/libs/utils.d.mts +6 -0
  291. package/dist/v1/libs/utils.mjs +16 -0
  292. package/docs/v1/README.md +1 -0
  293. package/docs/v1/basics/array.md +2 -2
  294. package/docs/v1/basics/deprecated/html.md +17 -0
  295. package/docs/v1/basics/fullScreen.md +1 -1
  296. package/docs/v1/basics/html.md +12 -26
  297. package/docs/v1/basics/mediaContent.md +1 -1
  298. package/docs/v1/basics/objChecker.md +1 -1
  299. package/docs/v1/basics/text.md +2 -2
  300. package/docs/v1/fileManager/main.md +1 -1
  301. package/docs/v1/libs/ColorSafeStringify.md +1 -1
  302. package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
  303. package/docs/v1/libs/TinyAnalogClock.md +1 -1
  304. package/docs/v1/libs/TinyArrayComparator.md +1 -1
  305. package/docs/v1/libs/TinyArrayPaginator.md +1 -1
  306. package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
  307. package/docs/v1/libs/TinyClassManager.md +1 -1
  308. package/docs/v1/libs/TinyClipboard.md +1 -1
  309. package/docs/v1/libs/TinyCookieConsent.md +1 -1
  310. package/docs/v1/libs/TinyDomReadyManager.md +1 -1
  311. package/docs/v1/libs/TinyDragDropDetector.md +1 -1
  312. package/docs/v1/libs/TinyDragger.md +1 -1
  313. package/docs/v1/libs/TinyElementObserver.md +1 -1
  314. package/docs/v1/libs/TinyHtml.md +1 -1
  315. package/docs/v1/libs/TinyIframeEvents.md +2 -2
  316. package/docs/v1/libs/TinyLevelUp.md +1 -1
  317. package/docs/v1/libs/TinyLoadingScreen.md +1 -1
  318. package/docs/v1/libs/TinyNewWinEvents.md +2 -2
  319. package/docs/v1/libs/TinyNotifications.md +1 -1
  320. package/docs/v1/libs/TinyPromiseQueue.md +2 -2
  321. package/docs/v1/libs/TinyTextDiffer.md +1 -1
  322. package/docs/v1/libs/TinyTextarea.md +1 -1
  323. package/package.json +11 -2
@@ -34,6 +34,14 @@
34
34
  * ruleOfThree.execute(2, 6, 3, true); // → 4
35
35
  */
36
36
  export function ruleOfThree(val1, val2, val3, inverse = false) {
37
+ if (typeof val1 !== 'number' || !Number.isFinite(val1))
38
+ throw new TypeError('val1 must be a finite number.');
39
+ if (typeof val2 !== 'number' || !Number.isFinite(val2))
40
+ throw new TypeError('val2 must be a finite number.');
41
+ if (typeof val3 !== 'number' || !Number.isFinite(val3))
42
+ throw new TypeError('val3 must be a finite number.');
43
+ if (typeof inverse !== 'boolean')
44
+ throw new TypeError('inverse must be a boolean.');
37
45
  return inverse ? Number(val1 * val2) / val3 : Number(val3 * val2) / val1;
38
46
  }
39
47
  /**
@@ -49,6 +57,10 @@ export function ruleOfThree(val1, val2, val3, inverse = false) {
49
57
  * getSimplePerc(200, 15); // 30
50
58
  */
51
59
  export function getSimplePerc(price, percentage) {
60
+ if (typeof price !== 'number' || !Number.isFinite(price))
61
+ throw new TypeError('price must be a finite number.');
62
+ if (typeof percentage !== 'number' || !Number.isFinite(percentage))
63
+ throw new TypeError('percentage must be a finite number.');
52
64
  return price * (percentage / 100);
53
65
  }
54
66
  /**
@@ -62,6 +74,10 @@ export function getSimplePerc(price, percentage) {
62
74
  * getPercentage(5, 100); // 5
63
75
  */
64
76
  export function getPercentage(part, total) {
77
+ if (typeof part !== 'number' || !Number.isFinite(part))
78
+ throw new TypeError('part must be a finite number.');
79
+ if (typeof total !== 'number' || !Number.isFinite(total))
80
+ throw new TypeError('total must be a finite number.');
65
81
  if (total === 0)
66
82
  return 0;
67
83
  return (part / total) * 100;
@@ -74,22 +90,25 @@ export function getPercentage(part, total) {
74
90
  * @returns {number|null} The age in years, or null if `timeData` is not provided or invalid.
75
91
  */
76
92
  export function getAge(timeData = 0, now = null) {
77
- if (typeof timeData !== 'undefined' && timeData !== null && timeData !== 0) {
78
- const birthDate = new Date(timeData);
79
- if (Number.isNaN(birthDate.getTime()))
80
- return null;
81
- const currentDate = now instanceof Date ? now : new Date();
82
- let age = currentDate.getFullYear() - birthDate.getFullYear();
83
- const currentMonth = currentDate.getMonth();
84
- const birthMonth = birthDate.getMonth();
85
- const currentDay = currentDate.getDate();
86
- const birthDay = birthDate.getDate();
87
- // Adjust if birthday hasn't occurred yet this year
88
- if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay))
89
- age--;
90
- return Math.abs(age);
93
+ if (typeof timeData !== 'number' && typeof timeData !== 'string' && !(timeData instanceof Date)) {
94
+ throw new TypeError('timeData must be a number, string, or Date object.');
91
95
  }
92
- return null;
96
+ if (now !== null && !(now instanceof Date)) {
97
+ throw new TypeError('now must be a Date object or null.');
98
+ }
99
+ const birthDate = new Date(timeData);
100
+ if (Number.isNaN(birthDate.getTime()))
101
+ return null;
102
+ const currentDate = now instanceof Date ? now : new Date();
103
+ let age = currentDate.getFullYear() - birthDate.getFullYear();
104
+ const currentMonth = currentDate.getMonth();
105
+ const birthMonth = birthDate.getMonth();
106
+ const currentDay = currentDate.getDate();
107
+ const birthDay = birthDate.getDate();
108
+ // Adjust if birthday hasn't occurred yet this year
109
+ if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay))
110
+ age--;
111
+ return Math.abs(age);
93
112
  }
94
113
  /**
95
114
  * @typedef {Object} FormattedByteResult
@@ -101,7 +120,7 @@ export function getAge(timeData = 0, now = null) {
101
120
  *
102
121
  * @param {number} bytes - The number of bytes to format. Must be a non-negative number.
103
122
  * @param {number|null} [decimals=null] - The number of decimal places to include in the result. Defaults to null. If negative, it will be treated as 0. If null, no rounding is applied.
104
- * @param {string|null} [maxUnit=null] - Optional unit limit. If provided, restricts conversion to this unit at most (e.g., 'MB' prevents conversion to 'GB' or higher). Must be one of: 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'.
123
+ * @param {'Bytes'|'KB'|'MB'|'GB'|'TB'|'PB'|'EB'|'ZB'|'YB'|null} [maxUnit=null] - Optional unit limit. If provided, restricts conversion to this unit at most (e.g., 'MB' prevents conversion to 'GB' or higher).
105
124
  * @returns {FormattedByteResult} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
106
125
  *
107
126
  * @example
@@ -113,12 +132,21 @@ export function getAge(timeData = 0, now = null) {
113
132
  * // → { unit: 'MB', value: 1024 }
114
133
  */
115
134
  export function formatBytes(bytes, decimals = null, maxUnit = null) {
116
- if (typeof bytes !== 'number' || bytes < 0)
117
- return { unit: null, value: null };
135
+ if (typeof bytes !== 'number' || !Number.isFinite(bytes) || bytes < 0)
136
+ throw new TypeError('bytes must be a positive number.');
118
137
  if (bytes === 0)
119
138
  return { unit: 'Bytes', value: 0 };
139
+ if (decimals !== null && (typeof decimals !== 'number' || !Number.isFinite(decimals))) {
140
+ throw new TypeError('decimals must be a number or null.');
141
+ }
120
142
  const k = 1024;
121
143
  const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
144
+ if (maxUnit !== null) {
145
+ if (typeof maxUnit !== 'string')
146
+ throw new TypeError('maxUnit must be a string or null.');
147
+ if (!sizes.includes(maxUnit))
148
+ throw new RangeError(`maxUnit must be one of: ${sizes.join(', ')}`);
149
+ }
122
150
  const maxIndex = maxUnit && sizes.includes(maxUnit) ? sizes.indexOf(maxUnit) : sizes.length - 1;
123
151
  const i = Math.min(Math.floor(Math.log(bytes) / Math.log(k)), maxIndex);
124
152
  let value = bytes / Math.pow(k, i);
@@ -149,8 +177,17 @@ export function formatBytes(bytes, decimals = null, maxUnit = null) {
149
177
  * @beta
150
178
  */
151
179
  export function genFibonacciSeq({ baseValues = [0, 1], length = 10, combiner = (a, b) => a + b, } = {}) {
152
- if (!Array.isArray(baseValues) || baseValues.length !== 2)
153
- throw new Error('baseValues must be an array of exactly two numbers');
180
+ if (!Array.isArray(baseValues) ||
181
+ baseValues.length !== 2 ||
182
+ !baseValues.every((value) => typeof value === 'number')) {
183
+ throw new Error('baseValues must be an array of exactly two numbers.');
184
+ }
185
+ if (typeof length !== 'number' || !Number.isInteger(length)) {
186
+ throw new RangeError('length must be an integer.');
187
+ }
188
+ if (typeof combiner !== 'function') {
189
+ throw new TypeError('combiner must be a function.');
190
+ }
154
191
  const sequence = [...baseValues.slice(0, 2)];
155
192
  for (let i = 2; i < length; i++) {
156
193
  const next = combiner(sequence[i - 2], sequence[i - 1], i);
@@ -169,12 +206,16 @@ export function genFibonacciSeq({ baseValues = [0, 1], length = 10, combiner = (
169
206
  * @returns {number} The calculated price per unit of the asset.
170
207
  */
171
208
  export function calculateMarketcap(originalMarketCap, circulatingSupply) {
172
- if (Number.isNaN(originalMarketCap) || !Number.isFinite(originalMarketCap))
173
- throw new TypeError('Original market cap must be a number.');
174
- if (Number.isNaN(circulatingSupply) || !Number.isFinite(circulatingSupply))
175
- throw new TypeError('Circulating supply must be a number.');
209
+ if (typeof originalMarketCap !== 'number' ||
210
+ Number.isNaN(originalMarketCap) ||
211
+ !Number.isFinite(originalMarketCap))
212
+ throw new TypeError('Original market cap must be a finite number.');
213
+ if (typeof circulatingSupply !== 'number' ||
214
+ Number.isNaN(circulatingSupply) ||
215
+ !Number.isFinite(circulatingSupply))
216
+ throw new TypeError('Circulating supply must be a finite number.');
176
217
  if (circulatingSupply <= 0)
177
- throw new Error('Circulating supply must be greater than zero.');
218
+ throw new RangeError('Circulating supply must be greater than zero.');
178
219
  return originalMarketCap / circulatingSupply;
179
220
  }
180
221
  /**
@@ -189,8 +230,10 @@ export function calculateMarketcap(originalMarketCap, circulatingSupply) {
189
230
  * }}
190
231
  */
191
232
  export function compareMarketcap(originalMarketCap, circulatingSupply, newMarketCap) {
192
- if (Number.isNaN(newMarketCap) || !Number.isFinite(newMarketCap))
193
- throw new TypeError('New market cap must be a number.');
233
+ if (typeof newMarketCap !== 'number' ||
234
+ Number.isNaN(newMarketCap) ||
235
+ !Number.isFinite(newMarketCap))
236
+ throw new TypeError('New market cap must be a finite number.');
194
237
  const originalPrice = calculateMarketcap(originalMarketCap, circulatingSupply);
195
238
  const newPrice = typeof newMarketCap === 'number' ? newMarketCap / circulatingSupply : NaN;
196
239
  const priceChangePercent = typeof newMarketCap === 'number' ? ((newPrice - originalPrice) / originalPrice) * 100 : NaN;
@@ -6,15 +6,25 @@
6
6
  * @param {string} str - The input string to perform replacements on.
7
7
  * @param {RegExp} regex - The regular expression to match substrings for replacement.
8
8
  * @param {Function} asyncFn - An asynchronous function that returns a replacement for each match.
9
- * It receives the same arguments as a standard `replace` callback.
9
+ * It receives the same arguments as a standard `replace` callback.
10
10
  * @returns {Promise<string>} The resulting string with all async replacements applied.
11
11
  *
12
12
  * @example
13
13
  * await asyncReplace("Hello @user1 and @user2!", /@\w+/g, async (mention) => {
14
- * return await getUserNameFromMention(mention);
14
+ * return await getUserNameFromMention(mention);
15
15
  * });
16
16
  */
17
17
  async function asyncReplace(str, regex, asyncFn) {
18
+ if (typeof str !== 'string') {
19
+ throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
20
+ }
21
+ if (!(regex instanceof RegExp)) {
22
+ throw new TypeError(`Expected a RegExp for 'regex', but received ${typeof regex}`);
23
+ }
24
+ if (typeof asyncFn !== 'function') {
25
+ throw new TypeError(`Expected a function for 'asyncFn', but received ${typeof asyncFn}`);
26
+ }
27
+
18
28
  /**
19
29
  * @type {any[]}
20
30
  */
@@ -42,6 +52,10 @@ async function asyncReplace(str, regex, asyncFn) {
42
52
  * @returns {string} The string converted to title case.
43
53
  */
44
54
  function toTitleCase(str) {
55
+ if (typeof str !== 'string') {
56
+ throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
57
+ }
58
+
45
59
  return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
46
60
  }
47
61
 
@@ -55,6 +69,10 @@ function toTitleCase(str) {
55
69
  * @returns {string} The string converted to title case with the first letter in lowercase.
56
70
  */
57
71
  function toTitleCaseLowerFirst(str) {
72
+ if (typeof str !== 'string') {
73
+ throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
74
+ }
75
+
58
76
  const titleCased = str.replace(
59
77
  /\w\S*/g,
60
78
  (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(),
@@ -101,6 +119,15 @@ function addAiMarkerShortcut({ key = 'a', className = 'detect-made-by-ai' } = {}
101
119
  '[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.',
102
120
  );
103
121
 
122
+ if (typeof key !== 'string') {
123
+ throw new TypeError(`Expected a string for 'config.key', but received ${typeof key}`);
124
+ }
125
+ if (typeof className !== 'string') {
126
+ throw new TypeError(
127
+ `Expected a string for 'config.className', but received ${typeof className}`,
128
+ );
129
+ }
130
+
104
131
  /** @type {(this: Document, ev: KeyboardEvent) => any} */
105
132
  const keydownEvent = function (event) {
106
133
  if (event.ctrlKey && event.altKey && event.key.toLowerCase() === key) {
@@ -128,7 +155,7 @@ function addAiMarkerShortcut({ key = 'a', className = 'detect-made-by-ai' } = {}
128
155
  * @param {string} text - The input text to be trimmed.
129
156
  * @param {number} limit - The maximum number of characters allowed.
130
157
  * @param {number} [safeCutZone=0.6] - A decimal between 0 and 1 representing the minimal acceptable position
131
- * (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
158
+ * (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
132
159
  * @returns {string} - The trimmed text, possibly ending with an ellipsis ("...").
133
160
  * @throws {TypeError} - Throws if `text` is not a string.
134
161
  * @throws {TypeError} - Throws if `limit` is not a positive integer.
@@ -162,18 +189,48 @@ function safeTextTrim(text, limit, safeCutZone = 0.6) {
162
189
  }
163
190
 
164
191
  /**
165
- * Diff two string objects.
166
- * @param {Record<string,string>} oldStrings
167
- * @param {Record<string,string>} newStrings
192
+ * @template {Record<string, any>} CompareValue
193
+ * @typedef {Object} DiffStringsModifiedValue
194
+ * @property {CompareValue[keyof CompareValue]} old - The value before the modification.
195
+ * @property {CompareValue[keyof CompareValue]} new - The new value after the modification.
196
+ */
197
+
198
+ /**
199
+ * @template {Record<string, any>} CompareValue
200
+ * @typedef {Object} DiffStringsData
201
+ * @property {Partial<CompareValue>} added - Properties that only exist in the new object.
202
+ * @property {Partial<CompareValue>} removed - Properties that only existed in the old object.
203
+ * @property {Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>} modified - Properties that changed, containing their old and new values.
204
+ */
205
+
206
+ /**
207
+ * Diff two objects.
208
+ * @template {Record<string, any>} CompareValue1
209
+ * @template {Record<string, any>} CompareValue2
210
+ * @param {CompareValue1} oldStrings - The original/old object for comparison.
211
+ * @param {CompareValue2} newStrings - The new object for comparison.
212
+ * @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
168
213
  */
169
- function diffStrings(oldStrings, newStrings) {
170
- /** @type {Record<string,Record<string,string|Record<string,string>>>}} */
214
+ function diffObjList(oldStrings, newStrings) {
215
+ if (typeof oldStrings !== 'object' || oldStrings === null || Array.isArray(oldStrings)) {
216
+ throw new TypeError(
217
+ `Expected an object for 'oldStrings', but received ${oldStrings === null ? 'null' : typeof oldStrings}`,
218
+ );
219
+ }
220
+ if (typeof newStrings !== 'object' || newStrings === null || Array.isArray(newStrings)) {
221
+ throw new TypeError(
222
+ `Expected an object for 'newStrings', but received ${newStrings === null ? 'null' : typeof newStrings}`,
223
+ );
224
+ }
225
+
226
+ /** @type {DiffStringsData<CompareValue1 & CompareValue2>} */
171
227
  const changes = { added: {}, removed: {}, modified: {} };
172
228
 
173
229
  // detect removed and modified
174
230
  for (const prop in oldStrings) {
175
231
  if (!(prop in newStrings)) {
176
232
  changes.removed[prop] = oldStrings[prop];
233
+ // @ts-ignore
177
234
  } else if (oldStrings[prop] !== newStrings[prop]) {
178
235
  changes.modified[prop] = { old: oldStrings[prop], new: newStrings[prop] };
179
236
  }
@@ -189,32 +246,20 @@ function diffStrings(oldStrings, newStrings) {
189
246
  return changes;
190
247
  }
191
248
 
192
- /*
193
- import { useEffect } from "react";
194
-
195
- function KeyPressHandler() {
196
- useEffect(() => {
197
- const handleKeyDown = (event) => {
198
- if (event.ctrlKey && event.altKey && event.key.toLowerCase() === "a") {
199
- event.preventDefault();
200
- document.body.classList.toggle("detect-made-by-ai");
201
- }
202
- };
203
-
204
- document.addEventListener("keydown", handleKeyDown);
205
- return () => {
206
- document.removeEventListener("keydown", handleKeyDown);
207
- };
208
- }, []);
209
-
210
- return null;
211
- }
212
-
213
- export default KeyPressHandler;
214
- */
249
+ /**
250
+ * Diff two objects.
251
+ * @template {Record<string, any>} CompareValue1
252
+ * @template {Record<string, any>} CompareValue2
253
+ * @param {CompareValue1} oldStrings - The original/old object for comparison.
254
+ * @param {CompareValue2} newStrings - The new object for comparison.
255
+ * @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
256
+ * @deprecated Function rename! Use {@link diffObjList} instead.
257
+ */
258
+ const diffStrings = diffObjList;
215
259
 
216
260
  exports.addAiMarkerShortcut = addAiMarkerShortcut;
217
261
  exports.asyncReplace = asyncReplace;
262
+ exports.diffObjList = diffObjList;
218
263
  exports.diffStrings = diffStrings;
219
264
  exports.safeTextTrim = safeTextTrim;
220
265
  exports.toTitleCase = toTitleCase;
@@ -4,15 +4,15 @@
4
4
  * @param {string} str - The input string to perform replacements on.
5
5
  * @param {RegExp} regex - The regular expression to match substrings for replacement.
6
6
  * @param {Function} asyncFn - An asynchronous function that returns a replacement for each match.
7
- * It receives the same arguments as a standard `replace` callback.
7
+ * It receives the same arguments as a standard `replace` callback.
8
8
  * @returns {Promise<string>} The resulting string with all async replacements applied.
9
9
  *
10
10
  * @example
11
11
  * await asyncReplace("Hello @user1 and @user2!", /@\w+/g, async (mention) => {
12
- * return await getUserNameFromMention(mention);
12
+ * return await getUserNameFromMention(mention);
13
13
  * });
14
14
  */
15
- export function asyncReplace(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
15
+ export declare function asyncReplace(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
16
16
  /**
17
17
  * Converts a string to title case where the first letter of each word is capitalized.
18
18
  * All other letters are converted to lowercase.
@@ -22,7 +22,7 @@ export function asyncReplace(str: string, regex: RegExp, asyncFn: Function): Pro
22
22
  * @param {string} str - The string to be converted to title case.
23
23
  * @returns {string} The string converted to title case.
24
24
  */
25
- export function toTitleCase(str: string): string;
25
+ export declare function toTitleCase(str: string): string;
26
26
  /**
27
27
  * Converts a string to title case where the first letter of each word is capitalized,
28
28
  * but the first letter of the entire string is left lowercase.
@@ -32,7 +32,7 @@ export function toTitleCase(str: string): string;
32
32
  * @param {string} str - The string to be converted to title case with the first letter in lowercase.
33
33
  * @returns {string} The string converted to title case with the first letter in lowercase.
34
34
  */
35
- export function toTitleCaseLowerFirst(str: string): string;
35
+ export declare function toTitleCaseLowerFirst(str: string): string;
36
36
  /**
37
37
  * Enables a keyboard shortcut to toggle a CSS class on the document body.
38
38
  *
@@ -66,9 +66,9 @@ export function toTitleCaseLowerFirst(str: string): string;
66
66
  * @param {string} [config.className='detect-made-by-ai'] - The CSS class to toggle on the `<body>` element.
67
67
  * @returns {(this: Document, ev: KeyboardEvent) => any} The event handler attached to `document`.
68
68
  */
69
- export function addAiMarkerShortcut({ key, className }?: {
70
- key?: string | undefined;
71
- className?: string | undefined;
69
+ export declare function addAiMarkerShortcut({ key, className }?: {
70
+ key?: string;
71
+ className?: string;
72
72
  }): (this: Document, ev: KeyboardEvent) => any;
73
73
  /**
74
74
  * Trims a text string to a specified character limit, attempting to avoid cutting words in half.
@@ -79,17 +79,67 @@ export function addAiMarkerShortcut({ key, className }?: {
79
79
  * @param {string} text - The input text to be trimmed.
80
80
  * @param {number} limit - The maximum number of characters allowed.
81
81
  * @param {number} [safeCutZone=0.6] - A decimal between 0 and 1 representing the minimal acceptable position
82
- * (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
82
+ * (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
83
83
  * @returns {string} - The trimmed text, possibly ending with an ellipsis ("...").
84
84
  * @throws {TypeError} - Throws if `text` is not a string.
85
85
  * @throws {TypeError} - Throws if `limit` is not a positive integer.
86
86
  * @throws {TypeError} - Throws if `safeCutZone` is not a number between 0 and 1 (inclusive).
87
87
  */
88
- export function safeTextTrim(text: string, limit: number, safeCutZone?: number): string;
88
+ export declare function safeTextTrim(text: string, limit: number, safeCutZone?: number): string;
89
+ export type DiffStringsModifiedValue<CompareValue extends Record<string, any>> = {
90
+ /**
91
+ * - The value before the modification.
92
+ */
93
+ old: CompareValue[keyof CompareValue];
94
+ /**
95
+ * - The new value after the modification.
96
+ */
97
+ new: CompareValue[keyof CompareValue];
98
+ };
99
+ export type DiffStringsData<CompareValue extends Record<string, any>> = {
100
+ /**
101
+ * - Properties that only exist in the new object.
102
+ */
103
+ added: Partial<CompareValue>;
104
+ /**
105
+ * - Properties that only existed in the old object.
106
+ */
107
+ removed: Partial<CompareValue>;
108
+ /**
109
+ * - Properties that changed, containing their old and new values.
110
+ */
111
+ modified: Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>;
112
+ };
89
113
  /**
90
- * Diff two string objects.
91
- * @param {Record<string,string>} oldStrings
92
- * @param {Record<string,string>} newStrings
114
+ * @template {Record<string, any>} CompareValue
115
+ * @typedef {Object} DiffStringsModifiedValue
116
+ * @property {CompareValue[keyof CompareValue]} old - The value before the modification.
117
+ * @property {CompareValue[keyof CompareValue]} new - The new value after the modification.
93
118
  */
94
- export function diffStrings(oldStrings: Record<string, string>, newStrings: Record<string, string>): Record<string, Record<string, string | Record<string, string>>>;
119
+ /**
120
+ * @template {Record<string, any>} CompareValue
121
+ * @typedef {Object} DiffStringsData
122
+ * @property {Partial<CompareValue>} added - Properties that only exist in the new object.
123
+ * @property {Partial<CompareValue>} removed - Properties that only existed in the old object.
124
+ * @property {Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>} modified - Properties that changed, containing their old and new values.
125
+ */
126
+ /**
127
+ * Diff two objects.
128
+ * @template {Record<string, any>} CompareValue1
129
+ * @template {Record<string, any>} CompareValue2
130
+ * @param {CompareValue1} oldStrings - The original/old object for comparison.
131
+ * @param {CompareValue2} newStrings - The new object for comparison.
132
+ * @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
133
+ */
134
+ export declare function diffObjList<CompareValue1 extends Record<string, any>, CompareValue2 extends Record<string, any>>(oldStrings: CompareValue1, newStrings: CompareValue2): DiffStringsData<CompareValue1 & CompareValue2>;
135
+ /**
136
+ * Diff two objects.
137
+ * @template {Record<string, any>} CompareValue1
138
+ * @template {Record<string, any>} CompareValue2
139
+ * @param {CompareValue1} oldStrings - The original/old object for comparison.
140
+ * @param {CompareValue2} newStrings - The new object for comparison.
141
+ * @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
142
+ * @deprecated Function rename! Use {@link diffObjList} instead.
143
+ */
144
+ export declare const diffStrings: typeof diffObjList;
95
145
  //# sourceMappingURL=text.d.mts.map
@@ -4,15 +4,24 @@
4
4
  * @param {string} str - The input string to perform replacements on.
5
5
  * @param {RegExp} regex - The regular expression to match substrings for replacement.
6
6
  * @param {Function} asyncFn - An asynchronous function that returns a replacement for each match.
7
- * It receives the same arguments as a standard `replace` callback.
7
+ * It receives the same arguments as a standard `replace` callback.
8
8
  * @returns {Promise<string>} The resulting string with all async replacements applied.
9
9
  *
10
10
  * @example
11
11
  * await asyncReplace("Hello @user1 and @user2!", /@\w+/g, async (mention) => {
12
- * return await getUserNameFromMention(mention);
12
+ * return await getUserNameFromMention(mention);
13
13
  * });
14
14
  */
15
15
  export async function asyncReplace(str, regex, asyncFn) {
16
+ if (typeof str !== 'string') {
17
+ throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
18
+ }
19
+ if (!(regex instanceof RegExp)) {
20
+ throw new TypeError(`Expected a RegExp for 'regex', but received ${typeof regex}`);
21
+ }
22
+ if (typeof asyncFn !== 'function') {
23
+ throw new TypeError(`Expected a function for 'asyncFn', but received ${typeof asyncFn}`);
24
+ }
16
25
  /**
17
26
  * @type {any[]}
18
27
  */
@@ -36,6 +45,9 @@ export async function asyncReplace(str, regex, asyncFn) {
36
45
  * @returns {string} The string converted to title case.
37
46
  */
38
47
  export function toTitleCase(str) {
48
+ if (typeof str !== 'string') {
49
+ throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
50
+ }
39
51
  return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
40
52
  }
41
53
  /**
@@ -48,6 +60,9 @@ export function toTitleCase(str) {
48
60
  * @returns {string} The string converted to title case with the first letter in lowercase.
49
61
  */
50
62
  export function toTitleCaseLowerFirst(str) {
63
+ if (typeof str !== 'string') {
64
+ throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
65
+ }
51
66
  const titleCased = str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
52
67
  return titleCased.charAt(0).toLowerCase() + titleCased.slice(1);
53
68
  }
@@ -87,6 +102,12 @@ export function toTitleCaseLowerFirst(str) {
87
102
  export function addAiMarkerShortcut({ key = 'a', className = 'detect-made-by-ai' } = {}) {
88
103
  if (typeof HTMLElement === 'undefined')
89
104
  throw new Error('[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.');
105
+ if (typeof key !== 'string') {
106
+ throw new TypeError(`Expected a string for 'config.key', but received ${typeof key}`);
107
+ }
108
+ if (typeof className !== 'string') {
109
+ throw new TypeError(`Expected a string for 'config.className', but received ${typeof className}`);
110
+ }
90
111
  /** @type {(this: Document, ev: KeyboardEvent) => any} */
91
112
  const keydownEvent = function (event) {
92
113
  if (event.ctrlKey && event.altKey && event.key.toLowerCase() === key) {
@@ -110,7 +131,7 @@ export function addAiMarkerShortcut({ key = 'a', className = 'detect-made-by-ai'
110
131
  * @param {string} text - The input text to be trimmed.
111
132
  * @param {number} limit - The maximum number of characters allowed.
112
133
  * @param {number} [safeCutZone=0.6] - A decimal between 0 and 1 representing the minimal acceptable position
113
- * (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
134
+ * (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
114
135
  * @returns {string} - The trimmed text, possibly ending with an ellipsis ("...").
115
136
  * @throws {TypeError} - Throws if `text` is not a string.
116
137
  * @throws {TypeError} - Throws if `limit` is not a positive integer.
@@ -139,17 +160,40 @@ export function safeTextTrim(text, limit, safeCutZone = 0.6) {
139
160
  return result;
140
161
  }
141
162
  /**
142
- * Diff two string objects.
143
- * @param {Record<string,string>} oldStrings
144
- * @param {Record<string,string>} newStrings
163
+ * @template {Record<string, any>} CompareValue
164
+ * @typedef {Object} DiffStringsModifiedValue
165
+ * @property {CompareValue[keyof CompareValue]} old - The value before the modification.
166
+ * @property {CompareValue[keyof CompareValue]} new - The new value after the modification.
167
+ */
168
+ /**
169
+ * @template {Record<string, any>} CompareValue
170
+ * @typedef {Object} DiffStringsData
171
+ * @property {Partial<CompareValue>} added - Properties that only exist in the new object.
172
+ * @property {Partial<CompareValue>} removed - Properties that only existed in the old object.
173
+ * @property {Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>} modified - Properties that changed, containing their old and new values.
145
174
  */
146
- export function diffStrings(oldStrings, newStrings) {
147
- /** @type {Record<string,Record<string,string|Record<string,string>>>}} */
175
+ /**
176
+ * Diff two objects.
177
+ * @template {Record<string, any>} CompareValue1
178
+ * @template {Record<string, any>} CompareValue2
179
+ * @param {CompareValue1} oldStrings - The original/old object for comparison.
180
+ * @param {CompareValue2} newStrings - The new object for comparison.
181
+ * @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
182
+ */
183
+ export function diffObjList(oldStrings, newStrings) {
184
+ if (typeof oldStrings !== 'object' || oldStrings === null || Array.isArray(oldStrings)) {
185
+ throw new TypeError(`Expected an object for 'oldStrings', but received ${oldStrings === null ? 'null' : typeof oldStrings}`);
186
+ }
187
+ if (typeof newStrings !== 'object' || newStrings === null || Array.isArray(newStrings)) {
188
+ throw new TypeError(`Expected an object for 'newStrings', but received ${newStrings === null ? 'null' : typeof newStrings}`);
189
+ }
190
+ /** @type {DiffStringsData<CompareValue1 & CompareValue2>} */
148
191
  const changes = { added: {}, removed: {}, modified: {} };
149
192
  // detect removed and modified
150
193
  for (const prop in oldStrings) {
151
194
  if (!(prop in newStrings)) {
152
195
  changes.removed[prop] = oldStrings[prop];
196
+ // @ts-ignore
153
197
  }
154
198
  else if (oldStrings[prop] !== newStrings[prop]) {
155
199
  changes.modified[prop] = { old: oldStrings[prop], new: newStrings[prop] };
@@ -163,26 +207,13 @@ export function diffStrings(oldStrings, newStrings) {
163
207
  }
164
208
  return changes;
165
209
  }
166
- /*
167
- import { useEffect } from "react";
168
-
169
- function KeyPressHandler() {
170
- useEffect(() => {
171
- const handleKeyDown = (event) => {
172
- if (event.ctrlKey && event.altKey && event.key.toLowerCase() === "a") {
173
- event.preventDefault();
174
- document.body.classList.toggle("detect-made-by-ai");
175
- }
176
- };
177
-
178
- document.addEventListener("keydown", handleKeyDown);
179
- return () => {
180
- document.removeEventListener("keydown", handleKeyDown);
181
- };
182
- }, []);
183
-
184
- return null;
185
- }
186
-
187
- export default KeyPressHandler;
188
- */
210
+ /**
211
+ * Diff two objects.
212
+ * @template {Record<string, any>} CompareValue1
213
+ * @template {Record<string, any>} CompareValue2
214
+ * @param {CompareValue1} oldStrings - The original/old object for comparison.
215
+ * @param {CompareValue2} newStrings - The new object for comparison.
216
+ * @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
217
+ * @deprecated Function rename! Use {@link diffObjList} instead.
218
+ */
219
+ export const diffStrings = diffObjList;
@@ -1,3 +1,3 @@
1
- export { ColorSafeStringify };
2
1
  import ColorSafeStringify from '../libs/ColorSafeStringify.mjs';
2
+ export { ColorSafeStringify };
3
3
  //# sourceMappingURL=ColorSafeStringify.d.mts.map
@@ -1,3 +1,3 @@
1
- export { TinyAdvancedRaffle };
2
1
  import TinyAdvancedRaffle from '../libs/TinyAdvancedRaffle.mjs';
2
+ export { TinyAdvancedRaffle };
3
3
  //# sourceMappingURL=TinyAdvancedRaffle.d.mts.map
@@ -1,3 +1,3 @@
1
- export { TinyAfterScrollWatcher };
2
1
  import TinyAfterScrollWatcher from '../libs/TinyAfterScrollWatcher.mjs';
2
+ export { TinyAfterScrollWatcher };
3
3
  //# sourceMappingURL=TinyAfterScrollWatcher.d.mts.map
@@ -1,3 +1,3 @@
1
- export { TinyAnalogClock };
2
1
  import TinyAnalogClock from '../libs/TinyAnalogClock.mjs';
2
+ export { TinyAnalogClock };
3
3
  //# sourceMappingURL=TinyAnalogClock.d.mts.map
@@ -1,3 +1,3 @@
1
- export { TinyArrayComparator };
2
1
  import TinyArrayComparator from '../libs/TinyArrayComparator.mjs';
2
+ export { TinyArrayComparator };
3
3
  //# sourceMappingURL=TinyArrayComparator.d.mts.map
@@ -1,3 +1,3 @@
1
- export { TinyArrayPaginator };
2
1
  import TinyArrayPaginator from '../libs/TinyArrayPaginator.mjs';
2
+ export { TinyArrayPaginator };
3
3
  //# sourceMappingURL=TinyArrayPaginator.d.mts.map
@@ -1,3 +1,3 @@
1
- export { TinyClassManager };
2
1
  import TinyClassManager from '../libs/TinyClassManager.mjs';
2
+ export { TinyClassManager };
3
3
  //# sourceMappingURL=TinyClassManager.d.mts.map