@herowcode/utils 1.3.5 → 1.5.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 (462) hide show
  1. package/dist/api/index.cjs +12 -0
  2. package/dist/api/index.cjs.map +1 -0
  3. package/dist/api/{client.d.ts → index.d.mts} +19 -8
  4. package/dist/api/index.d.ts +36 -3
  5. package/dist/api/index.js +3 -0
  6. package/dist/api/index.js.map +1 -0
  7. package/dist/array/index.cjs +16 -0
  8. package/dist/array/index.cjs.map +1 -0
  9. package/dist/array/index.d.mts +5 -0
  10. package/dist/array/index.d.ts +5 -3
  11. package/dist/array/index.js +3 -0
  12. package/dist/array/index.js.map +1 -0
  13. package/dist/chunk-2MANLCNG.cjs +23 -0
  14. package/dist/chunk-2MANLCNG.cjs.map +1 -0
  15. package/dist/chunk-2RTW37WD.js +20 -0
  16. package/dist/chunk-2RTW37WD.js.map +1 -0
  17. package/dist/chunk-2Y6M7IOG.js +250 -0
  18. package/dist/chunk-2Y6M7IOG.js.map +1 -0
  19. package/dist/chunk-3JUB2OJL.js +3 -0
  20. package/dist/chunk-3JUB2OJL.js.map +1 -0
  21. package/dist/chunk-53JMVGIG.js +187 -0
  22. package/dist/chunk-53JMVGIG.js.map +1 -0
  23. package/dist/chunk-56NHIM5J.js +151 -0
  24. package/dist/chunk-56NHIM5J.js.map +1 -0
  25. package/dist/chunk-5OLQJUNS.js +66 -0
  26. package/dist/chunk-5OLQJUNS.js.map +1 -0
  27. package/dist/chunk-5YOEKMTJ.cjs +321 -0
  28. package/dist/chunk-5YOEKMTJ.cjs.map +1 -0
  29. package/dist/chunk-6TWPZ6LL.cjs +4 -0
  30. package/dist/chunk-6TWPZ6LL.cjs.map +1 -0
  31. package/dist/chunk-AQZBHMTO.js +96 -0
  32. package/dist/chunk-AQZBHMTO.js.map +1 -0
  33. package/dist/chunk-ATWN4SRX.js +29 -0
  34. package/dist/chunk-ATWN4SRX.js.map +1 -0
  35. package/dist/chunk-GRSF4RY2.cjs +20 -0
  36. package/dist/chunk-GRSF4RY2.cjs.map +1 -0
  37. package/dist/chunk-GX5E5B4L.cjs +70 -0
  38. package/dist/chunk-GX5E5B4L.cjs.map +1 -0
  39. package/dist/chunk-HK727IAV.cjs +201 -0
  40. package/dist/chunk-HK727IAV.cjs.map +1 -0
  41. package/dist/chunk-LJ6KOZD4.cjs +154 -0
  42. package/dist/chunk-LJ6KOZD4.cjs.map +1 -0
  43. package/dist/chunk-N2DRAZ3A.cjs +29 -0
  44. package/dist/chunk-N2DRAZ3A.cjs.map +1 -0
  45. package/dist/chunk-O7SH3E3T.js +18 -0
  46. package/dist/chunk-O7SH3E3T.js.map +1 -0
  47. package/dist/chunk-P5YNRND6.cjs +4 -0
  48. package/dist/chunk-P5YNRND6.cjs.map +1 -0
  49. package/dist/chunk-QAE6Q2SA.js +317 -0
  50. package/dist/chunk-QAE6Q2SA.js.map +1 -0
  51. package/dist/chunk-QRXVUXGJ.js +378 -0
  52. package/dist/chunk-QRXVUXGJ.js.map +1 -0
  53. package/dist/chunk-SLYUARZG.cjs +99 -0
  54. package/dist/chunk-SLYUARZG.cjs.map +1 -0
  55. package/dist/chunk-SWRIT7EE.js +3 -0
  56. package/dist/chunk-SWRIT7EE.js.map +1 -0
  57. package/dist/chunk-UXEUYHBD.cjs +401 -0
  58. package/dist/chunk-UXEUYHBD.cjs.map +1 -0
  59. package/dist/chunk-V6OKXUBQ.js +22 -0
  60. package/dist/chunk-V6OKXUBQ.js.map +1 -0
  61. package/dist/chunk-VAZJXZU5.cjs +31 -0
  62. package/dist/chunk-VAZJXZU5.cjs.map +1 -0
  63. package/dist/chunk-WGSFRFRO.cjs +252 -0
  64. package/dist/chunk-WGSFRFRO.cjs.map +1 -0
  65. package/dist/date/index.cjs +56 -0
  66. package/dist/date/index.cjs.map +1 -0
  67. package/dist/date/index.d.mts +63 -0
  68. package/dist/date/index.d.ts +63 -8
  69. package/dist/date/index.js +3 -0
  70. package/dist/date/index.js.map +1 -0
  71. package/dist/extract-youtube-video-id-HSYMYXIZ.js +3 -0
  72. package/dist/extract-youtube-video-id-HSYMYXIZ.js.map +1 -0
  73. package/dist/extract-youtube-video-id-XVGNPUDX.cjs +12 -0
  74. package/dist/extract-youtube-video-id-XVGNPUDX.cjs.map +1 -0
  75. package/dist/files/index.browser.cjs +21 -0
  76. package/dist/files/index.browser.cjs.map +1 -0
  77. package/dist/files/index.browser.d.mts +14 -0
  78. package/dist/files/index.browser.d.ts +14 -0
  79. package/dist/files/index.browser.js +4 -0
  80. package/dist/files/index.browser.js.map +1 -0
  81. package/dist/files/index.cjs +31 -0
  82. package/dist/files/index.cjs.map +1 -0
  83. package/dist/files/index.d.mts +3 -0
  84. package/dist/files/index.d.ts +3 -6
  85. package/dist/files/index.js +6 -0
  86. package/dist/files/index.js.map +1 -0
  87. package/dist/files/index.node.cjs +21 -0
  88. package/dist/files/index.node.cjs.map +1 -0
  89. package/dist/files/index.node.d.mts +7 -0
  90. package/dist/files/index.node.d.ts +7 -0
  91. package/dist/files/index.node.js +4 -0
  92. package/dist/files/index.node.js.map +1 -0
  93. package/dist/format-bytes-BGjeDnvM.d.mts +3 -0
  94. package/dist/format-bytes-BGjeDnvM.d.ts +3 -0
  95. package/dist/function/index.cjs +20 -0
  96. package/dist/function/index.cjs.map +1 -0
  97. package/dist/function/index.d.mts +22 -0
  98. package/dist/function/index.d.ts +22 -4
  99. package/dist/function/index.js +3 -0
  100. package/dist/function/index.js.map +1 -0
  101. package/dist/index.cjs +188 -0
  102. package/dist/index.cjs.map +1 -0
  103. package/dist/index.d.mts +12 -0
  104. package/dist/index.d.ts +12 -8
  105. package/dist/index.js +15 -0
  106. package/dist/index.js.map +1 -0
  107. package/dist/nextjs/index.browser.cjs +110 -0
  108. package/dist/nextjs/index.browser.cjs.map +1 -0
  109. package/dist/nextjs/index.browser.d.mts +10 -0
  110. package/dist/nextjs/index.browser.d.ts +10 -0
  111. package/dist/nextjs/index.browser.js +103 -0
  112. package/dist/nextjs/index.browser.js.map +1 -0
  113. package/dist/string/index.cjs +60 -0
  114. package/dist/string/index.cjs.map +1 -0
  115. package/dist/string/index.d.mts +28 -0
  116. package/dist/string/index.d.ts +28 -14
  117. package/dist/string/index.js +3 -0
  118. package/dist/string/index.js.map +1 -0
  119. package/dist/{cjs/function/try-catch.d.ts → try-catch-B7WzqcPU.d.mts} +4 -4
  120. package/dist/{function/try-catch.d.ts → try-catch-B7WzqcPU.d.ts} +4 -4
  121. package/dist/youtube/index.browser.cjs +35 -0
  122. package/dist/youtube/index.browser.cjs.map +1 -0
  123. package/dist/youtube/index.browser.d.mts +2 -0
  124. package/dist/youtube/index.browser.d.ts +2 -0
  125. package/dist/youtube/index.browser.js +6 -0
  126. package/dist/youtube/index.browser.js.map +1 -0
  127. package/dist/youtube/index.cjs +36 -0
  128. package/dist/youtube/index.cjs.map +1 -0
  129. package/dist/youtube/index.d.mts +12 -0
  130. package/dist/youtube/index.d.ts +12 -7
  131. package/dist/youtube/index.js +7 -0
  132. package/dist/youtube/index.js.map +1 -0
  133. package/dist/youtube/index.node.cjs +26 -0
  134. package/dist/youtube/index.node.cjs.map +1 -0
  135. package/dist/youtube/index.node.d.mts +49 -0
  136. package/dist/youtube/index.node.d.ts +49 -0
  137. package/dist/youtube/index.node.js +5 -0
  138. package/dist/youtube/index.node.js.map +1 -0
  139. package/package.json +164 -49
  140. package/dist/api/client.d.ts.map +0 -1
  141. package/dist/api/index.d.ts.map +0 -1
  142. package/dist/api/wrapper.d.ts +0 -27
  143. package/dist/api/wrapper.d.ts.map +0 -1
  144. package/dist/array/index.d.ts.map +0 -1
  145. package/dist/array/shuffle.d.ts +0 -2
  146. package/dist/array/shuffle.d.ts.map +0 -1
  147. package/dist/array/unique.d.ts +0 -2
  148. package/dist/array/unique.d.ts.map +0 -1
  149. package/dist/cjs/api/client.d.ts +0 -25
  150. package/dist/cjs/api/client.d.ts.map +0 -1
  151. package/dist/cjs/api/client.js +0 -148
  152. package/dist/cjs/api/client.js.map +0 -1
  153. package/dist/cjs/api/index.d.ts +0 -3
  154. package/dist/cjs/api/index.d.ts.map +0 -1
  155. package/dist/cjs/api/index.js +0 -6
  156. package/dist/cjs/api/index.js.map +0 -1
  157. package/dist/cjs/api/wrapper.d.ts +0 -27
  158. package/dist/cjs/api/wrapper.d.ts.map +0 -1
  159. package/dist/cjs/api/wrapper.js +0 -152
  160. package/dist/cjs/api/wrapper.js.map +0 -1
  161. package/dist/cjs/array/index.d.ts +0 -3
  162. package/dist/cjs/array/index.d.ts.map +0 -1
  163. package/dist/cjs/array/index.js +0 -19
  164. package/dist/cjs/array/index.js.map +0 -1
  165. package/dist/cjs/array/shuffle.d.ts +0 -2
  166. package/dist/cjs/array/shuffle.d.ts.map +0 -1
  167. package/dist/cjs/array/shuffle.js +0 -16
  168. package/dist/cjs/array/shuffle.js.map +0 -1
  169. package/dist/cjs/array/unique.d.ts +0 -2
  170. package/dist/cjs/array/unique.d.ts.map +0 -1
  171. package/dist/cjs/array/unique.js +0 -7
  172. package/dist/cjs/array/unique.js.map +0 -1
  173. package/dist/cjs/array.js +0 -1
  174. package/dist/cjs/date/dayjs.d.ts +0 -20
  175. package/dist/cjs/date/dayjs.d.ts.map +0 -1
  176. package/dist/cjs/date/dayjs.js +0 -123
  177. package/dist/cjs/date/dayjs.js.map +0 -1
  178. package/dist/cjs/date/fix-timezone-offset.d.ts +0 -3
  179. package/dist/cjs/date/fix-timezone-offset.d.ts.map +0 -1
  180. package/dist/cjs/date/fix-timezone-offset.js +0 -9
  181. package/dist/cjs/date/fix-timezone-offset.js.map +0 -1
  182. package/dist/cjs/date/format-date.d.ts +0 -23
  183. package/dist/cjs/date/format-date.d.ts.map +0 -1
  184. package/dist/cjs/date/format-date.js +0 -71
  185. package/dist/cjs/date/format-date.js.map +0 -1
  186. package/dist/cjs/date/get-current-date-in-utc.d.ts +0 -3
  187. package/dist/cjs/date/get-current-date-in-utc.d.ts.map +0 -1
  188. package/dist/cjs/date/get-current-date-in-utc.js +0 -8
  189. package/dist/cjs/date/get-current-date-in-utc.js.map +0 -1
  190. package/dist/cjs/date/get-date-in-utc.d.ts +0 -3
  191. package/dist/cjs/date/get-date-in-utc.d.ts.map +0 -1
  192. package/dist/cjs/date/get-date-in-utc.js +0 -8
  193. package/dist/cjs/date/get-date-in-utc.js.map +0 -1
  194. package/dist/cjs/date/get-relative-time.d.ts +0 -3
  195. package/dist/cjs/date/get-relative-time.d.ts.map +0 -1
  196. package/dist/cjs/date/get-relative-time.js +0 -8
  197. package/dist/cjs/date/get-relative-time.js.map +0 -1
  198. package/dist/cjs/date/index.d.ts +0 -8
  199. package/dist/cjs/date/index.d.ts.map +0 -1
  200. package/dist/cjs/date/index.js +0 -24
  201. package/dist/cjs/date/index.js.map +0 -1
  202. package/dist/cjs/date/parse-time-spent.d.ts +0 -15
  203. package/dist/cjs/date/parse-time-spent.d.ts.map +0 -1
  204. package/dist/cjs/date/parse-time-spent.js +0 -207
  205. package/dist/cjs/date/parse-time-spent.js.map +0 -1
  206. package/dist/cjs/date.js +0 -1
  207. package/dist/cjs/files/compress-image.d.ts +0 -10
  208. package/dist/cjs/files/compress-image.d.ts.map +0 -1
  209. package/dist/cjs/files/compress-image.js +0 -61
  210. package/dist/cjs/files/compress-image.js.map +0 -1
  211. package/dist/cjs/files/download-url.d.ts +0 -2
  212. package/dist/cjs/files/download-url.d.ts.map +0 -1
  213. package/dist/cjs/files/download-url.js +0 -29
  214. package/dist/cjs/files/download-url.js.map +0 -1
  215. package/dist/cjs/files/file-delete.d.ts +0 -2
  216. package/dist/cjs/files/file-delete.d.ts.map +0 -1
  217. package/dist/cjs/files/file-delete.js +0 -20
  218. package/dist/cjs/files/file-delete.js.map +0 -1
  219. package/dist/cjs/files/file-exists.d.ts +0 -2
  220. package/dist/cjs/files/file-exists.d.ts.map +0 -1
  221. package/dist/cjs/files/file-exists.js +0 -18
  222. package/dist/cjs/files/file-exists.js.map +0 -1
  223. package/dist/cjs/files/format-bytes.d.ts +0 -2
  224. package/dist/cjs/files/format-bytes.d.ts.map +0 -1
  225. package/dist/cjs/files/format-bytes.js +0 -17
  226. package/dist/cjs/files/format-bytes.js.map +0 -1
  227. package/dist/cjs/files/index.d.ts +0 -6
  228. package/dist/cjs/files/index.d.ts.map +0 -1
  229. package/dist/cjs/files/index.js +0 -22
  230. package/dist/cjs/files/index.js.map +0 -1
  231. package/dist/cjs/files.js +0 -1
  232. package/dist/cjs/function/debounce.d.ts +0 -11
  233. package/dist/cjs/function/debounce.d.ts.map +0 -1
  234. package/dist/cjs/function/debounce.js +0 -26
  235. package/dist/cjs/function/debounce.js.map +0 -1
  236. package/dist/cjs/function/index.d.ts +0 -4
  237. package/dist/cjs/function/index.d.ts.map +0 -1
  238. package/dist/cjs/function/index.js +0 -20
  239. package/dist/cjs/function/index.js.map +0 -1
  240. package/dist/cjs/function/throttle.d.ts +0 -10
  241. package/dist/cjs/function/throttle.d.ts.map +0 -1
  242. package/dist/cjs/function/throttle.js +0 -36
  243. package/dist/cjs/function/throttle.js.map +0 -1
  244. package/dist/cjs/function/try-catch.d.ts.map +0 -1
  245. package/dist/cjs/function/try-catch.js +0 -39
  246. package/dist/cjs/function/try-catch.js.map +0 -1
  247. package/dist/cjs/function.js +0 -1
  248. package/dist/cjs/index.d.ts +0 -8
  249. package/dist/cjs/index.d.ts.map +0 -1
  250. package/dist/cjs/index.js +0 -24
  251. package/dist/cjs/index.js.map +0 -1
  252. package/dist/cjs/string/camel-case.d.ts +0 -2
  253. package/dist/cjs/string/camel-case.d.ts.map +0 -1
  254. package/dist/cjs/string/camel-case.js +0 -25
  255. package/dist/cjs/string/camel-case.js.map +0 -1
  256. package/dist/cjs/string/capitalize.d.ts +0 -2
  257. package/dist/cjs/string/capitalize.d.ts.map +0 -1
  258. package/dist/cjs/string/capitalize.js +0 -13
  259. package/dist/cjs/string/capitalize.js.map +0 -1
  260. package/dist/cjs/string/format-hms-to-seconds.d.ts +0 -2
  261. package/dist/cjs/string/format-hms-to-seconds.d.ts.map +0 -1
  262. package/dist/cjs/string/format-hms-to-seconds.js +0 -30
  263. package/dist/cjs/string/format-hms-to-seconds.js.map +0 -1
  264. package/dist/cjs/string/format-seconds-to-fragment.d.ts +0 -3
  265. package/dist/cjs/string/format-seconds-to-fragment.d.ts.map +0 -1
  266. package/dist/cjs/string/format-seconds-to-fragment.js +0 -20
  267. package/dist/cjs/string/format-seconds-to-fragment.js.map +0 -1
  268. package/dist/cjs/string/format-seconds-to-hms.d.ts +0 -2
  269. package/dist/cjs/string/format-seconds-to-hms.d.ts.map +0 -1
  270. package/dist/cjs/string/format-seconds-to-hms.js +0 -17
  271. package/dist/cjs/string/format-seconds-to-hms.js.map +0 -1
  272. package/dist/cjs/string/format-string-to-time.d.ts +0 -2
  273. package/dist/cjs/string/format-string-to-time.d.ts.map +0 -1
  274. package/dist/cjs/string/format-string-to-time.js +0 -15
  275. package/dist/cjs/string/format-string-to-time.js.map +0 -1
  276. package/dist/cjs/string/index.d.ts +0 -14
  277. package/dist/cjs/string/index.d.ts.map +0 -1
  278. package/dist/cjs/string/index.js +0 -30
  279. package/dist/cjs/string/index.js.map +0 -1
  280. package/dist/cjs/string/kebab-case.d.ts +0 -2
  281. package/dist/cjs/string/kebab-case.d.ts.map +0 -1
  282. package/dist/cjs/string/kebab-case.js +0 -15
  283. package/dist/cjs/string/kebab-case.js.map +0 -1
  284. package/dist/cjs/string/markdown-to-text.d.ts +0 -2
  285. package/dist/cjs/string/markdown-to-text.d.ts.map +0 -1
  286. package/dist/cjs/string/markdown-to-text.js +0 -70
  287. package/dist/cjs/string/markdown-to-text.js.map +0 -1
  288. package/dist/cjs/string/remove-html-tags.d.ts +0 -2
  289. package/dist/cjs/string/remove-html-tags.d.ts.map +0 -1
  290. package/dist/cjs/string/remove-html-tags.js +0 -18
  291. package/dist/cjs/string/remove-html-tags.js.map +0 -1
  292. package/dist/cjs/string/slugify.d.ts +0 -2
  293. package/dist/cjs/string/slugify.d.ts.map +0 -1
  294. package/dist/cjs/string/slugify.js +0 -13
  295. package/dist/cjs/string/slugify.js.map +0 -1
  296. package/dist/cjs/string/snake-case.d.ts +0 -2
  297. package/dist/cjs/string/snake-case.d.ts.map +0 -1
  298. package/dist/cjs/string/snake-case.js +0 -15
  299. package/dist/cjs/string/snake-case.js.map +0 -1
  300. package/dist/cjs/string/to-sentence-case.d.ts +0 -2
  301. package/dist/cjs/string/to-sentence-case.d.ts.map +0 -1
  302. package/dist/cjs/string/to-sentence-case.js +0 -13
  303. package/dist/cjs/string/to-sentence-case.js.map +0 -1
  304. package/dist/cjs/string/truncate.d.ts +0 -2
  305. package/dist/cjs/string/truncate.d.ts.map +0 -1
  306. package/dist/cjs/string/truncate.js +0 -19
  307. package/dist/cjs/string/truncate.js.map +0 -1
  308. package/dist/cjs/string.js +0 -1
  309. package/dist/cjs/youtube/extract-youtube-video-id.d.ts +0 -2
  310. package/dist/cjs/youtube/extract-youtube-video-id.d.ts.map +0 -1
  311. package/dist/cjs/youtube/extract-youtube-video-id.js +0 -30
  312. package/dist/cjs/youtube/extract-youtube-video-id.js.map +0 -1
  313. package/dist/cjs/youtube/generate-youtube-url.d.ts +0 -20
  314. package/dist/cjs/youtube/generate-youtube-url.d.ts.map +0 -1
  315. package/dist/cjs/youtube/generate-youtube-url.js +0 -86
  316. package/dist/cjs/youtube/generate-youtube-url.js.map +0 -1
  317. package/dist/cjs/youtube/get-video-duration.d.ts +0 -7
  318. package/dist/cjs/youtube/get-video-duration.d.ts.map +0 -1
  319. package/dist/cjs/youtube/get-video-duration.js +0 -150
  320. package/dist/cjs/youtube/get-video-duration.js.map +0 -1
  321. package/dist/cjs/youtube/get-youtube-thumbnail.d.ts +0 -2
  322. package/dist/cjs/youtube/get-youtube-thumbnail.d.ts.map +0 -1
  323. package/dist/cjs/youtube/get-youtube-thumbnail.js +0 -68
  324. package/dist/cjs/youtube/get-youtube-thumbnail.js.map +0 -1
  325. package/dist/cjs/youtube/get-youtube-video-info.d.ts +0 -26
  326. package/dist/cjs/youtube/get-youtube-video-info.d.ts.map +0 -1
  327. package/dist/cjs/youtube/get-youtube-video-info.js +0 -244
  328. package/dist/cjs/youtube/get-youtube-video-info.js.map +0 -1
  329. package/dist/cjs/youtube/index.d.ts +0 -7
  330. package/dist/cjs/youtube/index.d.ts.map +0 -1
  331. package/dist/cjs/youtube/index.js +0 -23
  332. package/dist/cjs/youtube/index.js.map +0 -1
  333. package/dist/cjs/youtube/validate-youtube-link.d.ts +0 -2
  334. package/dist/cjs/youtube/validate-youtube-link.d.ts.map +0 -1
  335. package/dist/cjs/youtube/validate-youtube-link.js +0 -77
  336. package/dist/cjs/youtube/validate-youtube-link.js.map +0 -1
  337. package/dist/cjs/youtube.js +0 -1
  338. package/dist/date/dayjs.d.ts +0 -20
  339. package/dist/date/dayjs.d.ts.map +0 -1
  340. package/dist/date/fix-timezone-offset.d.ts +0 -3
  341. package/dist/date/fix-timezone-offset.d.ts.map +0 -1
  342. package/dist/date/format-date.d.ts +0 -23
  343. package/dist/date/format-date.d.ts.map +0 -1
  344. package/dist/date/get-current-date-in-utc.d.ts +0 -3
  345. package/dist/date/get-current-date-in-utc.d.ts.map +0 -1
  346. package/dist/date/get-date-in-utc.d.ts +0 -3
  347. package/dist/date/get-date-in-utc.d.ts.map +0 -1
  348. package/dist/date/get-relative-time.d.ts +0 -3
  349. package/dist/date/get-relative-time.d.ts.map +0 -1
  350. package/dist/date/index.d.ts.map +0 -1
  351. package/dist/date/parse-time-spent.d.ts +0 -15
  352. package/dist/date/parse-time-spent.d.ts.map +0 -1
  353. package/dist/esm/api/client.js +0 -143
  354. package/dist/esm/api/index.js +0 -1
  355. package/dist/esm/api/wrapper.js +0 -148
  356. package/dist/esm/array/index.js +0 -2
  357. package/dist/esm/array/shuffle.js +0 -12
  358. package/dist/esm/array/unique.js +0 -3
  359. package/dist/esm/array.js +0 -1
  360. package/dist/esm/date/dayjs.js +0 -111
  361. package/dist/esm/date/fix-timezone-offset.js +0 -5
  362. package/dist/esm/date/format-date.js +0 -67
  363. package/dist/esm/date/get-current-date-in-utc.js +0 -4
  364. package/dist/esm/date/get-date-in-utc.js +0 -4
  365. package/dist/esm/date/get-relative-time.js +0 -4
  366. package/dist/esm/date/index.js +0 -7
  367. package/dist/esm/date/parse-time-spent.js +0 -203
  368. package/dist/esm/date.js +0 -1
  369. package/dist/esm/files/compress-image.js +0 -57
  370. package/dist/esm/files/download-url.js +0 -24
  371. package/dist/esm/files/file-delete.js +0 -12
  372. package/dist/esm/files/file-exists.js +0 -10
  373. package/dist/esm/files/format-bytes.js +0 -13
  374. package/dist/esm/files/index.js +0 -5
  375. package/dist/esm/files.js +0 -1
  376. package/dist/esm/function/debounce.js +0 -22
  377. package/dist/esm/function/index.js +0 -3
  378. package/dist/esm/function/throttle.js +0 -32
  379. package/dist/esm/function/try-catch.js +0 -35
  380. package/dist/esm/function.js +0 -1
  381. package/dist/esm/index.js +0 -7
  382. package/dist/esm/string/camel-case.js +0 -21
  383. package/dist/esm/string/capitalize.js +0 -9
  384. package/dist/esm/string/format-hms-to-seconds.js +0 -25
  385. package/dist/esm/string/format-seconds-to-fragment.js +0 -15
  386. package/dist/esm/string/format-seconds-to-hms.js +0 -13
  387. package/dist/esm/string/format-string-to-time.js +0 -10
  388. package/dist/esm/string/index.js +0 -13
  389. package/dist/esm/string/kebab-case.js +0 -11
  390. package/dist/esm/string/markdown-to-text.js +0 -66
  391. package/dist/esm/string/remove-html-tags.js +0 -14
  392. package/dist/esm/string/slugify.js +0 -9
  393. package/dist/esm/string/snake-case.js +0 -11
  394. package/dist/esm/string/to-sentence-case.js +0 -9
  395. package/dist/esm/string/truncate.js +0 -15
  396. package/dist/esm/string.js +0 -1
  397. package/dist/esm/youtube/extract-youtube-video-id.js +0 -26
  398. package/dist/esm/youtube/generate-youtube-url.js +0 -81
  399. package/dist/esm/youtube/get-video-duration.js +0 -146
  400. package/dist/esm/youtube/get-youtube-thumbnail.js +0 -31
  401. package/dist/esm/youtube/get-youtube-video-info.js +0 -207
  402. package/dist/esm/youtube/index.js +0 -6
  403. package/dist/esm/youtube/validate-youtube-link.js +0 -40
  404. package/dist/esm/youtube.js +0 -1
  405. package/dist/files/compress-image.d.ts +0 -10
  406. package/dist/files/compress-image.d.ts.map +0 -1
  407. package/dist/files/download-url.d.ts +0 -2
  408. package/dist/files/download-url.d.ts.map +0 -1
  409. package/dist/files/file-delete.d.ts +0 -2
  410. package/dist/files/file-delete.d.ts.map +0 -1
  411. package/dist/files/file-exists.d.ts +0 -2
  412. package/dist/files/file-exists.d.ts.map +0 -1
  413. package/dist/files/format-bytes.d.ts +0 -2
  414. package/dist/files/format-bytes.d.ts.map +0 -1
  415. package/dist/files/index.d.ts.map +0 -1
  416. package/dist/function/debounce.d.ts +0 -11
  417. package/dist/function/debounce.d.ts.map +0 -1
  418. package/dist/function/index.d.ts.map +0 -1
  419. package/dist/function/throttle.d.ts +0 -10
  420. package/dist/function/throttle.d.ts.map +0 -1
  421. package/dist/function/try-catch.d.ts.map +0 -1
  422. package/dist/index.d.ts.map +0 -1
  423. package/dist/string/camel-case.d.ts +0 -2
  424. package/dist/string/camel-case.d.ts.map +0 -1
  425. package/dist/string/capitalize.d.ts +0 -2
  426. package/dist/string/capitalize.d.ts.map +0 -1
  427. package/dist/string/format-hms-to-seconds.d.ts +0 -2
  428. package/dist/string/format-hms-to-seconds.d.ts.map +0 -1
  429. package/dist/string/format-seconds-to-fragment.d.ts +0 -3
  430. package/dist/string/format-seconds-to-fragment.d.ts.map +0 -1
  431. package/dist/string/format-seconds-to-hms.d.ts +0 -2
  432. package/dist/string/format-seconds-to-hms.d.ts.map +0 -1
  433. package/dist/string/format-string-to-time.d.ts +0 -2
  434. package/dist/string/format-string-to-time.d.ts.map +0 -1
  435. package/dist/string/index.d.ts.map +0 -1
  436. package/dist/string/kebab-case.d.ts +0 -2
  437. package/dist/string/kebab-case.d.ts.map +0 -1
  438. package/dist/string/markdown-to-text.d.ts +0 -2
  439. package/dist/string/markdown-to-text.d.ts.map +0 -1
  440. package/dist/string/remove-html-tags.d.ts +0 -2
  441. package/dist/string/remove-html-tags.d.ts.map +0 -1
  442. package/dist/string/slugify.d.ts +0 -2
  443. package/dist/string/slugify.d.ts.map +0 -1
  444. package/dist/string/snake-case.d.ts +0 -2
  445. package/dist/string/snake-case.d.ts.map +0 -1
  446. package/dist/string/to-sentence-case.d.ts +0 -2
  447. package/dist/string/to-sentence-case.d.ts.map +0 -1
  448. package/dist/string/truncate.d.ts +0 -2
  449. package/dist/string/truncate.d.ts.map +0 -1
  450. package/dist/youtube/extract-youtube-video-id.d.ts +0 -2
  451. package/dist/youtube/extract-youtube-video-id.d.ts.map +0 -1
  452. package/dist/youtube/generate-youtube-url.d.ts +0 -20
  453. package/dist/youtube/generate-youtube-url.d.ts.map +0 -1
  454. package/dist/youtube/get-video-duration.d.ts +0 -7
  455. package/dist/youtube/get-video-duration.d.ts.map +0 -1
  456. package/dist/youtube/get-youtube-thumbnail.d.ts +0 -2
  457. package/dist/youtube/get-youtube-thumbnail.d.ts.map +0 -1
  458. package/dist/youtube/get-youtube-video-info.d.ts +0 -26
  459. package/dist/youtube/get-youtube-video-info.d.ts.map +0 -1
  460. package/dist/youtube/index.d.ts.map +0 -1
  461. package/dist/youtube/validate-youtube-link.d.ts +0 -2
  462. package/dist/youtube/validate-youtube-link.d.ts.map +0 -1
@@ -1,148 +0,0 @@
1
- import { isAxiosError } from "axios";
2
- /**
3
- * Extracts error properties from Axios errors
4
- */
5
- async function extractAxiosErrorDetails(error) {
6
- var _a, _b, _c;
7
- const errorObj = {
8
- message: error.message || "Axios Error",
9
- status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
10
- path: (_b = error.config) === null || _b === void 0 ? void 0 : _b.url,
11
- };
12
- if (((_c = error.response) === null || _c === void 0 ? void 0 : _c.data) && typeof error.response.data === "object") {
13
- return await enrichErrorWithData(errorObj, Promise.resolve(error.response.data));
14
- }
15
- return errorObj;
16
- }
17
- /**
18
- * Extracts error properties from standard Error objects
19
- */
20
- function extractStandardErrorDetails(error) {
21
- const errorObj = {
22
- message: error.message,
23
- };
24
- // Capture any custom properties the error might have
25
- const extendedError = error;
26
- if (extendedError.code)
27
- errorObj.code = String(extendedError.code);
28
- if (extendedError.status)
29
- errorObj.status = Number(extendedError.status);
30
- if (extendedError.details)
31
- errorObj.details = extendedError.details;
32
- return errorObj;
33
- }
34
- /**
35
- * Extracts error properties from fetch Response objects
36
- */
37
- async function extractResponseErrorDetails(response) {
38
- const errorObj = {
39
- message: `HTTP Error ${response.status}: ${response.statusText}`,
40
- status: response.status,
41
- path: response.url,
42
- };
43
- try {
44
- // Clone the response to avoid consuming the body stream
45
- const clonedResponse = response.clone();
46
- const errorData = await clonedResponse.json();
47
- // Directly enrich the error object with the parsed data
48
- if (errorData && typeof errorData === "object") {
49
- if ("message" in errorData && errorData.message) {
50
- errorObj.message = String(errorData.message);
51
- }
52
- if ("code" in errorData) {
53
- errorObj.code = String(errorData.code);
54
- }
55
- if ("details" in errorData) {
56
- errorObj.details = errorData.details;
57
- }
58
- else if ("issues" in errorData) {
59
- errorObj.details = errorData.issues;
60
- }
61
- if ("timestamp" in errorData) {
62
- errorObj.timestamp = String(errorData.timestamp);
63
- }
64
- }
65
- return errorObj;
66
- }
67
- catch (_a) {
68
- // If JSON parsing fails, return the basic error object
69
- return errorObj;
70
- }
71
- }
72
- /**
73
- * Enriches an error object with additional data from response
74
- */
75
- async function enrichErrorWithData(errorObj, errorData, path) {
76
- const data = await errorData;
77
- if (data) {
78
- if ("message" in data) {
79
- errorObj.message = String(data.message);
80
- }
81
- if ("code" in data) {
82
- errorObj.code = String(data.code);
83
- }
84
- if ("details" in data) {
85
- errorObj.details = data.details;
86
- }
87
- else if ("issues" in data) {
88
- errorObj.details = data.issues;
89
- }
90
- if ("timestamp" in data) {
91
- errorObj.timestamp = String(data.timestamp);
92
- }
93
- if (path) {
94
- errorObj.path = path;
95
- }
96
- }
97
- return errorObj;
98
- }
99
- /**
100
- * Determines the type of error and routes to appropriate handler
101
- */
102
- async function processError(error) {
103
- if (error instanceof Response) {
104
- return extractResponseErrorDetails(error);
105
- }
106
- if (isAxiosError(error)) {
107
- return extractAxiosErrorDetails(error);
108
- }
109
- if (error instanceof Error) {
110
- return extractStandardErrorDetails(error);
111
- }
112
- // Handle unknown error types
113
- return {
114
- message: error ? JSON.stringify(error) : "Unknown error",
115
- };
116
- }
117
- /**
118
- * Wraps API calls with standardized error handling
119
- *
120
- * @param apiCall - The API call function to execute
121
- * @param defaultData - Optional default value to return when an error occurs
122
- * @returns A standardized result object with data or formatted error message
123
- *
124
- * @example
125
- * // Basic usage
126
- * const result = await apiWrapper(() => fetchUserData(userId));
127
- *
128
- * @example
129
- * // With default data value
130
- * const result = await apiWrapper(() => fetchPosts(), []);
131
- * // result.data will be [] instead of null on error
132
- */
133
- export async function apiWrapper(apiCall, defaultData) {
134
- try {
135
- const data = await apiCall();
136
- return {
137
- data,
138
- error: null,
139
- };
140
- }
141
- catch (error) {
142
- const errorObj = await processError(error);
143
- return {
144
- data: (defaultData !== null && defaultData !== void 0 ? defaultData : null),
145
- error: errorObj,
146
- };
147
- }
148
- }
@@ -1,2 +0,0 @@
1
- export * from "./shuffle.js";
2
- export * from "./unique.js";
@@ -1,12 +0,0 @@
1
- export function shuffle(array) {
2
- const shuffled = [...array];
3
- for (let i = shuffled.length - 1; i > 0; i--) {
4
- // Get cryptographically strong random values
5
- const randomBuffer = new Uint32Array(1);
6
- crypto.getRandomValues(randomBuffer);
7
- // Use modulo to get a value in our range
8
- const j = randomBuffer[0] % (i + 1);
9
- [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
10
- }
11
- return shuffled;
12
- }
@@ -1,3 +0,0 @@
1
- export function unique(array) {
2
- return [...new Set(array)];
3
- }
package/dist/esm/array.js DELETED
@@ -1 +0,0 @@
1
- export * from './array/index.js'
@@ -1,111 +0,0 @@
1
- import dayJs from "dayjs";
2
- import advancedFormat from "dayjs/plugin/advancedFormat";
3
- import customParseFormat from "dayjs/plugin/customParseFormat";
4
- import localizedFormat from "dayjs/plugin/localizedFormat";
5
- import relativeTime from "dayjs/plugin/relativeTime";
6
- import timezone from "dayjs/plugin/timezone";
7
- import utc from "dayjs/plugin/utc";
8
- import "dayjs/locale/en";
9
- import "dayjs/locale/es";
10
- import "dayjs/locale/fr";
11
- import "dayjs/locale/pt-br";
12
- const DEFAULT_INTL_CONFIG = {
13
- locale: "pt-BR",
14
- options: {
15
- month: "long",
16
- day: "numeric",
17
- year: "numeric",
18
- },
19
- };
20
- let globalIntlConfig = {
21
- locale: DEFAULT_INTL_CONFIG.locale,
22
- options: { ...DEFAULT_INTL_CONFIG.options },
23
- };
24
- function mergeIntlConfigs(base, override) {
25
- var _a;
26
- if (!override) {
27
- return {
28
- locale: base.locale,
29
- options: { ...base.options },
30
- };
31
- }
32
- const mergedLocale = (_a = override.locale) !== null && _a !== void 0 ? _a : base.locale;
33
- const mergedOptions = { ...base.options };
34
- if (override.options) {
35
- for (const key of Object.keys(override.options)) {
36
- const value = override.options[key];
37
- if (value === undefined || value === null) {
38
- delete mergedOptions[key];
39
- }
40
- else {
41
- mergedOptions[key] = value;
42
- }
43
- }
44
- }
45
- return {
46
- locale: mergedLocale,
47
- options: mergedOptions,
48
- };
49
- }
50
- const intlPlugin = (pluginConfig, DayjsClass) => {
51
- if (pluginConfig) {
52
- globalIntlConfig = mergeIntlConfigs(globalIntlConfig, pluginConfig);
53
- }
54
- const formatIntl = function formatIntl(config) {
55
- const resolved = mergeIntlConfigs(globalIntlConfig, config);
56
- return new Intl.DateTimeFormat(resolved.locale, resolved.options).format(this.toDate());
57
- };
58
- const toIntlFormatter = function toIntlFormatter(config) {
59
- const resolved = mergeIntlConfigs(globalIntlConfig, config);
60
- return new Intl.DateTimeFormat(resolved.locale, resolved.options);
61
- };
62
- Object.defineProperty(DayjsClass.prototype, "formatIntl", {
63
- value: formatIntl,
64
- configurable: true,
65
- });
66
- Object.defineProperty(DayjsClass.prototype, "toIntlFormatter", {
67
- value: toIntlFormatter,
68
- configurable: true,
69
- });
70
- };
71
- export function getDayjsGlobalIntl() {
72
- return {
73
- locale: globalIntlConfig.locale,
74
- options: { ...globalIntlConfig.options },
75
- };
76
- }
77
- export function setDayjsGlobalIntl(config) {
78
- globalIntlConfig = mergeIntlConfigs(globalIntlConfig, config);
79
- return getDayjsGlobalIntl();
80
- }
81
- export function resetDayjsGlobalIntl() {
82
- globalIntlConfig = {
83
- locale: DEFAULT_INTL_CONFIG.locale,
84
- options: { ...DEFAULT_INTL_CONFIG.options },
85
- };
86
- return getDayjsGlobalIntl();
87
- }
88
- export function withDayjsGlobalIntl(config, callback) {
89
- const previous = getDayjsGlobalIntl();
90
- globalIntlConfig = mergeIntlConfigs(globalIntlConfig, config);
91
- try {
92
- return callback();
93
- }
94
- finally {
95
- globalIntlConfig = {
96
- locale: previous.locale,
97
- options: { ...previous.options },
98
- };
99
- }
100
- }
101
- export function resolveDayjsIntlConfig(config) {
102
- return mergeIntlConfigs(globalIntlConfig, config);
103
- }
104
- dayJs.extend(utc);
105
- dayJs.extend(customParseFormat);
106
- dayJs.extend(advancedFormat);
107
- dayJs.extend(timezone);
108
- dayJs.extend(localizedFormat);
109
- dayJs.extend(relativeTime);
110
- dayJs.extend(intlPlugin);
111
- export const dayjs = dayJs;
@@ -1,5 +0,0 @@
1
- import { dayjs } from "./dayjs.js";
2
- export function fixTimezoneOffset(utcDate) {
3
- const offset = new Date(utcDate).getTimezoneOffset();
4
- return dayjs(utcDate).add(offset, "minute");
5
- }
@@ -1,67 +0,0 @@
1
- import { dayjs, getDayjsGlobalIntl } from "./dayjs.js";
2
- function isFormatDateConfig(value) {
3
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4
- }
5
- function isValidLocaleTag(value) {
6
- if (typeof Intl !== "undefined" &&
7
- typeof Intl.getCanonicalLocales === "function") {
8
- try {
9
- Intl.getCanonicalLocales(value);
10
- return true;
11
- }
12
- catch (_a) {
13
- return false;
14
- }
15
- }
16
- return /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(value);
17
- }
18
- function toDayjsLocale(locale) {
19
- if (!locale)
20
- return undefined;
21
- const first = Array.isArray(locale)
22
- ? locale[0]
23
- : locale;
24
- return typeof first === "string" ? first : String(first);
25
- }
26
- export function formatDate(date, localeOrConfig = getDayjsGlobalIntl().locale, opts) {
27
- var _a;
28
- const instance = dayjs(date);
29
- if (!instance.isValid()) {
30
- throw new RangeError("Invalid time value");
31
- }
32
- if (isFormatDateConfig(localeOrConfig)) {
33
- const { format, locale, intl, useIntl } = localeOrConfig;
34
- const baseLocale = locale !== null && locale !== void 0 ? locale : toDayjsLocale(intl === null || intl === void 0 ? void 0 : intl.locale);
35
- const workingInstance = baseLocale ? instance.locale(baseLocale) : instance;
36
- if (format && !useIntl) {
37
- return workingInstance.format(format);
38
- }
39
- const intlConfig = intl
40
- ? {
41
- locale: (_a = intl.locale) !== null && _a !== void 0 ? _a : baseLocale,
42
- options: intl.options,
43
- }
44
- : baseLocale
45
- ? {
46
- locale: baseLocale,
47
- }
48
- : undefined;
49
- return workingInstance.formatIntl(intlConfig);
50
- }
51
- if (typeof localeOrConfig === "string" && opts === undefined) {
52
- if (!isValidLocaleTag(localeOrConfig)) {
53
- return instance.format(localeOrConfig);
54
- }
55
- }
56
- const localeForDayjs = toDayjsLocale(localeOrConfig);
57
- const workingInstance = localeForDayjs
58
- ? instance.locale(localeForDayjs)
59
- : instance;
60
- const intlConfig = localeOrConfig !== undefined || opts !== undefined
61
- ? {
62
- locale: localeOrConfig,
63
- options: opts,
64
- }
65
- : undefined;
66
- return workingInstance.formatIntl(intlConfig);
67
- }
@@ -1,4 +0,0 @@
1
- import { dayjs } from "./dayjs.js";
2
- export function getCurrentDateInUTC() {
3
- return dayjs().utc();
4
- }
@@ -1,4 +0,0 @@
1
- import { dayjs } from "./dayjs.js";
2
- export function getDateInUTC(date) {
3
- return dayjs(date).utc();
4
- }
@@ -1,4 +0,0 @@
1
- import { dayjs } from "./dayjs.js";
2
- export function getRelativeTime(date, dateNow = dayjs()) {
3
- return dayjs(date).from(dateNow);
4
- }
@@ -1,7 +0,0 @@
1
- export * from "./dayjs.js";
2
- export * from "./fix-timezone-offset.js";
3
- export * from "./format-date.js";
4
- export * from "./get-current-date-in-utc.js";
5
- export * from "./get-date-in-utc.js";
6
- export * from "./get-relative-time.js";
7
- export * from "./parse-time-spent.js";
@@ -1,203 +0,0 @@
1
- import { fixTimezoneOffset } from "./fix-timezone-offset.js";
2
- // Supported locales and their translations
3
- const locales = {
4
- "pt-BR": {
5
- year: { singular: "ano", plural: "anos" },
6
- month: { singular: "mês", plural: "meses" },
7
- day: { singular: "dia", plural: "dias" },
8
- hour: { singular: "hora", plural: "horas" },
9
- minute: { singular: "minuto", plural: "minutos" },
10
- second: { singular: "segundo", plural: "segundos" },
11
- formatList: (parts) => {
12
- if (parts.length === 0)
13
- return "";
14
- if (parts.length === 1)
15
- return parts[0];
16
- const lastPart = parts[parts.length - 1];
17
- const otherParts = parts.slice(0, -1);
18
- return `${otherParts.join(", ")} e ${lastPart}`;
19
- },
20
- compactTokens: {
21
- year: "a",
22
- month: "m",
23
- day: "d",
24
- hour: "h",
25
- minute: "min",
26
- second: "s",
27
- },
28
- },
29
- "en-US": {
30
- year: { singular: "year", plural: "years" },
31
- month: { singular: "month", plural: "months" },
32
- day: { singular: "day", plural: "days" },
33
- hour: { singular: "hour", plural: "hours" },
34
- minute: { singular: "minute", plural: "minutes" },
35
- second: { singular: "second", plural: "seconds" },
36
- formatList: (parts) => {
37
- if (parts.length === 0)
38
- return "";
39
- if (parts.length === 1)
40
- return parts[0];
41
- if (parts.length === 2)
42
- return `${parts[0]} and ${parts[1]}`;
43
- return `${parts.slice(0, -1).join(", ")}, and ${parts[parts.length - 1]}`;
44
- },
45
- compactTokens: {
46
- year: "y",
47
- month: "mo",
48
- day: "d",
49
- hour: "h",
50
- minute: "m",
51
- second: "s",
52
- },
53
- },
54
- "es-ES": {
55
- year: { singular: "año", plural: "años" },
56
- month: { singular: "mes", plural: "meses" },
57
- day: { singular: "día", plural: "días" },
58
- hour: { singular: "hora", plural: "horas" },
59
- minute: { singular: "minuto", plural: "minutos" },
60
- second: { singular: "segundo", plural: "segundos" },
61
- formatList: (parts) => {
62
- if (parts.length === 0)
63
- return "";
64
- if (parts.length === 1)
65
- return parts[0];
66
- const lastPart = parts[parts.length - 1];
67
- const otherParts = parts.slice(0, -1);
68
- return `${otherParts.join(", ")} y ${lastPart}`;
69
- },
70
- compactTokens: {
71
- year: "a",
72
- month: "mes",
73
- day: "d",
74
- hour: "h",
75
- minute: "min",
76
- second: "s",
77
- },
78
- },
79
- "fr-FR": {
80
- year: { singular: "an", plural: "ans" },
81
- month: { singular: "mois", plural: "mois" },
82
- day: { singular: "jour", plural: "jours" },
83
- hour: { singular: "heure", plural: "heures" },
84
- minute: { singular: "minute", plural: "minutes" },
85
- second: { singular: "seconde", plural: "secondes" },
86
- formatList: (parts) => {
87
- if (parts.length === 0)
88
- return "";
89
- if (parts.length === 1)
90
- return parts[0];
91
- const lastPart = parts[parts.length - 1];
92
- const otherParts = parts.slice(0, -1);
93
- return `${otherParts.join(", ")} et ${lastPart}`;
94
- },
95
- compactTokens: {
96
- year: "a",
97
- month: "m",
98
- day: "j",
99
- hour: "h",
100
- minute: "min",
101
- second: "s",
102
- },
103
- },
104
- };
105
- // options: format -> 'verbose' | 'compact', minimal -> show only largest non-zero unit
106
- export function parseTimeSpent(initialDate, finalDate, locale = "pt-BR", // Default to Portuguese for backward compatibility
107
- options) {
108
- var _a, _b;
109
- const final = fixTimezoneOffset(finalDate);
110
- const initial = fixTimezoneOffset(initialDate);
111
- const years = final.diff(initial, "year");
112
- const months = final.diff(initial.add(years, "year"), "month");
113
- const days = final.diff(initial.add(years, "year").add(months, "month"), "day");
114
- const hours = final.diff(initial.add(years, "year").add(months, "month").add(days, "day"), "hour");
115
- const minutes = final.diff(initial
116
- .add(years, "year")
117
- .add(months, "month")
118
- .add(days, "day")
119
- .add(hours, "hour"), "minute");
120
- const seconds = final.diff(initial
121
- .add(years, "year")
122
- .add(months, "month")
123
- .add(days, "day")
124
- .add(hours, "hour")
125
- .add(minutes, "minute"), "second");
126
- // Use default locale if the requested one isn't supported
127
- const translations = locales[locale] || locales["pt-BR"];
128
- // Build verbose parts (localized words)
129
- const verboseParts = [];
130
- if (years > 0) {
131
- const unit = years === 1 ? translations.year.singular : translations.year.plural;
132
- verboseParts.push(`${years} ${unit}`);
133
- }
134
- if (months > 0) {
135
- const unit = months === 1 ? translations.month.singular : translations.month.plural;
136
- verboseParts.push(`${months} ${unit}`);
137
- }
138
- if (days > 0) {
139
- const unit = days === 1 ? translations.day.singular : translations.day.plural;
140
- verboseParts.push(`${days} ${unit}`);
141
- }
142
- if (hours > 0) {
143
- const unit = hours === 1 ? translations.hour.singular : translations.hour.plural;
144
- verboseParts.push(`${hours} ${unit}`);
145
- }
146
- if (minutes > 0) {
147
- const unit = minutes === 1 ? translations.minute.singular : translations.minute.plural;
148
- verboseParts.push(`${minutes} ${unit}`);
149
- }
150
- if (seconds > 0) {
151
- const unit = seconds === 1 ? translations.second.singular : translations.second.plural;
152
- verboseParts.push(`${seconds} ${unit}`);
153
- }
154
- // Build compact parts (e.g. "1a2m3d")
155
- const compactPieces = [];
156
- if (years > 0)
157
- compactPieces.push(`${years}${translations.compactTokens.year}`);
158
- if (months > 0)
159
- compactPieces.push(`${months}${translations.compactTokens.month}`);
160
- if (days > 0)
161
- compactPieces.push(`${days}${translations.compactTokens.day}`);
162
- if (hours > 0)
163
- compactPieces.push(`${hours}${translations.compactTokens.hour}`);
164
- if (minutes > 0)
165
- compactPieces.push(`${minutes}${translations.compactTokens.minute}`);
166
- if (seconds > 0)
167
- compactPieces.push(`${seconds}${translations.compactTokens.second}`);
168
- const format = (_a = options === null || options === void 0 ? void 0 : options.format) !== null && _a !== void 0 ? _a : "verbose";
169
- const minimal = (_b = options === null || options === void 0 ? void 0 : options.minimal) !== null && _b !== void 0 ? _b : false;
170
- let formatted = "";
171
- if (format === "compact") {
172
- if (compactPieces.length === 0) {
173
- formatted = "";
174
- }
175
- else if (minimal) {
176
- formatted = compactPieces[0];
177
- }
178
- else {
179
- formatted = compactPieces.join("");
180
- }
181
- }
182
- else {
183
- // verbose
184
- if (verboseParts.length === 0) {
185
- formatted = "";
186
- }
187
- else if (minimal) {
188
- formatted = verboseParts[0];
189
- }
190
- else {
191
- formatted = translations.formatList(verboseParts);
192
- }
193
- }
194
- return {
195
- years,
196
- months,
197
- days,
198
- hours,
199
- minutes,
200
- seconds,
201
- formatted,
202
- };
203
- }
package/dist/esm/date.js DELETED
@@ -1 +0,0 @@
1
- export * from './date/index.js'
@@ -1,57 +0,0 @@
1
- function convertToWebp(filename) {
2
- const lastDotIndex = filename.lastIndexOf(".");
3
- if (lastDotIndex === -1) {
4
- return `${filename}.webp`;
5
- }
6
- return `${filename.substring(0, lastDotIndex)}.webp`;
7
- }
8
- export function compressImage({ file, maxWidth = Number.POSITIVE_INFINITY, maxHeight = Number.POSITIVE_INFINITY, quality = 1, allowedFileTypes = ["image/jpg", "image/jpeg", "image/png", "image/webp"], }) {
9
- if (!allowedFileTypes.includes(file.type)) {
10
- throw new Error("Image format not supported");
11
- }
12
- return new Promise((resolve, reject) => {
13
- const reader = new FileReader();
14
- reader.onload = (event) => {
15
- var _a;
16
- const compressed = new Image();
17
- compressed.onload = () => {
18
- const canvas = document.createElement("canvas");
19
- let width = compressed.width;
20
- let height = compressed.height;
21
- if (width > height) {
22
- if (width > maxWidth) {
23
- height *= maxWidth / width;
24
- width = maxWidth;
25
- }
26
- }
27
- else {
28
- if (height > maxHeight) {
29
- width *= maxHeight / height;
30
- height = maxHeight;
31
- }
32
- }
33
- canvas.width = width;
34
- canvas.height = height;
35
- const context = canvas.getContext("2d");
36
- if (!context) {
37
- reject(new Error("Failed to get canvas context"));
38
- return;
39
- }
40
- context.drawImage(compressed, 0, 0, width, height);
41
- canvas.toBlob((blob) => {
42
- if (!blob) {
43
- reject(new Error("Failed to compress image."));
44
- return;
45
- }
46
- const compressedFile = new File([blob], convertToWebp(file.name), {
47
- type: "image/webp",
48
- lastModified: Date.now(),
49
- });
50
- resolve(compressedFile);
51
- }, "image/webp", quality);
52
- };
53
- compressed.src = (_a = event.target) === null || _a === void 0 ? void 0 : _a.result;
54
- };
55
- reader.readAsDataURL(file);
56
- });
57
- }
@@ -1,24 +0,0 @@
1
- export const downloadUrl = async (url) => {
2
- try {
3
- const urlObj = new URL(url);
4
- const pathname = urlObj.pathname;
5
- const segments = pathname.split("/").filter((segment) => segment.length > 0);
6
- const filename = segments.length > 0 ? segments[segments.length - 1] : null;
7
- if (!filename || !filename.includes(".")) {
8
- throw new Error("URL does not contain a valid filename");
9
- }
10
- const response = await fetch(url, { mode: "cors" });
11
- const blob = await response.blob();
12
- const link = document.createElement("a");
13
- link.href = window.URL.createObjectURL(blob);
14
- link.download = filename;
15
- document.body.appendChild(link);
16
- link.click();
17
- document.body.removeChild(link);
18
- return true;
19
- }
20
- catch (error) {
21
- console.error("Error downloading the file", error);
22
- return false;
23
- }
24
- };