@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-relative-time.d.ts","sourceRoot":"","sources":["../../src/date/get-relative-time.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGvC,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,wBAAU,GAAG,MAAM,CAE3E"}
|
package/dist/date/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface ITimeSpent {
|
|
2
|
-
years: number;
|
|
3
|
-
months: number;
|
|
4
|
-
days: number;
|
|
5
|
-
hours: number;
|
|
6
|
-
minutes: number;
|
|
7
|
-
seconds: number;
|
|
8
|
-
formatted: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function parseTimeSpent(initialDate: string | Date, finalDate: string | Date, locale?: string, // Default to Portuguese for backward compatibility
|
|
11
|
-
options?: {
|
|
12
|
-
format?: "verbose" | "compact";
|
|
13
|
-
minimal?: boolean;
|
|
14
|
-
}): ITimeSpent;
|
|
15
|
-
//# sourceMappingURL=parse-time-spent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-time-spent.d.ts","sourceRoot":"","sources":["../../src/date/parse-time-spent.ts"],"names":[],"mappings":"AA2HA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAGD,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,MAAM,SAAU,EAAE,mDAAmD;AACrE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,UAAU,CAkHZ"}
|
package/dist/esm/api/client.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { apiWrapper } from "./wrapper.js";
|
|
2
|
-
const defaultRetryConfig = {
|
|
3
|
-
limit: 5,
|
|
4
|
-
methods: ["get"],
|
|
5
|
-
statusCodes: [413],
|
|
6
|
-
backoffLimit: 3000,
|
|
7
|
-
};
|
|
8
|
-
function buildQueryString(params) {
|
|
9
|
-
const searchParams = new URLSearchParams();
|
|
10
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
11
|
-
if (value !== null && value !== undefined) {
|
|
12
|
-
searchParams.append(key, String(value));
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
const queryString = searchParams.toString();
|
|
16
|
-
return queryString ? `?${queryString}` : "";
|
|
17
|
-
}
|
|
18
|
-
async function beforeRequestHook(request, getAccessToken, getUserIP) {
|
|
19
|
-
const token = await (getAccessToken === null || getAccessToken === void 0 ? void 0 : getAccessToken());
|
|
20
|
-
const headers = new Headers(request.headers);
|
|
21
|
-
if (token) {
|
|
22
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
23
|
-
}
|
|
24
|
-
const userIP = await (getUserIP === null || getUserIP === void 0 ? void 0 : getUserIP());
|
|
25
|
-
if (userIP) {
|
|
26
|
-
headers.set("X-User-IP", userIP);
|
|
27
|
-
}
|
|
28
|
-
let body;
|
|
29
|
-
try {
|
|
30
|
-
const cloned = request.clone();
|
|
31
|
-
const text = await cloned.text();
|
|
32
|
-
body = text === "" ? undefined : text;
|
|
33
|
-
}
|
|
34
|
-
catch (_a) {
|
|
35
|
-
body = undefined;
|
|
36
|
-
}
|
|
37
|
-
return new Request(request, { headers, body });
|
|
38
|
-
}
|
|
39
|
-
async function afterResponseHook(request, response, onSignoutUnauthorized) {
|
|
40
|
-
const possibleSignInPaths = ["signin", "sign-in", "login"];
|
|
41
|
-
const isSignInPath = possibleSignInPaths.some((path) => request.url.includes(path));
|
|
42
|
-
const needsBody = response.status === 401 && !isSignInPath;
|
|
43
|
-
let responseBody = null;
|
|
44
|
-
let responseBodyFor401 = null;
|
|
45
|
-
if (needsBody) {
|
|
46
|
-
const clone = response.clone();
|
|
47
|
-
try {
|
|
48
|
-
responseBody = await clone.json();
|
|
49
|
-
responseBodyFor401 = responseBody;
|
|
50
|
-
}
|
|
51
|
-
catch (_b) {
|
|
52
|
-
responseBody = await clone.text();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (response.status === 401 && !isSignInPath) {
|
|
56
|
-
return onSignoutUnauthorized === null || onSignoutUnauthorized === void 0 ? void 0 : onSignoutUnauthorized(responseBodyFor401);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function fetchWithRetry(input, init) {
|
|
60
|
-
var _b, _c, _d, _e;
|
|
61
|
-
const retryConfig = (init === null || init === void 0 ? void 0 : init.retry) || defaultRetryConfig;
|
|
62
|
-
const method = ((init === null || init === void 0 ? void 0 : init.method) || "GET").toLowerCase();
|
|
63
|
-
let attempt = 0;
|
|
64
|
-
while (true) {
|
|
65
|
-
attempt++;
|
|
66
|
-
const response = await fetch(input, init);
|
|
67
|
-
const shouldRetry = ((_b = retryConfig.statusCodes) === null || _b === void 0 ? void 0 : _b.includes(response.status)) &&
|
|
68
|
-
((_c = retryConfig.methods) === null || _c === void 0 ? void 0 : _c.includes(method)) &&
|
|
69
|
-
attempt < ((_d = retryConfig.limit) !== null && _d !== void 0 ? _d : 5);
|
|
70
|
-
if (!shouldRetry)
|
|
71
|
-
return response;
|
|
72
|
-
const backoff = Math.min(2 ** attempt * 100, (_e = retryConfig.backoffLimit) !== null && _e !== void 0 ? _e : 3000);
|
|
73
|
-
await new Promise((resolve) => setTimeout(resolve, backoff));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async function api(config, endpoint, options = {}) {
|
|
77
|
-
var _b, _c;
|
|
78
|
-
let url = endpoint.startsWith("http")
|
|
79
|
-
? endpoint
|
|
80
|
-
: `${(_b = config.baseURL) === null || _b === void 0 ? void 0 : _b.replace(/\/$/, "")}/${endpoint.replace(/^\//, "")}`;
|
|
81
|
-
// Add query parameters if provided
|
|
82
|
-
if (options.params) {
|
|
83
|
-
const queryString = buildQueryString(options.params);
|
|
84
|
-
url += queryString;
|
|
85
|
-
}
|
|
86
|
-
// Apply default options
|
|
87
|
-
const init = {
|
|
88
|
-
credentials: "include",
|
|
89
|
-
...options,
|
|
90
|
-
};
|
|
91
|
-
let body;
|
|
92
|
-
if (options.json !== undefined && options.json !== null) {
|
|
93
|
-
body = JSON.stringify(options.json);
|
|
94
|
-
// Only add Content-Type if body is not empty
|
|
95
|
-
if (body && body !== "null" && body !== "undefined") {
|
|
96
|
-
init.headers = {
|
|
97
|
-
...init.headers,
|
|
98
|
-
"Content-Type": "application/json",
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// Remove Content-Type application/json if there's no body
|
|
103
|
-
if (!body) {
|
|
104
|
-
const headers = new Headers(init.headers);
|
|
105
|
-
if (((_c = headers.get("Content-Type")) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === "application/json") {
|
|
106
|
-
headers.delete("Content-Type");
|
|
107
|
-
init.headers = headers;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// Create initial request
|
|
111
|
-
let request = new Request(url, { ...init, body });
|
|
112
|
-
// Run pre-request hooks
|
|
113
|
-
request = await beforeRequestHook(request, config.getAccessToken, config.getUserIP);
|
|
114
|
-
// Keep init headers in sync with the mutated request so fetch keeps auth headers
|
|
115
|
-
init.headers = new Headers(request.headers);
|
|
116
|
-
// Execute request with retry logic
|
|
117
|
-
const response = await fetchWithRetry(request, init);
|
|
118
|
-
// Run post-response hooks
|
|
119
|
-
await afterResponseHook(request, response, config.onSignoutUnauthorized);
|
|
120
|
-
if (!response.ok) {
|
|
121
|
-
throw response;
|
|
122
|
-
}
|
|
123
|
-
if (response.status === 204) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
const text = await response.text();
|
|
127
|
-
if (!text) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
return JSON.parse(text);
|
|
131
|
-
}
|
|
132
|
-
export const apiClient = (config) => {
|
|
133
|
-
const apiConfig = {
|
|
134
|
-
...config,
|
|
135
|
-
};
|
|
136
|
-
return {
|
|
137
|
-
get: (url, options) => apiWrapper(() => api(apiConfig, url, options)),
|
|
138
|
-
post: (url, options) => apiWrapper(() => api(apiConfig, url, { ...options, method: "POST" })),
|
|
139
|
-
put: (url, options) => apiWrapper(() => api(apiConfig, url, { ...options, method: "PUT" })),
|
|
140
|
-
delete: (url, options) => apiWrapper(() => api(apiConfig, url, { ...options, method: "DELETE" })),
|
|
141
|
-
patch: (url, options) => apiWrapper(() => api(apiConfig, url, { ...options, method: "PATCH" })),
|
|
142
|
-
};
|
|
143
|
-
};
|
package/dist/esm/api/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { apiClient } from "./client.js";
|
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";
|