@herowcode/utils 1.3.4 → 1.4.8
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.
- package/README.md +3 -5
- package/dist/api/index.cjs +12 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/{client.d.ts → index.d.mts} +19 -8
- package/dist/api/index.d.ts +36 -3
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -0
- package/dist/array/index.cjs +16 -0
- package/dist/array/index.cjs.map +1 -0
- package/dist/array/index.d.mts +5 -0
- package/dist/array/index.d.ts +5 -3
- package/dist/array/index.js +3 -0
- package/dist/array/index.js.map +1 -0
- package/dist/chunk-2MANLCNG.cjs +23 -0
- package/dist/chunk-2MANLCNG.cjs.map +1 -0
- package/dist/chunk-2RTW37WD.js +20 -0
- package/dist/chunk-2RTW37WD.js.map +1 -0
- package/dist/chunk-2Y6M7IOG.js +250 -0
- package/dist/chunk-2Y6M7IOG.js.map +1 -0
- package/dist/chunk-3JUB2OJL.js +3 -0
- package/dist/chunk-3JUB2OJL.js.map +1 -0
- package/dist/chunk-53JMVGIG.js +187 -0
- package/dist/chunk-53JMVGIG.js.map +1 -0
- package/dist/chunk-56NHIM5J.js +151 -0
- package/dist/chunk-56NHIM5J.js.map +1 -0
- package/dist/chunk-5OLQJUNS.js +66 -0
- package/dist/chunk-5OLQJUNS.js.map +1 -0
- package/dist/chunk-5YOEKMTJ.cjs +321 -0
- package/dist/chunk-5YOEKMTJ.cjs.map +1 -0
- package/dist/chunk-6TWPZ6LL.cjs +4 -0
- package/dist/chunk-6TWPZ6LL.cjs.map +1 -0
- package/dist/chunk-AQZBHMTO.js +96 -0
- package/dist/chunk-AQZBHMTO.js.map +1 -0
- package/dist/chunk-ATWN4SRX.js +29 -0
- package/dist/chunk-ATWN4SRX.js.map +1 -0
- package/dist/chunk-GRSF4RY2.cjs +20 -0
- package/dist/chunk-GRSF4RY2.cjs.map +1 -0
- package/dist/chunk-GX5E5B4L.cjs +70 -0
- package/dist/chunk-GX5E5B4L.cjs.map +1 -0
- package/dist/chunk-HK727IAV.cjs +201 -0
- package/dist/chunk-HK727IAV.cjs.map +1 -0
- package/dist/chunk-LJ6KOZD4.cjs +154 -0
- package/dist/chunk-LJ6KOZD4.cjs.map +1 -0
- package/dist/chunk-N2DRAZ3A.cjs +29 -0
- package/dist/chunk-N2DRAZ3A.cjs.map +1 -0
- package/dist/chunk-O7SH3E3T.js +18 -0
- package/dist/chunk-O7SH3E3T.js.map +1 -0
- package/dist/chunk-P5YNRND6.cjs +4 -0
- package/dist/chunk-P5YNRND6.cjs.map +1 -0
- package/dist/chunk-QAE6Q2SA.js +317 -0
- package/dist/chunk-QAE6Q2SA.js.map +1 -0
- package/dist/chunk-QRXVUXGJ.js +378 -0
- package/dist/chunk-QRXVUXGJ.js.map +1 -0
- package/dist/chunk-SLYUARZG.cjs +99 -0
- package/dist/chunk-SLYUARZG.cjs.map +1 -0
- package/dist/chunk-SWRIT7EE.js +3 -0
- package/dist/chunk-SWRIT7EE.js.map +1 -0
- package/dist/chunk-UXEUYHBD.cjs +401 -0
- package/dist/chunk-UXEUYHBD.cjs.map +1 -0
- package/dist/chunk-V6OKXUBQ.js +22 -0
- package/dist/chunk-V6OKXUBQ.js.map +1 -0
- package/dist/chunk-VAZJXZU5.cjs +31 -0
- package/dist/chunk-VAZJXZU5.cjs.map +1 -0
- package/dist/chunk-WGSFRFRO.cjs +252 -0
- package/dist/chunk-WGSFRFRO.cjs.map +1 -0
- package/dist/date/index.cjs +56 -0
- package/dist/date/index.cjs.map +1 -0
- package/dist/date/index.d.mts +63 -0
- package/dist/date/index.d.ts +63 -8
- package/dist/date/index.js +3 -0
- package/dist/date/index.js.map +1 -0
- package/dist/extract-youtube-video-id-HSYMYXIZ.js +3 -0
- package/dist/extract-youtube-video-id-HSYMYXIZ.js.map +1 -0
- package/dist/extract-youtube-video-id-XVGNPUDX.cjs +12 -0
- package/dist/extract-youtube-video-id-XVGNPUDX.cjs.map +1 -0
- package/dist/files/index.browser.cjs +21 -0
- package/dist/files/index.browser.cjs.map +1 -0
- package/dist/files/index.browser.d.mts +14 -0
- package/dist/files/index.browser.d.ts +14 -0
- package/dist/files/index.browser.js +4 -0
- package/dist/files/index.browser.js.map +1 -0
- package/dist/files/index.cjs +31 -0
- package/dist/files/index.cjs.map +1 -0
- package/dist/files/index.d.mts +3 -0
- package/dist/files/index.d.ts +3 -6
- package/dist/files/index.js +6 -0
- package/dist/files/index.js.map +1 -0
- package/dist/files/index.node.cjs +21 -0
- package/dist/files/index.node.cjs.map +1 -0
- package/dist/files/index.node.d.mts +7 -0
- package/dist/files/index.node.d.ts +7 -0
- package/dist/files/index.node.js +4 -0
- package/dist/files/index.node.js.map +1 -0
- package/dist/format-bytes-BGjeDnvM.d.mts +3 -0
- package/dist/format-bytes-BGjeDnvM.d.ts +3 -0
- package/dist/function/index.cjs +20 -0
- package/dist/function/index.cjs.map +1 -0
- package/dist/function/index.d.mts +22 -0
- package/dist/function/index.d.ts +22 -4
- package/dist/function/index.js +3 -0
- package/dist/function/index.js.map +1 -0
- package/dist/index.cjs +188 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/string/index.cjs +60 -0
- package/dist/string/index.cjs.map +1 -0
- package/dist/string/index.d.mts +28 -0
- package/dist/string/index.d.ts +28 -14
- package/dist/string/index.js +3 -0
- package/dist/string/index.js.map +1 -0
- package/dist/{cjs/function/try-catch.d.ts → try-catch-B7WzqcPU.d.mts} +4 -4
- package/dist/{function/try-catch.d.ts → try-catch-B7WzqcPU.d.ts} +4 -4
- package/dist/youtube/index.browser.cjs +35 -0
- package/dist/youtube/index.browser.cjs.map +1 -0
- package/dist/youtube/index.browser.d.mts +2 -0
- package/dist/youtube/index.browser.d.ts +2 -0
- package/dist/youtube/index.browser.js +6 -0
- package/dist/youtube/index.browser.js.map +1 -0
- package/dist/youtube/index.cjs +36 -0
- package/dist/youtube/index.cjs.map +1 -0
- package/dist/youtube/index.d.mts +12 -0
- package/dist/youtube/index.d.ts +12 -7
- package/dist/youtube/index.js +7 -0
- package/dist/youtube/index.js.map +1 -0
- package/dist/youtube/index.node.cjs +26 -0
- package/dist/youtube/index.node.cjs.map +1 -0
- package/dist/youtube/index.node.d.mts +49 -0
- package/dist/youtube/index.node.d.ts +49 -0
- package/dist/youtube/index.node.js +5 -0
- package/dist/youtube/index.node.js.map +1 -0
- package/package.json +134 -47
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/wrapper.d.ts +0 -27
- package/dist/api/wrapper.d.ts.map +0 -1
- package/dist/array/index.d.ts.map +0 -1
- package/dist/array/shuffle.d.ts +0 -2
- package/dist/array/shuffle.d.ts.map +0 -1
- package/dist/array/unique.d.ts +0 -2
- package/dist/array/unique.d.ts.map +0 -1
- package/dist/cjs/api/client.d.ts +0 -25
- package/dist/cjs/api/client.d.ts.map +0 -1
- package/dist/cjs/api/client.js +0 -148
- package/dist/cjs/api/client.js.map +0 -1
- package/dist/cjs/api/index.d.ts +0 -3
- package/dist/cjs/api/index.d.ts.map +0 -1
- package/dist/cjs/api/index.js +0 -6
- package/dist/cjs/api/index.js.map +0 -1
- package/dist/cjs/api/wrapper.d.ts +0 -27
- package/dist/cjs/api/wrapper.d.ts.map +0 -1
- package/dist/cjs/api/wrapper.js +0 -152
- package/dist/cjs/api/wrapper.js.map +0 -1
- package/dist/cjs/array/index.d.ts +0 -3
- package/dist/cjs/array/index.d.ts.map +0 -1
- package/dist/cjs/array/index.js +0 -19
- package/dist/cjs/array/index.js.map +0 -1
- package/dist/cjs/array/shuffle.d.ts +0 -2
- package/dist/cjs/array/shuffle.d.ts.map +0 -1
- package/dist/cjs/array/shuffle.js +0 -16
- package/dist/cjs/array/shuffle.js.map +0 -1
- package/dist/cjs/array/unique.d.ts +0 -2
- package/dist/cjs/array/unique.d.ts.map +0 -1
- package/dist/cjs/array/unique.js +0 -7
- package/dist/cjs/array/unique.js.map +0 -1
- package/dist/cjs/array.js +0 -1
- package/dist/cjs/date/dayjs.d.ts +0 -20
- package/dist/cjs/date/dayjs.d.ts.map +0 -1
- package/dist/cjs/date/dayjs.js +0 -123
- package/dist/cjs/date/dayjs.js.map +0 -1
- package/dist/cjs/date/fix-timezone-offset.d.ts +0 -3
- package/dist/cjs/date/fix-timezone-offset.d.ts.map +0 -1
- package/dist/cjs/date/fix-timezone-offset.js +0 -9
- package/dist/cjs/date/fix-timezone-offset.js.map +0 -1
- package/dist/cjs/date/format-date.d.ts +0 -23
- package/dist/cjs/date/format-date.d.ts.map +0 -1
- package/dist/cjs/date/format-date.js +0 -71
- package/dist/cjs/date/format-date.js.map +0 -1
- package/dist/cjs/date/get-current-date-in-utc.d.ts +0 -3
- package/dist/cjs/date/get-current-date-in-utc.d.ts.map +0 -1
- package/dist/cjs/date/get-current-date-in-utc.js +0 -8
- package/dist/cjs/date/get-current-date-in-utc.js.map +0 -1
- package/dist/cjs/date/get-date-in-utc.d.ts +0 -3
- package/dist/cjs/date/get-date-in-utc.d.ts.map +0 -1
- package/dist/cjs/date/get-date-in-utc.js +0 -8
- package/dist/cjs/date/get-date-in-utc.js.map +0 -1
- package/dist/cjs/date/get-relative-time.d.ts +0 -3
- package/dist/cjs/date/get-relative-time.d.ts.map +0 -1
- package/dist/cjs/date/get-relative-time.js +0 -8
- package/dist/cjs/date/get-relative-time.js.map +0 -1
- package/dist/cjs/date/index.d.ts +0 -8
- package/dist/cjs/date/index.d.ts.map +0 -1
- package/dist/cjs/date/index.js +0 -24
- package/dist/cjs/date/index.js.map +0 -1
- package/dist/cjs/date/parse-time-spent.d.ts +0 -15
- package/dist/cjs/date/parse-time-spent.d.ts.map +0 -1
- package/dist/cjs/date/parse-time-spent.js +0 -207
- package/dist/cjs/date/parse-time-spent.js.map +0 -1
- package/dist/cjs/date.js +0 -1
- package/dist/cjs/files/compress-image.d.ts +0 -10
- package/dist/cjs/files/compress-image.d.ts.map +0 -1
- package/dist/cjs/files/compress-image.js +0 -61
- package/dist/cjs/files/compress-image.js.map +0 -1
- package/dist/cjs/files/download-url.d.ts +0 -2
- package/dist/cjs/files/download-url.d.ts.map +0 -1
- package/dist/cjs/files/download-url.js +0 -29
- package/dist/cjs/files/download-url.js.map +0 -1
- package/dist/cjs/files/file-delete.d.ts +0 -2
- package/dist/cjs/files/file-delete.d.ts.map +0 -1
- package/dist/cjs/files/file-delete.js +0 -20
- package/dist/cjs/files/file-delete.js.map +0 -1
- package/dist/cjs/files/file-exists.d.ts +0 -2
- package/dist/cjs/files/file-exists.d.ts.map +0 -1
- package/dist/cjs/files/file-exists.js +0 -18
- package/dist/cjs/files/file-exists.js.map +0 -1
- package/dist/cjs/files/format-bytes.d.ts +0 -2
- package/dist/cjs/files/format-bytes.d.ts.map +0 -1
- package/dist/cjs/files/format-bytes.js +0 -17
- package/dist/cjs/files/format-bytes.js.map +0 -1
- package/dist/cjs/files/index.d.ts +0 -6
- package/dist/cjs/files/index.d.ts.map +0 -1
- package/dist/cjs/files/index.js +0 -22
- package/dist/cjs/files/index.js.map +0 -1
- package/dist/cjs/files.js +0 -1
- package/dist/cjs/function/debounce.d.ts +0 -11
- package/dist/cjs/function/debounce.d.ts.map +0 -1
- package/dist/cjs/function/debounce.js +0 -26
- package/dist/cjs/function/debounce.js.map +0 -1
- package/dist/cjs/function/index.d.ts +0 -4
- package/dist/cjs/function/index.d.ts.map +0 -1
- package/dist/cjs/function/index.js +0 -20
- package/dist/cjs/function/index.js.map +0 -1
- package/dist/cjs/function/throttle.d.ts +0 -10
- package/dist/cjs/function/throttle.d.ts.map +0 -1
- package/dist/cjs/function/throttle.js +0 -36
- package/dist/cjs/function/throttle.js.map +0 -1
- package/dist/cjs/function/try-catch.d.ts.map +0 -1
- package/dist/cjs/function/try-catch.js +0 -39
- package/dist/cjs/function/try-catch.js.map +0 -1
- package/dist/cjs/function.js +0 -1
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/string/camel-case.d.ts +0 -2
- package/dist/cjs/string/camel-case.d.ts.map +0 -1
- package/dist/cjs/string/camel-case.js +0 -25
- package/dist/cjs/string/camel-case.js.map +0 -1
- package/dist/cjs/string/capitalize.d.ts +0 -2
- package/dist/cjs/string/capitalize.d.ts.map +0 -1
- package/dist/cjs/string/capitalize.js +0 -13
- package/dist/cjs/string/capitalize.js.map +0 -1
- package/dist/cjs/string/format-hms-to-seconds.d.ts +0 -2
- package/dist/cjs/string/format-hms-to-seconds.d.ts.map +0 -1
- package/dist/cjs/string/format-hms-to-seconds.js +0 -30
- package/dist/cjs/string/format-hms-to-seconds.js.map +0 -1
- package/dist/cjs/string/format-seconds-to-fragment.d.ts +0 -3
- package/dist/cjs/string/format-seconds-to-fragment.d.ts.map +0 -1
- package/dist/cjs/string/format-seconds-to-fragment.js +0 -20
- package/dist/cjs/string/format-seconds-to-fragment.js.map +0 -1
- package/dist/cjs/string/format-seconds-to-hms.d.ts +0 -2
- package/dist/cjs/string/format-seconds-to-hms.d.ts.map +0 -1
- package/dist/cjs/string/format-seconds-to-hms.js +0 -17
- package/dist/cjs/string/format-seconds-to-hms.js.map +0 -1
- package/dist/cjs/string/format-string-to-time.d.ts +0 -2
- package/dist/cjs/string/format-string-to-time.d.ts.map +0 -1
- package/dist/cjs/string/format-string-to-time.js +0 -15
- package/dist/cjs/string/format-string-to-time.js.map +0 -1
- package/dist/cjs/string/index.d.ts +0 -14
- package/dist/cjs/string/index.d.ts.map +0 -1
- package/dist/cjs/string/index.js +0 -30
- package/dist/cjs/string/index.js.map +0 -1
- package/dist/cjs/string/kebab-case.d.ts +0 -2
- package/dist/cjs/string/kebab-case.d.ts.map +0 -1
- package/dist/cjs/string/kebab-case.js +0 -15
- package/dist/cjs/string/kebab-case.js.map +0 -1
- package/dist/cjs/string/markdown-to-text.d.ts +0 -2
- package/dist/cjs/string/markdown-to-text.d.ts.map +0 -1
- package/dist/cjs/string/markdown-to-text.js +0 -70
- package/dist/cjs/string/markdown-to-text.js.map +0 -1
- package/dist/cjs/string/remove-html-tags.d.ts +0 -2
- package/dist/cjs/string/remove-html-tags.d.ts.map +0 -1
- package/dist/cjs/string/remove-html-tags.js +0 -18
- package/dist/cjs/string/remove-html-tags.js.map +0 -1
- package/dist/cjs/string/slugify.d.ts +0 -2
- package/dist/cjs/string/slugify.d.ts.map +0 -1
- package/dist/cjs/string/slugify.js +0 -13
- package/dist/cjs/string/slugify.js.map +0 -1
- package/dist/cjs/string/snake-case.d.ts +0 -2
- package/dist/cjs/string/snake-case.d.ts.map +0 -1
- package/dist/cjs/string/snake-case.js +0 -15
- package/dist/cjs/string/snake-case.js.map +0 -1
- package/dist/cjs/string/to-sentence-case.d.ts +0 -2
- package/dist/cjs/string/to-sentence-case.d.ts.map +0 -1
- package/dist/cjs/string/to-sentence-case.js +0 -13
- package/dist/cjs/string/to-sentence-case.js.map +0 -1
- package/dist/cjs/string/truncate.d.ts +0 -2
- package/dist/cjs/string/truncate.d.ts.map +0 -1
- package/dist/cjs/string/truncate.js +0 -19
- package/dist/cjs/string/truncate.js.map +0 -1
- package/dist/cjs/string.js +0 -1
- package/dist/cjs/youtube/extract-youtube-video-id.d.ts +0 -2
- package/dist/cjs/youtube/extract-youtube-video-id.d.ts.map +0 -1
- package/dist/cjs/youtube/extract-youtube-video-id.js +0 -30
- package/dist/cjs/youtube/extract-youtube-video-id.js.map +0 -1
- package/dist/cjs/youtube/generate-youtube-url.d.ts +0 -20
- package/dist/cjs/youtube/generate-youtube-url.d.ts.map +0 -1
- package/dist/cjs/youtube/generate-youtube-url.js +0 -86
- package/dist/cjs/youtube/generate-youtube-url.js.map +0 -1
- package/dist/cjs/youtube/get-youtube-thumbnail.d.ts +0 -2
- package/dist/cjs/youtube/get-youtube-thumbnail.d.ts.map +0 -1
- package/dist/cjs/youtube/get-youtube-thumbnail.js +0 -68
- package/dist/cjs/youtube/get-youtube-thumbnail.js.map +0 -1
- package/dist/cjs/youtube/get-youtube-video-info.d.ts +0 -26
- package/dist/cjs/youtube/get-youtube-video-info.d.ts.map +0 -1
- package/dist/cjs/youtube/get-youtube-video-info.js +0 -244
- package/dist/cjs/youtube/get-youtube-video-info.js.map +0 -1
- package/dist/cjs/youtube/index.d.ts +0 -7
- package/dist/cjs/youtube/index.d.ts.map +0 -1
- package/dist/cjs/youtube/index.js +0 -23
- package/dist/cjs/youtube/index.js.map +0 -1
- package/dist/cjs/youtube/use-get-video-duration.d.ts +0 -7
- package/dist/cjs/youtube/use-get-video-duration.d.ts.map +0 -1
- package/dist/cjs/youtube/use-get-video-duration.js +0 -153
- package/dist/cjs/youtube/use-get-video-duration.js.map +0 -1
- package/dist/cjs/youtube/validate-youtube-link.d.ts +0 -2
- package/dist/cjs/youtube/validate-youtube-link.d.ts.map +0 -1
- package/dist/cjs/youtube/validate-youtube-link.js +0 -77
- package/dist/cjs/youtube/validate-youtube-link.js.map +0 -1
- package/dist/cjs/youtube.js +0 -1
- package/dist/date/dayjs.d.ts +0 -20
- package/dist/date/dayjs.d.ts.map +0 -1
- package/dist/date/fix-timezone-offset.d.ts +0 -3
- package/dist/date/fix-timezone-offset.d.ts.map +0 -1
- package/dist/date/format-date.d.ts +0 -23
- package/dist/date/format-date.d.ts.map +0 -1
- package/dist/date/get-current-date-in-utc.d.ts +0 -3
- package/dist/date/get-current-date-in-utc.d.ts.map +0 -1
- package/dist/date/get-date-in-utc.d.ts +0 -3
- package/dist/date/get-date-in-utc.d.ts.map +0 -1
- package/dist/date/get-relative-time.d.ts +0 -3
- package/dist/date/get-relative-time.d.ts.map +0 -1
- package/dist/date/index.d.ts.map +0 -1
- package/dist/date/parse-time-spent.d.ts +0 -15
- package/dist/date/parse-time-spent.d.ts.map +0 -1
- package/dist/esm/api/client.js +0 -143
- package/dist/esm/api/index.js +0 -1
- package/dist/esm/api/wrapper.js +0 -148
- package/dist/esm/array/index.js +0 -2
- package/dist/esm/array/shuffle.js +0 -12
- package/dist/esm/array/unique.js +0 -3
- package/dist/esm/array.js +0 -1
- package/dist/esm/date/dayjs.js +0 -111
- package/dist/esm/date/fix-timezone-offset.js +0 -5
- package/dist/esm/date/format-date.js +0 -67
- package/dist/esm/date/get-current-date-in-utc.js +0 -4
- package/dist/esm/date/get-date-in-utc.js +0 -4
- package/dist/esm/date/get-relative-time.js +0 -4
- package/dist/esm/date/index.js +0 -7
- package/dist/esm/date/parse-time-spent.js +0 -203
- package/dist/esm/date.js +0 -1
- package/dist/esm/files/compress-image.js +0 -57
- package/dist/esm/files/download-url.js +0 -24
- package/dist/esm/files/file-delete.js +0 -12
- package/dist/esm/files/file-exists.js +0 -10
- package/dist/esm/files/format-bytes.js +0 -13
- package/dist/esm/files/index.js +0 -5
- package/dist/esm/files.js +0 -1
- package/dist/esm/function/debounce.js +0 -22
- package/dist/esm/function/index.js +0 -3
- package/dist/esm/function/throttle.js +0 -32
- package/dist/esm/function/try-catch.js +0 -35
- package/dist/esm/function.js +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/string/camel-case.js +0 -21
- package/dist/esm/string/capitalize.js +0 -9
- package/dist/esm/string/format-hms-to-seconds.js +0 -25
- package/dist/esm/string/format-seconds-to-fragment.js +0 -15
- package/dist/esm/string/format-seconds-to-hms.js +0 -13
- package/dist/esm/string/format-string-to-time.js +0 -10
- package/dist/esm/string/index.js +0 -13
- package/dist/esm/string/kebab-case.js +0 -11
- package/dist/esm/string/markdown-to-text.js +0 -66
- package/dist/esm/string/remove-html-tags.js +0 -14
- package/dist/esm/string/slugify.js +0 -9
- package/dist/esm/string/snake-case.js +0 -11
- package/dist/esm/string/to-sentence-case.js +0 -9
- package/dist/esm/string/truncate.js +0 -15
- package/dist/esm/string.js +0 -1
- package/dist/esm/youtube/extract-youtube-video-id.js +0 -26
- package/dist/esm/youtube/generate-youtube-url.js +0 -81
- package/dist/esm/youtube/get-youtube-thumbnail.js +0 -31
- package/dist/esm/youtube/get-youtube-video-info.js +0 -207
- package/dist/esm/youtube/index.js +0 -6
- package/dist/esm/youtube/use-get-video-duration.js +0 -149
- package/dist/esm/youtube/validate-youtube-link.js +0 -40
- package/dist/esm/youtube.js +0 -1
- package/dist/files/compress-image.d.ts +0 -10
- package/dist/files/compress-image.d.ts.map +0 -1
- package/dist/files/download-url.d.ts +0 -2
- package/dist/files/download-url.d.ts.map +0 -1
- package/dist/files/file-delete.d.ts +0 -2
- package/dist/files/file-delete.d.ts.map +0 -1
- package/dist/files/file-exists.d.ts +0 -2
- package/dist/files/file-exists.d.ts.map +0 -1
- package/dist/files/format-bytes.d.ts +0 -2
- package/dist/files/format-bytes.d.ts.map +0 -1
- package/dist/files/index.d.ts.map +0 -1
- package/dist/function/debounce.d.ts +0 -11
- package/dist/function/debounce.d.ts.map +0 -1
- package/dist/function/index.d.ts.map +0 -1
- package/dist/function/throttle.d.ts +0 -10
- package/dist/function/throttle.d.ts.map +0 -1
- package/dist/function/try-catch.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/string/camel-case.d.ts +0 -2
- package/dist/string/camel-case.d.ts.map +0 -1
- package/dist/string/capitalize.d.ts +0 -2
- package/dist/string/capitalize.d.ts.map +0 -1
- package/dist/string/format-hms-to-seconds.d.ts +0 -2
- package/dist/string/format-hms-to-seconds.d.ts.map +0 -1
- package/dist/string/format-seconds-to-fragment.d.ts +0 -3
- package/dist/string/format-seconds-to-fragment.d.ts.map +0 -1
- package/dist/string/format-seconds-to-hms.d.ts +0 -2
- package/dist/string/format-seconds-to-hms.d.ts.map +0 -1
- package/dist/string/format-string-to-time.d.ts +0 -2
- package/dist/string/format-string-to-time.d.ts.map +0 -1
- package/dist/string/index.d.ts.map +0 -1
- package/dist/string/kebab-case.d.ts +0 -2
- package/dist/string/kebab-case.d.ts.map +0 -1
- package/dist/string/markdown-to-text.d.ts +0 -2
- package/dist/string/markdown-to-text.d.ts.map +0 -1
- package/dist/string/remove-html-tags.d.ts +0 -2
- package/dist/string/remove-html-tags.d.ts.map +0 -1
- package/dist/string/slugify.d.ts +0 -2
- package/dist/string/slugify.d.ts.map +0 -1
- package/dist/string/snake-case.d.ts +0 -2
- package/dist/string/snake-case.d.ts.map +0 -1
- package/dist/string/to-sentence-case.d.ts +0 -2
- package/dist/string/to-sentence-case.d.ts.map +0 -1
- package/dist/string/truncate.d.ts +0 -2
- package/dist/string/truncate.d.ts.map +0 -1
- package/dist/youtube/extract-youtube-video-id.d.ts +0 -2
- package/dist/youtube/extract-youtube-video-id.d.ts.map +0 -1
- package/dist/youtube/generate-youtube-url.d.ts +0 -20
- package/dist/youtube/generate-youtube-url.d.ts.map +0 -1
- package/dist/youtube/get-youtube-thumbnail.d.ts +0 -2
- package/dist/youtube/get-youtube-thumbnail.d.ts.map +0 -1
- package/dist/youtube/get-youtube-video-info.d.ts +0 -26
- package/dist/youtube/get-youtube-video-info.d.ts.map +0 -1
- package/dist/youtube/index.d.ts.map +0 -1
- package/dist/youtube/use-get-video-duration.d.ts +0 -7
- package/dist/youtube/use-get-video-duration.d.ts.map +0 -1
- package/dist/youtube/validate-youtube-link.d.ts +0 -2
- package/dist/youtube/validate-youtube-link.d.ts.map +0 -1
|
@@ -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
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import { fileExists } from "./file-exists.js";
|
|
3
|
-
export const fileDelete = async (filePath) => {
|
|
4
|
-
try {
|
|
5
|
-
if (await fileExists(filePath))
|
|
6
|
-
await fs.rm(filePath);
|
|
7
|
-
}
|
|
8
|
-
catch (err) {
|
|
9
|
-
// Log but don't throw during cleanup
|
|
10
|
-
console.error(`Error deleting file at ${filePath}:`, err);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function formatBytes(bytes) {
|
|
2
|
-
if (bytes < 0) {
|
|
3
|
-
throw new Error("Size in bytes cannot be negative");
|
|
4
|
-
}
|
|
5
|
-
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
6
|
-
let size = bytes;
|
|
7
|
-
let index = 0;
|
|
8
|
-
while (size >= 1024 && index < units.length - 1) {
|
|
9
|
-
size /= 1024;
|
|
10
|
-
index++;
|
|
11
|
-
}
|
|
12
|
-
return `${size.toFixed(2)} ${units[index]}`;
|
|
13
|
-
}
|
package/dist/esm/files/index.js
DELETED
package/dist/esm/files.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './files/index.js'
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a debounced function that delays invoking func until after delay milliseconds
|
|
3
|
-
* have elapsed since the last time the debounced function was invoked
|
|
4
|
-
* @param fn - The function to debounce
|
|
5
|
-
* @param delay - The number of milliseconds to delay
|
|
6
|
-
* @returns The debounced function
|
|
7
|
-
*/
|
|
8
|
-
export function debounce(fn, delay) {
|
|
9
|
-
if (typeof fn !== "function") {
|
|
10
|
-
throw new Error("First argument must be a function");
|
|
11
|
-
}
|
|
12
|
-
if (typeof delay !== "number" || delay < 0) {
|
|
13
|
-
throw new Error("Delay must be a non-negative number");
|
|
14
|
-
}
|
|
15
|
-
let timeoutId;
|
|
16
|
-
return function (...args) {
|
|
17
|
-
if (timeoutId) {
|
|
18
|
-
clearTimeout(timeoutId);
|
|
19
|
-
}
|
|
20
|
-
timeoutId = setTimeout(() => fn.apply(this, args), delay);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a throttled function that only invokes func at most once per every delay milliseconds
|
|
3
|
-
* @param fn - The function to throttle
|
|
4
|
-
* @param delay - The number of milliseconds to throttle invocations to
|
|
5
|
-
* @returns The throttled function
|
|
6
|
-
*/
|
|
7
|
-
export function throttle(fn, delay) {
|
|
8
|
-
if (typeof fn !== "function") {
|
|
9
|
-
throw new Error("First argument must be a function");
|
|
10
|
-
}
|
|
11
|
-
if (typeof delay !== "number" || delay < 0) {
|
|
12
|
-
throw new Error("Delay must be a non-negative number");
|
|
13
|
-
}
|
|
14
|
-
let lastCall = 0;
|
|
15
|
-
let timeoutId;
|
|
16
|
-
return function (...args) {
|
|
17
|
-
const now = Date.now();
|
|
18
|
-
if (now - lastCall >= delay) {
|
|
19
|
-
lastCall = now;
|
|
20
|
-
fn.apply(this, args);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
if (timeoutId) {
|
|
24
|
-
clearTimeout(timeoutId);
|
|
25
|
-
}
|
|
26
|
-
timeoutId = setTimeout(() => {
|
|
27
|
-
lastCall = Date.now();
|
|
28
|
-
fn.apply(this, args);
|
|
29
|
-
}, delay - (now - lastCall));
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enhanced try-catch utility that handles async operations and provides typed results
|
|
3
|
-
*
|
|
4
|
-
* @param fn - The promise or function returning a promise to execute
|
|
5
|
-
* @param defaultData - Optional default value to use for data when an error occurs (instead of null)
|
|
6
|
-
* @returns A consistent result object containing either data or error
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // With a promise
|
|
10
|
-
* const result = await tryCatch(fetchUserData(userId));
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // With a function that returns a promise
|
|
14
|
-
* const result = await tryCatch(() => fetchUserData(userId));
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* // With custom default data
|
|
18
|
-
* const result = await tryCatch(fetchItems(), []);
|
|
19
|
-
* // result.data will be an empty array instead of null when error occurs
|
|
20
|
-
*/
|
|
21
|
-
export async function tryCatch(fn, defaultData) {
|
|
22
|
-
try {
|
|
23
|
-
const data = await (typeof fn === "function" ? fn() : fn);
|
|
24
|
-
return {
|
|
25
|
-
data,
|
|
26
|
-
error: null,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
return {
|
|
31
|
-
data: (defaultData !== null && defaultData !== void 0 ? defaultData : null),
|
|
32
|
-
error: error,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
package/dist/esm/function.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './function/index.js'
|
package/dist/esm/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "./api/index.js"; // API utilities
|
|
2
|
-
export * from "./array/index.js"; // Array utilities
|
|
3
|
-
export * from "./date/index.js"; // Date utilities
|
|
4
|
-
export * from "./files/index.js"; // Files utilities
|
|
5
|
-
export * from "./function/index.js"; // Function utilities
|
|
6
|
-
export * from "./string/index.js"; // String utilities
|
|
7
|
-
export * from "./youtube/index.js"; // YouTube utilities
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function camelCase(str) {
|
|
2
|
-
if (typeof str !== "string") {
|
|
3
|
-
throw new Error("Input must be a string");
|
|
4
|
-
}
|
|
5
|
-
if (str.length === 0) {
|
|
6
|
-
return str;
|
|
7
|
-
}
|
|
8
|
-
const words = str
|
|
9
|
-
.toLowerCase()
|
|
10
|
-
.replace(/[^a-zA-Z0-9\s\-_]/g, "")
|
|
11
|
-
.split(/[\s\-_]+/)
|
|
12
|
-
.filter((word) => word.length > 0);
|
|
13
|
-
if (words.length === 0) {
|
|
14
|
-
return "";
|
|
15
|
-
}
|
|
16
|
-
return (words[0] +
|
|
17
|
-
words
|
|
18
|
-
.slice(1)
|
|
19
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
20
|
-
.join(""));
|
|
21
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const formatHMSToSeconds = (val) => {
|
|
2
|
-
if (val == null || val === "")
|
|
3
|
-
return null;
|
|
4
|
-
if (typeof val === "number")
|
|
5
|
-
return Number.isFinite(val) ? Math.max(0, Math.floor(val)) : null;
|
|
6
|
-
const s = String(val).trim();
|
|
7
|
-
// purely numeric string
|
|
8
|
-
if (/^\d+$/.test(s))
|
|
9
|
-
return Math.max(0, Number.parseInt(s, 10));
|
|
10
|
-
// hh:mm:ss or mm:ss
|
|
11
|
-
if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(s)) {
|
|
12
|
-
const parts = s.split(":").map((p) => Number.parseInt(p, 10));
|
|
13
|
-
if (parts.some((n) => Number.isNaN(n)))
|
|
14
|
-
return null;
|
|
15
|
-
let seconds = 0;
|
|
16
|
-
if (parts.length === 3) {
|
|
17
|
-
seconds = parts[0] * 3600 + parts[1] * 60 + parts[2];
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
seconds = parts[0] * 60 + parts[1];
|
|
21
|
-
}
|
|
22
|
-
return Math.max(0, seconds);
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** convert seconds to "1h2m3s" or "42s" style for fragment */
|
|
2
|
-
export const formatSecondsToFragment = (secs) => {
|
|
3
|
-
const parsedSecs = Math.max(0, Math.floor(secs));
|
|
4
|
-
const h = Math.floor(parsedSecs / 3600);
|
|
5
|
-
const m = Math.floor((parsedSecs % 3600) / 60);
|
|
6
|
-
const s = parsedSecs % 60;
|
|
7
|
-
let out = "";
|
|
8
|
-
if (h > 0)
|
|
9
|
-
out += `${h}h`;
|
|
10
|
-
if (m > 0)
|
|
11
|
-
out += `${m}m`;
|
|
12
|
-
if (s > 0 || out === "")
|
|
13
|
-
out += `${s}s`;
|
|
14
|
-
return out;
|
|
15
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function formatSecondsToHMS(totalSeconds) {
|
|
2
|
-
const rounded = Math.max(0, Math.round(totalSeconds));
|
|
3
|
-
const hours = Math.floor(rounded / 3600);
|
|
4
|
-
const minutes = Math.floor((rounded % 3600) / 60);
|
|
5
|
-
const seconds = rounded % 60;
|
|
6
|
-
const hh = String(hours).padStart(2, "0");
|
|
7
|
-
const mm = String(minutes).padStart(2, "0");
|
|
8
|
-
const ss = String(seconds).padStart(2, "0");
|
|
9
|
-
if (hours === 0) {
|
|
10
|
-
return `${mm}:${ss}`;
|
|
11
|
-
}
|
|
12
|
-
return `${hh}:${mm}:${ss}`;
|
|
13
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const formatStringToTime = (str) => {
|
|
2
|
-
const stringCleaned = Number(str.replace(/\D/g, "")).toString();
|
|
3
|
-
if (stringCleaned.length > 4) {
|
|
4
|
-
return stringCleaned
|
|
5
|
-
.padStart(6, "0")
|
|
6
|
-
.slice(0, 6)
|
|
7
|
-
.replace(/(\d{2})(\d{2})(\d{2})/, "$1:$2:$3");
|
|
8
|
-
}
|
|
9
|
-
return stringCleaned.padStart(4, "0").replace(/(\d{2})(\d{2})/, "$1:$2");
|
|
10
|
-
};
|
package/dist/esm/string/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./camel-case.js";
|
|
2
|
-
export * from "./capitalize.js";
|
|
3
|
-
export * from "./format-hms-to-seconds.js";
|
|
4
|
-
export * from "./format-seconds-to-fragment.js";
|
|
5
|
-
export * from "./format-seconds-to-hms.js";
|
|
6
|
-
export * from "./format-string-to-time.js";
|
|
7
|
-
export * from "./kebab-case.js";
|
|
8
|
-
export * from "./markdown-to-text.js";
|
|
9
|
-
export * from "./remove-html-tags.js";
|
|
10
|
-
export * from "./slugify.js";
|
|
11
|
-
export * from "./snake-case.js";
|
|
12
|
-
export * from "./to-sentence-case.js";
|
|
13
|
-
export * from "./truncate.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function kebabCase(str) {
|
|
2
|
-
if (typeof str !== "string") {
|
|
3
|
-
throw new Error("Input must be a string");
|
|
4
|
-
}
|
|
5
|
-
return str
|
|
6
|
-
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
7
|
-
.replace(/[\s_]+/g, "-")
|
|
8
|
-
.replace(/[^a-zA-Z0-9-]/g, "")
|
|
9
|
-
.toLowerCase()
|
|
10
|
-
.replace(/^-+|-+$/g, "");
|
|
11
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export function markdownToText(markdown) {
|
|
2
|
-
if (!markdown)
|
|
3
|
-
return "";
|
|
4
|
-
// normalize newlines
|
|
5
|
-
let text = markdown.replace(/\r\n?/g, "\n");
|
|
6
|
-
// Remove code fences but keep inner content (trim surrounding newlines to avoid extra blank lines)
|
|
7
|
-
text = text.replace(/```[\s\S]*?```/g, (m) => {
|
|
8
|
-
const inner = m.replace(/^```.*\n?/, "").replace(/```$/, "");
|
|
9
|
-
return inner.replace(/^\n+|\n+$/g, "");
|
|
10
|
-
});
|
|
11
|
-
// Remove inline code backticks
|
|
12
|
-
text = text.replace(/`([^`]+)`/g, "$1");
|
|
13
|
-
// Images: keep alt text if present
|
|
14
|
-
text = text.replace(/!\[([^\]]*)\]\((?:[^)]+)\)/g, "$1");
|
|
15
|
-
// Links: keep link text
|
|
16
|
-
text = text.replace(/\[([^\]]+)\]\((?:[^)]+)\)/g, "$1");
|
|
17
|
-
// Reference-style links: [text][id] -> text
|
|
18
|
-
text = text.replace(/\[([^\]]+)\]\s*\[[^\]]*\]/g, "$1");
|
|
19
|
-
// Remove footnote markers like [^1] (do this before we mutate surrounding lines)
|
|
20
|
-
text = text.replace(/\[\^[^\]]+\]/g, "");
|
|
21
|
-
// Remove reference definitions like: [id]: url (and footnote defs like [^1]: note)
|
|
22
|
-
// Remove the entire definition line including its trailing newline to avoid leaving blank lines
|
|
23
|
-
text = text.replace(/^\s*\[[^\]]+\]:\s*.*(?:\r\n?|\n)?/gm, "");
|
|
24
|
-
text = text.replace(/^\s*\[\^[^\]]+\]:\s*.*(?:\r\n?|\n)?/gm, "");
|
|
25
|
-
// Remove HTML tags but keep inner text
|
|
26
|
-
text = text.replace(/<\/?[^>]+>/g, "");
|
|
27
|
-
// Remove emphasis markers (bold/italic/strikethrough), preserve text
|
|
28
|
-
text = text.replace(/(\*\*|__)(.*?)\1/g, "$2");
|
|
29
|
-
text = text.replace(/(\*|_)(.*?)\1/g, "$2");
|
|
30
|
-
text = text.replace(/~~(.*?)~~/g, "$1");
|
|
31
|
-
// Remove headings (#, ##, etc.)
|
|
32
|
-
text = text.replace(/^\s{0,3}#{1,6}\s*/gm, "");
|
|
33
|
-
// Remove blockquote markers
|
|
34
|
-
text = text.replace(/^\s{0,3}>\s?/gm, "");
|
|
35
|
-
// Remove list markers (ordered and unordered)
|
|
36
|
-
text = text.replace(/^\s{0,3}([-+*]|\d+\.)\s+/gm, "");
|
|
37
|
-
// Remove table separator lines and keep table cell content by replacing pipes with spaced pipes
|
|
38
|
-
// Match the separator line and any trailing newline so we don't leave an empty line behind
|
|
39
|
-
// Remove separator lines entirely (don't insert an extra newline)
|
|
40
|
-
text = text.replace(/^\s*\|?(?:\s*:?-+:?\s*\|)+\s*(?:\r\n?|\n)?/gm, "");
|
|
41
|
-
text = text.replace(/\|/g, " | ");
|
|
42
|
-
// Trim leading whitespace on each line (fixes leading space introduced by replacing pipes)
|
|
43
|
-
text = text.replace(/^[ \t]+/gm, "");
|
|
44
|
-
// Fix table spacing edge-case: when a cell starts with two spaces before a digit (caused by adding spaces around pipes), collapse to a single space
|
|
45
|
-
text = text.replace(/\|\s{2}(?=\d)/g, "| ");
|
|
46
|
-
// Remove footnote markers like [^1]
|
|
47
|
-
text = text.replace(/\[\^[^\]]+\]/g, "");
|
|
48
|
-
// Remove any leftover footnote-definition fragments that may have been concatenated to the previous line
|
|
49
|
-
// e.g. "Text^1: note" -> "Text"
|
|
50
|
-
text = text.replace(/\^[0-9]+:\s*.*(?:\r\n?|\n)?/g, "");
|
|
51
|
-
// Decode a few common HTML entities
|
|
52
|
-
const entities = {
|
|
53
|
-
"&": "&",
|
|
54
|
-
"<": "<",
|
|
55
|
-
">": ">",
|
|
56
|
-
""": '"',
|
|
57
|
-
"'": "'",
|
|
58
|
-
};
|
|
59
|
-
text = text.replace(/&[a-zA-Z0-9#]+;/g, (e) => { var _a; return (_a = entities[e]) !== null && _a !== void 0 ? _a : e; });
|
|
60
|
-
// Trim trailing whitespace on each line
|
|
61
|
-
text = text.replace(/[ \t]+$/gm, "");
|
|
62
|
-
// Collapse excessive blank lines to at most two (preserve paragraph breaks)
|
|
63
|
-
text = text.replace(/\n{3,}/g, "\n\n");
|
|
64
|
-
// Final trim but preserve leading/trailing single newlines inside content as needed
|
|
65
|
-
return text.trim();
|
|
66
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function removeHtmlTags(input) {
|
|
2
|
-
// Input validation
|
|
3
|
-
if (!input || typeof input !== "string") {
|
|
4
|
-
return "";
|
|
5
|
-
}
|
|
6
|
-
// Apply reasonable input length limit for safety
|
|
7
|
-
const maxLength = 100000; // Adjust based on your requirements
|
|
8
|
-
let updatedInput = input;
|
|
9
|
-
if (updatedInput.length > maxLength) {
|
|
10
|
-
updatedInput = updatedInput.slice(0, maxLength);
|
|
11
|
-
}
|
|
12
|
-
// Use a non-backtracking approach to prevent ReDoS vulnerabilities
|
|
13
|
-
return updatedInput.replace(/<(?:[^>"']|"[^"]*"|'[^']*')*>/g, "");
|
|
14
|
-
}
|