@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.
- 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/nextjs/index.browser.cjs +110 -0
- package/dist/nextjs/index.browser.cjs.map +1 -0
- package/dist/nextjs/index.browser.d.mts +10 -0
- package/dist/nextjs/index.browser.d.ts +10 -0
- package/dist/nextjs/index.browser.js +103 -0
- package/dist/nextjs/index.browser.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 +164 -49
- 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-video-duration.d.ts +0 -7
- package/dist/cjs/youtube/get-video-duration.d.ts.map +0 -1
- package/dist/cjs/youtube/get-video-duration.js +0 -150
- package/dist/cjs/youtube/get-video-duration.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/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-video-duration.js +0 -146
- 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/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-video-duration.d.ts +0 -7
- package/dist/youtube/get-video-duration.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/validate-youtube-link.d.ts +0 -2
- package/dist/youtube/validate-youtube-link.d.ts.map +0 -1
package/dist/esm/api/wrapper.js
DELETED
|
@@ -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
|
-
}
|
package/dist/esm/array/index.js
DELETED
|
@@ -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
|
-
}
|
package/dist/esm/array/unique.js
DELETED
package/dist/esm/array.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './array/index.js'
|
package/dist/esm/date/dayjs.js
DELETED
|
@@ -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,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
|
-
}
|
package/dist/esm/date/index.js
DELETED
|
@@ -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
|
-
};
|