@splendidlabz/utils 1.11.3 → 1.11.4
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/cjs/dom/accessibility.cjs +53 -0
- package/dist/cjs/dom/actions/index.cjs +410 -0
- package/dist/cjs/dom/actions/masonry.cjs +152 -0
- package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +157 -0
- package/dist/cjs/dom/actions/sticky.cjs +213 -0
- package/dist/cjs/dom/bounding-box.cjs +70 -0
- package/dist/cjs/dom/clipboard.cjs +37 -0
- package/dist/cjs/dom/cookie.cjs +57 -0
- package/dist/cjs/dom/css-vars.cjs +57 -0
- package/dist/cjs/dom/events.cjs +59 -0
- package/{src/dom/focusable.js → dist/cjs/dom/focusable.cjs} +51 -73
- package/dist/cjs/dom/font-size.cjs +80 -0
- package/dist/cjs/dom/get-element.cjs +98 -0
- package/dist/cjs/dom/hash.cjs +35 -0
- package/dist/cjs/dom/index.cjs +1267 -0
- package/dist/cjs/dom/keyboard.cjs +51 -0
- package/dist/cjs/dom/local-store.cjs +79 -0
- package/dist/cjs/dom/media.cjs +59 -0
- package/dist/cjs/dom/observers/index.cjs +253 -0
- package/dist/cjs/dom/observers/intersection-observer.cjs +91 -0
- package/dist/cjs/dom/observers/mutation-observer.cjs +95 -0
- package/dist/cjs/dom/observers/observer.cjs +48 -0
- package/dist/cjs/dom/observers/resize-observer.cjs +84 -0
- package/dist/cjs/dom/observers/scroll-observer.cjs +177 -0
- package/dist/cjs/dom/pkce.cjs +53 -0
- package/dist/cjs/dom/query-params.cjs +38 -0
- package/dist/cjs/dom/random-string.cjs +38 -0
- package/dist/cjs/dom/sanitize.cjs +65 -0
- package/dist/cjs/dom/session-store.cjs +49 -0
- package/dist/cjs/dom/spam-prevention.cjs +50 -0
- package/dist/cjs/dom/trap-focus.cjs +197 -0
- package/dist/cjs/dom/ui/aria-current.cjs +43 -0
- package/dist/cjs/dom/ui/inconsistent-button-fix.cjs +35 -0
- package/dist/cjs/dom/ui/index.cjs +105 -0
- package/dist/cjs/dom/ui/scroll-container.cjs +47 -0
- package/dist/cjs/dom/ui/traverse-and-scramble.cjs +50 -0
- package/dist/cjs/lib/arrays/index.cjs +139 -0
- package/dist/cjs/lib/arrays/item-position.cjs +42 -0
- package/dist/cjs/lib/arrays/join.cjs +43 -0
- package/dist/cjs/lib/arrays/shuffle.cjs +42 -0
- package/dist/cjs/lib/arrays/sort.cjs +67 -0
- package/dist/cjs/lib/arrays/split-array.cjs +41 -0
- package/dist/cjs/lib/arrays/unique.cjs +31 -0
- package/dist/cjs/lib/auth/index.cjs +53 -0
- package/dist/cjs/lib/auth/route-manager.cjs +51 -0
- package/dist/cjs/lib/checks.cjs +63 -0
- package/dist/cjs/lib/date/days.cjs +37 -0
- package/dist/cjs/lib/date/index.cjs +208 -0
- package/dist/cjs/lib/date/months.cjs +102 -0
- package/dist/cjs/lib/date/time.cjs +117 -0
- package/dist/cjs/lib/form/form-data.cjs +83 -0
- package/dist/cjs/lib/form/index.cjs +122 -0
- package/dist/cjs/lib/form/sanitize.cjs +61 -0
- package/dist/cjs/lib/functions/callback.cjs +31 -0
- package/dist/cjs/lib/functions/debounce.cjs +43 -0
- package/dist/cjs/lib/functions/env.cjs +32 -0
- package/dist/cjs/lib/functions/functional.cjs +82 -0
- package/dist/cjs/lib/functions/index.cjs +142 -0
- package/dist/cjs/lib/functions/throttle.cjs +38 -0
- package/dist/cjs/lib/functions/timeout.cjs +41 -0
- package/dist/cjs/lib/hash.cjs +43 -0
- package/dist/cjs/lib/index.cjs +1178 -0
- package/dist/cjs/lib/numbers/index.cjs +49 -0
- package/dist/cjs/lib/numbers/math.cjs +36 -0
- package/dist/cjs/lib/objects/camelcase-keys.cjs +80 -0
- package/dist/cjs/lib/objects/empty.cjs +39 -0
- package/dist/cjs/lib/objects/equal.cjs +47 -0
- package/dist/cjs/lib/objects/extend.cjs +147 -0
- package/dist/cjs/lib/objects/flatten.cjs +48 -0
- package/dist/cjs/lib/objects/index.cjs +378 -0
- package/dist/cjs/lib/objects/json.cjs +35 -0
- package/dist/cjs/lib/objects/loop.cjs +40 -0
- package/dist/cjs/lib/objects/mix/mix.cjs +115 -0
- package/dist/cjs/lib/objects/nested-property.cjs +45 -0
- package/dist/cjs/lib/objects/normalize-object.cjs +106 -0
- package/dist/cjs/lib/objects/omit-empty.cjs +40 -0
- package/dist/cjs/lib/objects/size.cjs +63 -0
- package/dist/cjs/lib/objects/split.cjs +39 -0
- package/dist/cjs/lib/promises/index.cjs +69 -0
- package/dist/cjs/lib/promises/reject.cjs +67 -0
- package/dist/cjs/lib/sse.cjs +99 -0
- package/dist/cjs/lib/strings/convert-case/convert-case.cjs +96 -0
- package/dist/cjs/lib/strings/index.cjs +197 -0
- package/dist/cjs/lib/strings/markdown.cjs +76 -0
- package/dist/cjs/lib/strings/name.cjs +46 -0
- package/dist/cjs/lib/strings/pluralize.cjs +40 -0
- package/dist/cjs/lib/strings/query-string.cjs +43 -0
- package/dist/cjs/lib/style/index.cjs +64 -0
- package/dist/cjs/lib/symbols/index.cjs +40 -0
- package/dist/cjs/lib/symbols/symbols.cjs +38 -0
- package/dist/cjs/node/dirname.cjs +49 -0
- package/dist/cjs/node/file-cache.cjs +200 -0
- package/dist/cjs/node/file.cjs +50 -0
- package/dist/cjs/node/hash.cjs +42 -0
- package/dist/cjs/node/index.cjs +296 -0
- package/dist/cjs/node/pkce.cjs +64 -0
- package/dist/cjs/node/random-string.cjs +43 -0
- package/dist/cjs/node/sanitize.cjs +65 -0
- package/dist/cjs/node/uuid.cjs +42 -0
- package/dist/esm/dom/accessibility.js +26 -0
- package/dist/esm/dom/actions/index.js +3 -0
- package/dist/esm/dom/actions/masonry.js +38 -0
- package/dist/esm/dom/actions/prefer-horizontal-scroll.js +90 -0
- package/dist/esm/dom/actions/sticky.js +70 -0
- package/dist/esm/dom/bounding-box.js +44 -0
- package/dist/esm/dom/clipboard.js +12 -0
- package/dist/esm/dom/cookie.js +31 -0
- package/dist/esm/dom/css-vars.js +21 -0
- package/dist/esm/dom/events.js +31 -0
- package/dist/esm/dom/focusable.js +117 -0
- package/dist/esm/dom/font-size.js +40 -0
- package/dist/esm/dom/get-element.js +66 -0
- package/dist/esm/dom/hash.js +10 -0
- package/dist/esm/dom/index.js +23 -0
- package/dist/esm/dom/keyboard.js +22 -0
- package/{src → dist/esm}/dom/local-store.js +16 -28
- package/dist/esm/dom/media.js +32 -0
- package/dist/esm/dom/observers/index.js +4 -0
- package/dist/esm/dom/observers/intersection-observer.js +36 -0
- package/dist/esm/dom/observers/mutation-observer.js +40 -0
- package/dist/esm/dom/observers/observer.js +15 -0
- package/dist/esm/dom/observers/resize-observer.js +29 -0
- package/dist/esm/dom/observers/scroll-observer.js +95 -0
- package/dist/esm/dom/pkce.js +20 -0
- package/dist/esm/dom/query-params.js +13 -0
- package/dist/esm/dom/random-string.js +12 -0
- package/dist/esm/dom/sanitize.js +8 -0
- package/dist/esm/dom/session-store.js +24 -0
- package/dist/esm/dom/spam-prevention.js +25 -0
- package/dist/esm/dom/trap-focus.js +51 -0
- package/dist/esm/dom/ui/aria-current.js +17 -0
- package/dist/esm/dom/ui/inconsistent-button-fix.js +10 -0
- package/dist/esm/dom/ui/index.js +4 -0
- package/dist/esm/dom/ui/scroll-container.js +22 -0
- package/dist/esm/dom/ui/traverse-and-scramble.js +25 -0
- package/dist/esm/lib/arrays/index.js +6 -0
- package/dist/esm/lib/arrays/item-position.js +15 -0
- package/dist/esm/lib/arrays/join.js +12 -0
- package/dist/esm/lib/arrays/shuffle.js +17 -0
- package/dist/esm/lib/arrays/sort.js +36 -0
- package/dist/esm/lib/arrays/split-array.js +16 -0
- package/dist/esm/lib/arrays/unique.js +6 -0
- package/dist/esm/lib/auth/index.js +1 -0
- package/dist/esm/lib/auth/route-manager.js +25 -0
- package/dist/esm/lib/checks.js +34 -0
- package/dist/esm/lib/date/days.js +12 -0
- package/dist/esm/lib/date/index.js +3 -0
- package/dist/esm/lib/date/months.js +77 -0
- package/dist/esm/lib/date/time.js +75 -0
- package/dist/esm/lib/form/form-data.js +57 -0
- package/dist/esm/lib/form/index.js +2 -0
- package/dist/esm/lib/form/sanitize.js +34 -0
- package/dist/esm/lib/functions/callback.js +6 -0
- package/dist/esm/lib/functions/debounce.js +18 -0
- package/dist/esm/lib/functions/env.js +7 -0
- package/dist/esm/lib/functions/functional.js +52 -0
- package/dist/esm/lib/functions/index.js +5 -0
- package/dist/esm/lib/functions/throttle.js +13 -0
- package/dist/esm/lib/functions/timeout.js +14 -0
- package/dist/esm/lib/hash.js +18 -0
- package/dist/esm/lib/index.js +14 -0
- package/dist/esm/lib/numbers/index.js +11 -0
- package/dist/esm/lib/numbers/math.js +10 -0
- package/dist/esm/lib/objects/camelcase-keys.js +16 -0
- package/dist/esm/lib/objects/empty.js +13 -0
- package/dist/esm/lib/objects/equal.js +11 -0
- package/dist/esm/lib/objects/extend.js +13 -0
- package/dist/esm/lib/objects/flatten.js +17 -0
- package/dist/esm/lib/objects/index.js +13 -0
- package/dist/esm/lib/objects/json.js +10 -0
- package/dist/esm/lib/objects/loop.js +14 -0
- package/dist/esm/lib/objects/mix/mix.js +88 -0
- package/dist/esm/lib/objects/nested-property.js +18 -0
- package/dist/esm/lib/objects/normalize-object.js +9 -0
- package/dist/esm/lib/objects/omit-empty.js +15 -0
- package/dist/esm/lib/objects/size.js +38 -0
- package/dist/esm/lib/objects/split.js +14 -0
- package/dist/esm/lib/promises/index.js +1 -0
- package/dist/esm/lib/promises/reject.js +17 -0
- package/dist/esm/lib/sse.js +50 -0
- package/dist/esm/lib/strings/convert-case/convert-case.js +64 -0
- package/dist/esm/lib/strings/index.js +5 -0
- package/dist/esm/lib/strings/markdown.js +40 -0
- package/dist/esm/lib/strings/name.js +21 -0
- package/dist/esm/lib/strings/pluralize.js +5 -0
- package/dist/esm/lib/strings/query-string.js +16 -0
- package/dist/esm/lib/style/index.js +12 -0
- package/dist/esm/lib/symbols/index.js +1 -0
- package/dist/esm/lib/symbols/symbols.js +12 -0
- package/dist/esm/node/context.js +0 -0
- package/dist/esm/node/dirname.js +13 -0
- package/dist/esm/node/file-cache.js +121 -0
- package/dist/esm/node/file.js +14 -0
- package/dist/esm/node/hash.js +7 -0
- package/dist/esm/node/index.js +7 -0
- package/dist/esm/node/pkce.js +20 -0
- package/dist/esm/node/random-string.js +8 -0
- package/dist/esm/node/sanitize.js +8 -0
- package/dist/esm/node/uuid.js +7 -0
- package/dist/types/dom/accessibility.d.cts +30 -0
- package/dist/types/dom/actions/index.d.cts +3 -0
- package/dist/types/dom/actions/masonry.d.cts +5 -0
- package/dist/types/dom/actions/prefer-horizontal-scroll.d.cts +5 -0
- package/dist/types/dom/actions/sticky.d.cts +5 -0
- package/{src/dom/bounding-box.js → dist/types/dom/bounding-box.d.cts} +8 -49
- package/dist/types/dom/clipboard.d.cts +7 -0
- package/dist/types/dom/cookie.d.cts +7 -0
- package/dist/types/dom/css-vars.d.cts +6 -0
- package/{src/dom/events.js → dist/types/dom/events.d.cts} +52 -31
- package/dist/types/dom/focusable.d.cts +78 -0
- package/dist/types/dom/font-size.d.cts +8 -0
- package/{src/dom/get-element.js → dist/types/dom/get-element.d.cts} +25 -99
- package/dist/types/dom/hash.d.cts +3 -0
- package/dist/types/dom/index.d.cts +31 -0
- package/{src/dom/keyboard.js → dist/types/dom/keyboard.d.cts} +7 -19
- package/dist/types/dom/local-store.d.cts +31 -0
- package/dist/types/dom/media.d.cts +5 -0
- package/dist/types/dom/observers/index.d.cts +4 -0
- package/dist/types/dom/observers/intersection-observer.d.cts +10 -0
- package/dist/types/dom/observers/mutation-observer.d.cts +9 -0
- package/dist/types/dom/observers/observer.d.cts +3 -0
- package/{src/dom/observers/resize-observer.js → dist/types/dom/observers/resize-observer.d.cts} +6 -32
- package/dist/types/dom/observers/scroll-observer.d.cts +40 -0
- package/dist/types/dom/pkce.d.cts +8 -0
- package/dist/types/dom/query-params.d.cts +6 -0
- package/dist/types/dom/random-string.d.cts +9 -0
- package/dist/types/dom/sanitize.d.cts +10 -0
- package/dist/types/dom/session-store.d.cts +7 -0
- package/dist/types/dom/spam-prevention.d.cts +14 -0
- package/dist/types/dom/trap-focus.d.cts +32 -0
- package/dist/types/dom/ui/aria-current.d.cts +7 -0
- package/{src/dom/ui/inconsistent-button-fix.js → dist/types/dom/ui/inconsistent-button-fix.d.cts} +5 -11
- package/dist/types/dom/ui/index.d.cts +4 -0
- package/dist/types/dom/ui/scroll-container.d.cts +3 -0
- package/dist/types/dom/ui/traverse-and-scramble.d.cts +21 -0
- package/dist/types/lib/arrays/index.d.cts +6 -0
- package/{src/lib/arrays/item-position.js → dist/types/lib/arrays/item-position.d.cts} +5 -12
- package/{src/lib/arrays/join.js → dist/types/lib/arrays/join.d.cts} +4 -9
- package/dist/types/lib/arrays/shuffle.d.cts +3 -0
- package/dist/types/lib/arrays/sort.d.cts +32 -0
- package/dist/types/lib/arrays/split-array.d.cts +6 -0
- package/dist/types/lib/arrays/unique.d.cts +3 -0
- package/dist/types/lib/auth/index.d.cts +1 -0
- package/dist/types/lib/auth/route-manager.d.cts +28 -0
- package/dist/types/lib/checks.d.cts +33 -0
- package/dist/types/lib/date/days.d.cts +7 -0
- package/dist/types/lib/date/index.d.cts +3 -0
- package/dist/types/lib/date/months.d.cts +11 -0
- package/dist/types/lib/date/time.d.cts +21 -0
- package/dist/types/lib/form/form-data.d.cts +9 -0
- package/dist/types/lib/form/index.d.cts +2 -0
- package/{src/lib/form/sanitize.js → dist/types/lib/form/sanitize.d.cts} +19 -39
- package/{src/lib/functions/callback.js → dist/types/lib/functions/callback.d.cts} +3 -3
- package/dist/types/lib/functions/debounce.d.cts +3 -0
- package/dist/types/lib/functions/env.d.cts +3 -0
- package/{src/lib/functions/functional.js → dist/types/lib/functions/functional.d.cts} +8 -49
- package/dist/types/lib/functions/index.d.cts +5 -0
- package/dist/types/lib/functions/throttle.d.cts +3 -0
- package/dist/types/lib/functions/timeout.d.cts +5 -0
- package/dist/types/lib/hash.d.cts +3 -0
- package/dist/types/lib/index.d.cts +43 -0
- package/dist/types/lib/numbers/index.d.cts +5 -0
- package/dist/types/lib/numbers/math.d.cts +4 -0
- package/dist/types/lib/objects/camelcase-keys.d.cts +3 -0
- package/dist/types/lib/objects/empty.d.cts +4 -0
- package/dist/types/lib/objects/equal.d.cts +4 -0
- package/dist/types/lib/objects/extend.d.cts +6 -0
- package/dist/types/lib/objects/flatten.d.cts +6 -0
- package/dist/types/lib/objects/index.d.cts +13 -0
- package/dist/types/lib/objects/json.d.cts +3 -0
- package/dist/types/lib/objects/loop.d.cts +4 -0
- package/dist/types/lib/objects/mix/mix.d.cts +44 -0
- package/{src/lib/objects/nested-property.js → dist/types/lib/objects/nested-property.d.cts} +4 -21
- package/dist/types/lib/objects/normalize-object.d.cts +3 -0
- package/dist/types/lib/objects/omit-empty.d.cts +3 -0
- package/dist/types/lib/objects/size.d.cts +3 -0
- package/dist/types/lib/objects/split.d.cts +14 -0
- package/dist/types/lib/promises/index.d.cts +1 -0
- package/dist/types/lib/promises/reject.d.cts +5 -0
- package/dist/types/lib/sse.d.cts +18 -0
- package/dist/types/lib/strings/convert-case/convert-case.d.cts +10 -0
- package/dist/types/lib/strings/index.d.cts +5 -0
- package/dist/types/lib/strings/markdown.d.cts +25 -0
- package/dist/types/lib/strings/name.d.cts +7 -0
- package/dist/types/lib/strings/pluralize.d.cts +3 -0
- package/dist/types/lib/strings/query-string.d.cts +10 -0
- package/dist/types/lib/style/index.d.cts +3 -0
- package/dist/types/lib/symbols/index.d.cts +1 -0
- package/dist/types/lib/symbols/symbols.d.cts +4 -0
- package/dist/types/node/context.d.cts +2 -0
- package/dist/types/node/dirname.d.cts +9 -0
- package/dist/types/node/file-cache.d.cts +56 -0
- package/dist/types/node/file.d.cts +4 -0
- package/dist/types/node/hash.d.cts +3 -0
- package/dist/types/node/index.d.cts +7 -0
- package/dist/types/node/pkce.d.cts +14 -0
- package/dist/types/node/random-string.d.cts +3 -0
- package/{src/node/sanitize.js → dist/types/node/sanitize.d.cts} +3 -6
- package/dist/types/node/uuid.d.cts +3 -0
- package/package.json +4 -1
- package/CHANGELOG.md +0 -237
- package/eslint.config.js +0 -2
- package/src/dom/accessibility.js +0 -58
- package/src/dom/actions/index.js +0 -3
- package/src/dom/actions/masonry.js +0 -43
- package/src/dom/actions/prefer-horizontal-scroll.js +0 -121
- package/src/dom/actions/sticky.js +0 -85
- package/src/dom/clipboard.js +0 -14
- package/src/dom/cookie.js +0 -32
- package/src/dom/css-vars.js +0 -19
- package/src/dom/font-size.js +0 -40
- package/src/dom/hash.js +0 -9
- package/src/dom/index.js +0 -23
- package/src/dom/media.js +0 -30
- package/src/dom/observers/index.js +0 -4
- package/src/dom/observers/intersection-observer.js +0 -43
- package/src/dom/observers/mutation-observer.js +0 -51
- package/src/dom/observers/observer.js +0 -18
- package/src/dom/observers/scroll-observer.js +0 -146
- package/src/dom/pkce.js +0 -34
- package/src/dom/query-params.js +0 -14
- package/src/dom/random-string.js +0 -18
- package/src/dom/random-string.test.js +0 -13
- package/src/dom/sanitize.js +0 -16
- package/src/dom/session-store.js +0 -29
- package/src/dom/spam-prevention.js +0 -40
- package/src/dom/trap-focus.js +0 -70
- package/src/dom/ui/aria-current.js +0 -20
- package/src/dom/ui/index.js +0 -4
- package/src/dom/ui/scroll-container.js +0 -25
- package/src/dom/ui/traverse-and-scramble.js +0 -61
- package/src/lib/arrays/index.js +0 -6
- package/src/lib/arrays/shuffle.js +0 -21
- package/src/lib/arrays/sort.js +0 -88
- package/src/lib/arrays/sort.spec.js +0 -123
- package/src/lib/arrays/split-array.js +0 -15
- package/src/lib/arrays/unique.js +0 -3
- package/src/lib/auth/index.js +0 -1
- package/src/lib/auth/route-manager.js +0 -45
- package/src/lib/checks.js +0 -57
- package/src/lib/date/days.js +0 -9
- package/src/lib/date/index.js +0 -3
- package/src/lib/date/months.js +0 -74
- package/src/lib/date/time.js +0 -83
- package/src/lib/form/form-data.js +0 -73
- package/src/lib/form/index.js +0 -2
- package/src/lib/form/sanitize.spec.js +0 -126
- package/src/lib/functions/debounce.js +0 -18
- package/src/lib/functions/env.js +0 -5
- package/src/lib/functions/functional.test.js +0 -196
- package/src/lib/functions/index.js +0 -5
- package/src/lib/functions/throttle.js +0 -11
- package/src/lib/functions/timeout.js +0 -15
- package/src/lib/hash.js +0 -18
- package/src/lib/hash.spec.js +0 -163
- package/src/lib/index.js +0 -14
- package/src/lib/numbers/index.js +0 -12
- package/src/lib/numbers/math.js +0 -9
- package/src/lib/numbers/split-unit.test.js +0 -45
- package/src/lib/objects/camelcase-keys.js +0 -17
- package/src/lib/objects/camelcase-keys.test.js +0 -72
- package/src/lib/objects/empty.js +0 -10
- package/src/lib/objects/equal.js +0 -9
- package/src/lib/objects/extend.js +0 -16
- package/src/lib/objects/extend.test.js +0 -35
- package/src/lib/objects/flatten.js +0 -19
- package/src/lib/objects/index.js +0 -13
- package/src/lib/objects/json.js +0 -7
- package/src/lib/objects/loop.js +0 -11
- package/src/lib/objects/loop.test.js +0 -31
- package/src/lib/objects/mix/mix.js +0 -191
- package/src/lib/objects/mix/mix.md +0 -78
- package/src/lib/objects/mix/mix.test.js +0 -445
- package/src/lib/objects/normalize-object.js +0 -10
- package/src/lib/objects/omit-empty.js +0 -23
- package/src/lib/objects/omit-empty.test.js +0 -85
- package/src/lib/objects/size.js +0 -41
- package/src/lib/objects/split.js +0 -19
- package/src/lib/promises/index.js +0 -1
- package/src/lib/promises/reject.js +0 -17
- package/src/lib/sse.js +0 -61
- package/src/lib/strings/convert-case/convert-case.js +0 -86
- package/src/lib/strings/convert-case/convert-case.md +0 -44
- package/src/lib/strings/convert-case/convert-case.test.js +0 -50
- package/src/lib/strings/index.js +0 -5
- package/src/lib/strings/markdown.js +0 -71
- package/src/lib/strings/markdown.spec.js +0 -73
- package/src/lib/strings/name.js +0 -24
- package/src/lib/strings/name.test.js +0 -67
- package/src/lib/strings/pluralize.js +0 -2
- package/src/lib/strings/query-string.js +0 -18
- package/src/lib/style/index.js +0 -13
- package/src/lib/symbols/index.js +0 -1
- package/src/lib/symbols/symbols.js +0 -9
- package/src/node/dirname.js +0 -17
- package/src/node/file-cache.js +0 -184
- package/src/node/file.js +0 -13
- package/src/node/hash.js +0 -5
- package/src/node/index.js +0 -7
- package/src/node/pkce.js +0 -33
- package/src/node/random-string.js +0 -10
- package/src/node/random-string.test.js +0 -15
- package/src/node/sanitize.spec.js +0 -142
- package/src/node/uuid.js +0 -5
- package/tsconfig.json +0 -23
- package/tsup.config.js +0 -38
- package/tsup.config.mjs +0 -63
- /package/{src/node/context.js → dist/cjs/node/context.cjs} +0 -0
|
@@ -0,0 +1,1178 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/lib/index.js
|
|
30
|
+
var lib_exports = {};
|
|
31
|
+
__export(lib_exports, {
|
|
32
|
+
AuthManager: () => AuthManager,
|
|
33
|
+
DAYS: () => DAYS,
|
|
34
|
+
MONTHS: () => MONTHS,
|
|
35
|
+
RouteManager: () => RouteManager,
|
|
36
|
+
camelCaseKeys: () => camelCaseKeys,
|
|
37
|
+
compose: () => compose,
|
|
38
|
+
composeAsync: () => composeAsync,
|
|
39
|
+
concatMix: () => concatMix,
|
|
40
|
+
createMix: () => createMix,
|
|
41
|
+
createSSE: () => createSSE,
|
|
42
|
+
curry: () => curry,
|
|
43
|
+
debounce: () => debounce,
|
|
44
|
+
delay: () => delay,
|
|
45
|
+
extendObject: () => extendObject,
|
|
46
|
+
flattenArrayFields: () => flattenArrayFields,
|
|
47
|
+
flattenObject: () => flattenObject,
|
|
48
|
+
formDataToObject: () => formDataToObject,
|
|
49
|
+
getEnv: () => getEnv,
|
|
50
|
+
getNestedProperty: () => getNestedProperty,
|
|
51
|
+
getNestedProperty2: () => getNestedProperty2,
|
|
52
|
+
getNestedValue: () => getNestedValue,
|
|
53
|
+
getSymbol: () => getSymbol,
|
|
54
|
+
getSymbolValue: () => getSymbolValue,
|
|
55
|
+
getTimeInMs: () => getTimeInMs,
|
|
56
|
+
getType: () => getType,
|
|
57
|
+
isArray: () => isArray,
|
|
58
|
+
isEmpty: () => isEmpty,
|
|
59
|
+
isEqual: () => isEqual,
|
|
60
|
+
isFunction: () => isFunction,
|
|
61
|
+
isHashedValue: () => isHashedValue,
|
|
62
|
+
isLastItem: () => isLastItem,
|
|
63
|
+
isObject: () => isObject,
|
|
64
|
+
joinWithConjunction: () => joinWithConjunction,
|
|
65
|
+
last: () => last,
|
|
66
|
+
lastArrayItem: () => lastArrayItem,
|
|
67
|
+
markdown: () => markdown,
|
|
68
|
+
mix: () => mix,
|
|
69
|
+
ms: () => ms,
|
|
70
|
+
normalizeObject: () => normalizeObject,
|
|
71
|
+
notEmpty: () => notEmpty,
|
|
72
|
+
notEqual: () => notEqual,
|
|
73
|
+
notObject: () => notObject,
|
|
74
|
+
objectForEach: () => objectForEach,
|
|
75
|
+
objectMap: () => objectMap,
|
|
76
|
+
omitEmpty: () => omitEmpty,
|
|
77
|
+
parseFullName: () => parseFullName,
|
|
78
|
+
parseJSON: () => parseJSON,
|
|
79
|
+
parseSSE: () => parseSSE,
|
|
80
|
+
pipe: () => pipe,
|
|
81
|
+
pipeAsync: () => pipeAsync,
|
|
82
|
+
plural: () => plural,
|
|
83
|
+
pluralize: () => pluralize,
|
|
84
|
+
reject: () => reject,
|
|
85
|
+
sanitize: () => sanitize,
|
|
86
|
+
sanitizeArray: () => sanitizeArray,
|
|
87
|
+
sanitizeObject: () => sanitizeObject,
|
|
88
|
+
shuffle: () => shuffle,
|
|
89
|
+
sizeOf: () => sizeOf,
|
|
90
|
+
sort: () => sort,
|
|
91
|
+
splitArray: () => splitArray,
|
|
92
|
+
splitObject: () => splitObject,
|
|
93
|
+
splitUnit: () => splitUnit,
|
|
94
|
+
stripNumbers: () => stripNumbers,
|
|
95
|
+
throttle: () => throttle,
|
|
96
|
+
timeout: () => timeout,
|
|
97
|
+
times: () => times,
|
|
98
|
+
toCamel: () => toCamel,
|
|
99
|
+
toDays: () => toDays,
|
|
100
|
+
toDegrees: () => toDegrees,
|
|
101
|
+
toHours: () => toHours,
|
|
102
|
+
toKebab: () => toKebab,
|
|
103
|
+
toLower: () => toLower,
|
|
104
|
+
toMinutes: () => toMinutes,
|
|
105
|
+
toPascal: () => toPascal,
|
|
106
|
+
toQueryString: () => toQueryString,
|
|
107
|
+
toRadians: () => toRadians,
|
|
108
|
+
toReadableTime: () => toReadableTime,
|
|
109
|
+
toSeconds: () => toSeconds,
|
|
110
|
+
toSentence: () => toSentence,
|
|
111
|
+
toSlug: () => toSlug,
|
|
112
|
+
toStyleString: () => toStyleString,
|
|
113
|
+
toTitle: () => toTitle,
|
|
114
|
+
toUpper: () => toUpper,
|
|
115
|
+
toWeeks: () => toWeeks,
|
|
116
|
+
treatMarkdownWhitespace: () => treatMarkdownWhitespace,
|
|
117
|
+
uniqueArray: () => uniqueArray,
|
|
118
|
+
wait: () => wait
|
|
119
|
+
});
|
|
120
|
+
module.exports = __toCommonJS(lib_exports);
|
|
121
|
+
|
|
122
|
+
// src/lib/arrays/item-position.js
|
|
123
|
+
function last(array, index) {
|
|
124
|
+
console.warn("last is deprecated. Use isLastItem instead.");
|
|
125
|
+
return index === array.length - 1;
|
|
126
|
+
}
|
|
127
|
+
function isLastItem(array, index) {
|
|
128
|
+
return index === array.length - 1;
|
|
129
|
+
}
|
|
130
|
+
function lastArrayItem(array) {
|
|
131
|
+
return array[array.length - 1];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/lib/arrays/join.js
|
|
135
|
+
function joinWithConjunction(array, { conjunction = "and" } = {}) {
|
|
136
|
+
if (!array?.length) return "";
|
|
137
|
+
if (array.length === 1) return array[0];
|
|
138
|
+
if (array.length === 2) return `${array[0]} ${conjunction} ${array[1]}`;
|
|
139
|
+
const lastItem = lastArrayItem(array);
|
|
140
|
+
const rest = array.slice(0, -1);
|
|
141
|
+
return `${rest.join(", ")} ${conjunction} ${lastItem}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/lib/arrays/shuffle.js
|
|
145
|
+
function shuffle(array) {
|
|
146
|
+
const clone = array.slice();
|
|
147
|
+
let currentIndex = array.length;
|
|
148
|
+
let temporaryValue;
|
|
149
|
+
let randomIndex;
|
|
150
|
+
while (currentIndex !== 0) {
|
|
151
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
152
|
+
currentIndex -= 1;
|
|
153
|
+
temporaryValue = clone[currentIndex];
|
|
154
|
+
clone[currentIndex] = clone[randomIndex];
|
|
155
|
+
clone[randomIndex] = temporaryValue;
|
|
156
|
+
}
|
|
157
|
+
return clone;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/lib/objects/nested-property.js
|
|
161
|
+
function getNestedProperty(object, pathArr) {
|
|
162
|
+
return pathArr.reduce(
|
|
163
|
+
(nestedObject, key) => nestedObject && nestedObject[key] !== "undefined" ? nestedObject[key] : void 0,
|
|
164
|
+
object
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function getNestedProperty2(object, path) {
|
|
168
|
+
const pathArray = path.split(".");
|
|
169
|
+
return getNestedProperty(object, pathArray);
|
|
170
|
+
}
|
|
171
|
+
function getNestedValue(object, path) {
|
|
172
|
+
return path.split(".").reduce((acc, part) => acc?.[part], object);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/lib/arrays/sort.js
|
|
176
|
+
function sort(array, { props = null, reverse = false } = {}) {
|
|
177
|
+
const clone = array.slice();
|
|
178
|
+
if (props === null) {
|
|
179
|
+
return clone.sort((a, b) => {
|
|
180
|
+
const comparison = compareValues(a, b);
|
|
181
|
+
return reverse ? -comparison : comparison;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const properties = Array.isArray(props) ? props : [props];
|
|
185
|
+
return clone.sort((a, b) => {
|
|
186
|
+
for (const property of properties) {
|
|
187
|
+
const aValue = getNestedValue(a, property);
|
|
188
|
+
const bValue = getNestedValue(b, property);
|
|
189
|
+
if (aValue === bValue) continue;
|
|
190
|
+
if (aValue == null) return 1;
|
|
191
|
+
if (bValue == null) return -1;
|
|
192
|
+
const comparison = compareValues(aValue, bValue);
|
|
193
|
+
return reverse ? -comparison : comparison;
|
|
194
|
+
}
|
|
195
|
+
return 0;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function compareValues(a, b) {
|
|
199
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
200
|
+
if (typeof a === "string" && typeof b === "string") return a.localeCompare(b);
|
|
201
|
+
const aDate = new Date(a);
|
|
202
|
+
const bDate = new Date(b);
|
|
203
|
+
const aTime = aDate.getTime();
|
|
204
|
+
const bTime = bDate.getTime();
|
|
205
|
+
if (!isNaN(aTime) && !isNaN(bTime)) return aTime - bTime;
|
|
206
|
+
return String(a).localeCompare(String(b));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/lib/arrays/split-array.js
|
|
210
|
+
function splitArray(array, predicate) {
|
|
211
|
+
const ret = {
|
|
212
|
+
picked: [],
|
|
213
|
+
omitted: []
|
|
214
|
+
};
|
|
215
|
+
array.forEach((item, index, arr) => {
|
|
216
|
+
if (predicate(item, index, arr)) ret.picked.push(item);
|
|
217
|
+
else ret.omitted.push(item);
|
|
218
|
+
});
|
|
219
|
+
ret.p = ret.picked;
|
|
220
|
+
ret.o = ret.omitted;
|
|
221
|
+
return ret;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/lib/arrays/unique.js
|
|
225
|
+
function uniqueArray(array) {
|
|
226
|
+
return Array.from(new Set(array));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/lib/auth/route-manager.js
|
|
230
|
+
function RouteManager(config) {
|
|
231
|
+
const { protectedRoutes, bypassRoutes } = config;
|
|
232
|
+
return {
|
|
233
|
+
isProtectedRoute(pathname) {
|
|
234
|
+
return isMatch(protectedRoutes, pathname);
|
|
235
|
+
},
|
|
236
|
+
isBypassRoute(pathname) {
|
|
237
|
+
return isMatch(bypassRoutes, pathname);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function AuthManager(config) {
|
|
242
|
+
return RouteManager(config);
|
|
243
|
+
}
|
|
244
|
+
function isMatch(routeConfig, pathname) {
|
|
245
|
+
const { is, startsWith, includes } = routeConfig;
|
|
246
|
+
const isExactMatch = is && is.some((u) => pathname === u);
|
|
247
|
+
const startsWithMatch = startsWith && startsWith.some((u) => pathname.startsWith(u));
|
|
248
|
+
const includesMatch = includes && includes.some((u) => pathname.includes(u));
|
|
249
|
+
return isExactMatch || startsWithMatch || includesMatch;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/lib/checks.js
|
|
253
|
+
function isObject(x) {
|
|
254
|
+
return typeof x === "object" && !Array.isArray(x) && x !== null;
|
|
255
|
+
}
|
|
256
|
+
function isArray(x) {
|
|
257
|
+
return Array.isArray(x);
|
|
258
|
+
}
|
|
259
|
+
function notObject(x) {
|
|
260
|
+
return !isObject(x);
|
|
261
|
+
}
|
|
262
|
+
function getType(x) {
|
|
263
|
+
if (typeof x === "string") return "string";
|
|
264
|
+
if (typeof x === "number") {
|
|
265
|
+
if (Number.isInteger(x)) return "integer";
|
|
266
|
+
return "float";
|
|
267
|
+
}
|
|
268
|
+
if (typeof x === "boolean") return "boolean";
|
|
269
|
+
if (typeof x === "function") return "function";
|
|
270
|
+
if (typeof x === "undefined") return "undefined";
|
|
271
|
+
if (typeof x === "symbol") return "symbol";
|
|
272
|
+
if (typeof x === "bigint") return "bigint";
|
|
273
|
+
if (Array.isArray(x)) return "array";
|
|
274
|
+
if (typeof x === "object") return "object";
|
|
275
|
+
return "unknown";
|
|
276
|
+
}
|
|
277
|
+
function isFunction(x) {
|
|
278
|
+
return typeof x === "function";
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/lib/date/days.js
|
|
282
|
+
var DAYS = [
|
|
283
|
+
{ short: "Sun", long: "Sunday", numeric: 1 },
|
|
284
|
+
{ short: "Mon", long: "Monday", numeric: 2 },
|
|
285
|
+
{ short: "Tue", long: "Tuesday", numeric: 3 },
|
|
286
|
+
{ short: "Wed", long: "Wednesday", numeric: 4 },
|
|
287
|
+
{ short: "Thu", long: "Thursday", numeric: 5 },
|
|
288
|
+
{ short: "Fri", long: "Friday", numeric: 6 },
|
|
289
|
+
{ short: "Sat", long: "Saturday", numeric: 7 }
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
// src/lib/date/months.js
|
|
293
|
+
var MONTHS = [
|
|
294
|
+
{
|
|
295
|
+
long: "January",
|
|
296
|
+
short: "jan",
|
|
297
|
+
numeric: 1,
|
|
298
|
+
lastDay: { default: 31, leapYear: 31 }
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
long: "February",
|
|
302
|
+
short: "feb",
|
|
303
|
+
numeric: 2,
|
|
304
|
+
lastDay: { default: 28, leapYear: 29 }
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
long: "March",
|
|
308
|
+
short: "mar",
|
|
309
|
+
numeric: 3,
|
|
310
|
+
lastDay: { default: 31, leapYear: 31 }
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
long: "April",
|
|
314
|
+
short: "apr",
|
|
315
|
+
numeric: 4,
|
|
316
|
+
lastDay: { default: 30, leapYear: 30 }
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
long: "May",
|
|
320
|
+
short: "may",
|
|
321
|
+
numeric: 5,
|
|
322
|
+
lastDay: { default: 31, leapYear: 31 }
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
long: "June",
|
|
326
|
+
short: "jun",
|
|
327
|
+
numeric: 6,
|
|
328
|
+
lastDay: { default: 30, leapYear: 30 }
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
long: "July",
|
|
332
|
+
short: "jul",
|
|
333
|
+
numeric: 7,
|
|
334
|
+
lastDay: { default: 31, leapYear: 31 }
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
long: "August",
|
|
338
|
+
short: "aug",
|
|
339
|
+
numeric: 8,
|
|
340
|
+
lastDay: { default: 31, leapYear: 31 }
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
long: "September",
|
|
344
|
+
short: "sep",
|
|
345
|
+
numeric: 9,
|
|
346
|
+
lastDay: { default: 30, leapYear: 30 }
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
long: "October",
|
|
350
|
+
short: "oct",
|
|
351
|
+
numeric: 10,
|
|
352
|
+
lastDay: { default: 31, leapYear: 31 }
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
long: "November",
|
|
356
|
+
short: "nov",
|
|
357
|
+
numeric: 11,
|
|
358
|
+
lastDay: { default: 30, leapYear: 30 }
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
long: "December",
|
|
362
|
+
short: "dec",
|
|
363
|
+
numeric: 12,
|
|
364
|
+
lastDay: { default: 31, leapYear: 31 }
|
|
365
|
+
}
|
|
366
|
+
];
|
|
367
|
+
|
|
368
|
+
// src/lib/numbers/math.js
|
|
369
|
+
function toDegrees(angle) {
|
|
370
|
+
return angle * (180 / Math.PI);
|
|
371
|
+
}
|
|
372
|
+
function toRadians(angle) {
|
|
373
|
+
return angle * (Math.PI / 180);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/lib/numbers/index.js
|
|
377
|
+
function splitUnit(string) {
|
|
378
|
+
if (typeof string === "number") return [string, null];
|
|
379
|
+
const regex = /(-?\d*\.?\d+)\s*([a-z]+)/i;
|
|
380
|
+
const match = string.match(regex);
|
|
381
|
+
if (match) return [parseFloat(match[1]), match[2]];
|
|
382
|
+
return [parseFloat(string), null];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// src/lib/date/time.js
|
|
386
|
+
function ms(arg) {
|
|
387
|
+
const [value, unit] = splitUnit(arg);
|
|
388
|
+
if (unit === "d") return getTimeInMs(value, "days");
|
|
389
|
+
if (unit === "day") return getTimeInMs(value, "days");
|
|
390
|
+
if (unit === "days") return getTimeInMs(value, "days");
|
|
391
|
+
if (unit === "h") return getTimeInMs(value, "hours");
|
|
392
|
+
if (unit === "hr") return getTimeInMs(value, "hours");
|
|
393
|
+
if (unit === "hour") return getTimeInMs(value, "hours");
|
|
394
|
+
if (unit === "hours") return getTimeInMs(value, "hours");
|
|
395
|
+
if (unit === "m") return getTimeInMs(value, "minutes");
|
|
396
|
+
if (unit === "min") return getTimeInMs(value, "minutes");
|
|
397
|
+
if (unit === "mins") return getTimeInMs(value, "minutes");
|
|
398
|
+
if (unit === "minute") return getTimeInMs(value, "minutes");
|
|
399
|
+
if (unit === "minutes") return getTimeInMs(value, "minutes");
|
|
400
|
+
if (unit === "s") return getTimeInMs(value, "seconds");
|
|
401
|
+
if (unit === "sec") return getTimeInMs(value, "seconds");
|
|
402
|
+
if (unit === "secs") return getTimeInMs(value, "seconds");
|
|
403
|
+
if (unit === "second") return getTimeInMs(value, "seconds");
|
|
404
|
+
if (unit === "seconds") return getTimeInMs(value, "seconds");
|
|
405
|
+
return value;
|
|
406
|
+
}
|
|
407
|
+
function getTimeInMs(value, unit = "ms") {
|
|
408
|
+
switch (unit) {
|
|
409
|
+
case "ms":
|
|
410
|
+
return value;
|
|
411
|
+
case "seconds":
|
|
412
|
+
return value * 1e3;
|
|
413
|
+
case "minutes":
|
|
414
|
+
return value * 1e3 * 60;
|
|
415
|
+
case "hours":
|
|
416
|
+
return value * 1e3 * 60 * 60;
|
|
417
|
+
case "days":
|
|
418
|
+
return value * 1e3 * 60 * 60 * 24;
|
|
419
|
+
case "weeks":
|
|
420
|
+
return value * 1e3 * 60 * 60 * 24 * 7;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function toWeeks(ms2) {
|
|
424
|
+
return ms2 / 1e3 / 60 / 60 / 24 / 7;
|
|
425
|
+
}
|
|
426
|
+
function toDays(ms2) {
|
|
427
|
+
return ms2 / 1e3 / 60 / 60 / 24;
|
|
428
|
+
}
|
|
429
|
+
function toHours(ms2) {
|
|
430
|
+
return ms2 / 1e3 / 60 / 60;
|
|
431
|
+
}
|
|
432
|
+
function toMinutes(ms2) {
|
|
433
|
+
return ms2 / 1e3 / 60;
|
|
434
|
+
}
|
|
435
|
+
function toSeconds(ms2) {
|
|
436
|
+
return ms2 / 1e3;
|
|
437
|
+
}
|
|
438
|
+
function toReadableTime(ms2) {
|
|
439
|
+
const weekMs = 1e3 * 60 * 60 * 24 * 7;
|
|
440
|
+
const dayMs = 1e3 * 60 * 60 * 24;
|
|
441
|
+
const hourMs = 1e3 * 60 * 60;
|
|
442
|
+
const minuteMs = 1e3 * 60;
|
|
443
|
+
const weeks = Math.floor(ms2 / weekMs);
|
|
444
|
+
const days = Math.floor(ms2 % weekMs / dayMs);
|
|
445
|
+
const hours = Math.floor(ms2 % dayMs / hourMs);
|
|
446
|
+
const minutes = Math.floor(ms2 % hourMs / minuteMs);
|
|
447
|
+
const seconds = Math.floor(ms2 % minuteMs / 1e3);
|
|
448
|
+
return { weeks, days, hours, minutes, seconds };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// src/lib/form/form-data.js
|
|
452
|
+
function formDataToObject(formData) {
|
|
453
|
+
const obj = {};
|
|
454
|
+
for (let [key, value] of formData) {
|
|
455
|
+
if (typeof value === "string") value = value.trim();
|
|
456
|
+
if (key.includes("[]")) {
|
|
457
|
+
const arrayKey = key.replace("[]", "");
|
|
458
|
+
if (!obj[arrayKey]) obj[arrayKey] = [];
|
|
459
|
+
obj[arrayKey].push(value);
|
|
460
|
+
} else {
|
|
461
|
+
obj[key] = value;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return obj;
|
|
465
|
+
}
|
|
466
|
+
function flattenArrayFields(inputObject) {
|
|
467
|
+
const result = {};
|
|
468
|
+
for (const [key, value] of Object.entries(inputObject)) {
|
|
469
|
+
const match = key.match(/^(\w+)(?:\[(\d+)\])?(?:\[(\w+)\])?$/);
|
|
470
|
+
if (match) {
|
|
471
|
+
const [, baseKey, index, property] = match;
|
|
472
|
+
if (index !== void 0) {
|
|
473
|
+
if (!result[baseKey]) result[baseKey] = [];
|
|
474
|
+
const arrayIndex = parseInt(index);
|
|
475
|
+
if (!result[baseKey][arrayIndex]) result[baseKey][arrayIndex] = {};
|
|
476
|
+
if (property) {
|
|
477
|
+
result[baseKey][arrayIndex][property] = value;
|
|
478
|
+
} else {
|
|
479
|
+
result[baseKey][arrayIndex] = value;
|
|
480
|
+
}
|
|
481
|
+
} else if (property) {
|
|
482
|
+
if (!result[baseKey]) result[baseKey] = {};
|
|
483
|
+
result[baseKey][property] = value;
|
|
484
|
+
} else {
|
|
485
|
+
result[key] = value;
|
|
486
|
+
}
|
|
487
|
+
} else {
|
|
488
|
+
result[key] = value;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
for (const key in result) {
|
|
492
|
+
if (typeof result[key] === "object" && result[key] !== null) {
|
|
493
|
+
if (Object.keys(result[key]).every((k) => !isNaN(parseInt(k)))) {
|
|
494
|
+
result[key] = Object.values(result[key]).filter((item) => {
|
|
495
|
+
if (typeof item === "object") {
|
|
496
|
+
return Object.values(item).some((v) => v !== "");
|
|
497
|
+
}
|
|
498
|
+
return item !== "";
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// src/lib/form/sanitize.js
|
|
507
|
+
function sanitize(value, options = {}) {
|
|
508
|
+
const { sanitizer, ...rest } = options;
|
|
509
|
+
if (!sanitizer) throw new Error("sanitizer function is required");
|
|
510
|
+
if (typeof value === "string") return sanitizer(value, rest);
|
|
511
|
+
if (Array.isArray(value)) return sanitizeArray(value, { sanitizer, ...rest });
|
|
512
|
+
if (value && typeof value === "object") {
|
|
513
|
+
return Object.fromEntries(
|
|
514
|
+
Object.entries(value).map(([key, val]) => [
|
|
515
|
+
key,
|
|
516
|
+
sanitize(val, { sanitizer, ...rest })
|
|
517
|
+
])
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
return value;
|
|
521
|
+
}
|
|
522
|
+
function sanitizeArray(arr, { sanitizer, ...rest }) {
|
|
523
|
+
if (!sanitizer) throw new Error("sanitizer function is required");
|
|
524
|
+
return arr.map((item) => sanitize(item, { sanitizer, ...rest }));
|
|
525
|
+
}
|
|
526
|
+
function sanitizeObject(obj, { sanitizer, ...options } = {}) {
|
|
527
|
+
if (!sanitizer) throw new Error("sanitizer function is required");
|
|
528
|
+
if (Array.isArray(obj)) return sanitizeArray(obj, { sanitizer, ...options });
|
|
529
|
+
return Object.fromEntries(
|
|
530
|
+
Object.entries(obj).map(([key, value]) => [
|
|
531
|
+
key,
|
|
532
|
+
sanitize(value, { sanitizer, ...options })
|
|
533
|
+
])
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// src/lib/functions/debounce.js
|
|
538
|
+
function debounce(callback, wait2, immediate = false) {
|
|
539
|
+
let timeout2;
|
|
540
|
+
return function() {
|
|
541
|
+
const context = this;
|
|
542
|
+
const args = arguments;
|
|
543
|
+
const callNow = immediate && !timeout2;
|
|
544
|
+
clearTimeout(timeout2);
|
|
545
|
+
timeout2 = setTimeout(later, wait2);
|
|
546
|
+
if (callNow) callback.apply(context, args);
|
|
547
|
+
function later() {
|
|
548
|
+
timeout2 = null;
|
|
549
|
+
if (!immediate) callback.apply(context, args);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/lib/functions/env.js
|
|
555
|
+
function getEnv() {
|
|
556
|
+
if (typeof window === "object") return "browser";
|
|
557
|
+
if (typeof global === "object") return "node";
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// src/lib/functions/functional.js
|
|
561
|
+
function curry(fn) {
|
|
562
|
+
return function curried(...args) {
|
|
563
|
+
if (args.length >= fn.length) {
|
|
564
|
+
return fn.apply(this, args);
|
|
565
|
+
} else {
|
|
566
|
+
return function(...moreArgs) {
|
|
567
|
+
return curried.apply(this, args.concat(moreArgs));
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function compose(...fns) {
|
|
573
|
+
return function(value) {
|
|
574
|
+
return fns.reduceRight((acc, fn) => fn(acc), value);
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function composeAsync(...fns) {
|
|
578
|
+
return async function(value) {
|
|
579
|
+
return fns.reduceRight(async (acc, fn) => {
|
|
580
|
+
const result = await acc;
|
|
581
|
+
return await fn(result);
|
|
582
|
+
}, value);
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function pipe(...fns) {
|
|
586
|
+
return function(value) {
|
|
587
|
+
return fns.reduce((acc, fn) => fn(acc), value);
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function pipeAsync(...fns) {
|
|
591
|
+
return async function(value) {
|
|
592
|
+
return fns.reduce(async (acc, fn) => {
|
|
593
|
+
const result = await acc;
|
|
594
|
+
return await fn(result);
|
|
595
|
+
}, value);
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function times(fn, n) {
|
|
599
|
+
const result = [];
|
|
600
|
+
for (let i = 0; i < n; i++) {
|
|
601
|
+
result.push(fn(i));
|
|
602
|
+
}
|
|
603
|
+
return result;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// src/lib/functions/throttle.js
|
|
607
|
+
function throttle(callback, wait2) {
|
|
608
|
+
let lastCall = 0;
|
|
609
|
+
return function(...args) {
|
|
610
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
611
|
+
if (now - lastCall >= wait2) {
|
|
612
|
+
callback(...args);
|
|
613
|
+
lastCall = now;
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// src/lib/functions/timeout.js
|
|
619
|
+
function timeout(wait2, callback) {
|
|
620
|
+
setTimeout(callback, wait2);
|
|
621
|
+
}
|
|
622
|
+
function delay(ms2) {
|
|
623
|
+
return new Promise((resolve) => setTimeout(resolve, ms2));
|
|
624
|
+
}
|
|
625
|
+
function wait(ms2) {
|
|
626
|
+
return delay(ms2);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// src/lib/hash.js
|
|
630
|
+
function isHashedValue(value, type = "sha256") {
|
|
631
|
+
if (typeof value !== "string") return null;
|
|
632
|
+
value = value.trim();
|
|
633
|
+
type = type.toLowerCase();
|
|
634
|
+
if (type === "sha256") {
|
|
635
|
+
return value.length === 64 && /^[a-fA-F0-9]{64}$/.test(value);
|
|
636
|
+
}
|
|
637
|
+
if (type === "sha1") {
|
|
638
|
+
return value.length === 40 && /^[a-fA-F0-9]{40}$/.test(value);
|
|
639
|
+
}
|
|
640
|
+
if (type === "md5") {
|
|
641
|
+
return value.length === 32 && /^[a-fA-F0-9]{32}$/.test(value);
|
|
642
|
+
}
|
|
643
|
+
return null;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// src/lib/objects/loop.js
|
|
647
|
+
function objectForEach(object, callback) {
|
|
648
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
649
|
+
callback({ key, value });
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
function objectMap(object, callback) {
|
|
653
|
+
return Object.entries(object).map(([key, value]) => {
|
|
654
|
+
return callback({ key, value });
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// src/lib/strings/convert-case/convert-case.js
|
|
659
|
+
function toKebab(string) {
|
|
660
|
+
if (!string) return "";
|
|
661
|
+
return string.split("").map((letter, index) => {
|
|
662
|
+
const previousLetter = string[index - 1] || "";
|
|
663
|
+
const currentLetter = letter;
|
|
664
|
+
if (isDigit(currentLetter) && !isDigit(previousLetter)) {
|
|
665
|
+
return `-${currentLetter}`;
|
|
666
|
+
}
|
|
667
|
+
if (!isCaps(currentLetter)) return currentLetter;
|
|
668
|
+
if (previousLetter === "") {
|
|
669
|
+
return `${currentLetter.toLowerCase()}`;
|
|
670
|
+
}
|
|
671
|
+
if (isCaps(previousLetter)) {
|
|
672
|
+
return `${currentLetter.toLowerCase()}`;
|
|
673
|
+
}
|
|
674
|
+
return `-${currentLetter.toLowerCase()}`;
|
|
675
|
+
}).join("").trim().replace(/[-_\s]+/g, "-");
|
|
676
|
+
}
|
|
677
|
+
function toCamel(string) {
|
|
678
|
+
return toKebab(string).split("-").map((word, index) => {
|
|
679
|
+
if (index === 0) return word;
|
|
680
|
+
return word.slice(0, 1).toUpperCase() + word.slice(1).toLowerCase();
|
|
681
|
+
}).join("");
|
|
682
|
+
}
|
|
683
|
+
function toPascal(string) {
|
|
684
|
+
const camel = toCamel(string);
|
|
685
|
+
return camel.slice(0, 1).toUpperCase() + camel.slice(1);
|
|
686
|
+
}
|
|
687
|
+
function toTitle(string) {
|
|
688
|
+
return toKebab(string).split("-").map((word) => {
|
|
689
|
+
return word.slice(0, 1).toUpperCase() + word.slice(1);
|
|
690
|
+
}).join(" ");
|
|
691
|
+
}
|
|
692
|
+
function toSlug(string) {
|
|
693
|
+
return toKebab(string);
|
|
694
|
+
}
|
|
695
|
+
function toSentence(string) {
|
|
696
|
+
const interim = toKebab(string).replace(/-/g, " ");
|
|
697
|
+
return interim.slice(0, 1).toUpperCase() + interim.slice(1);
|
|
698
|
+
}
|
|
699
|
+
function toUpper(string) {
|
|
700
|
+
const interim = toKebab(string).replace(/-/g, " ");
|
|
701
|
+
return interim.toUpperCase();
|
|
702
|
+
}
|
|
703
|
+
function toLower(string) {
|
|
704
|
+
const interim = toKebab(string).replace(/-/g, " ");
|
|
705
|
+
return interim.toLowerCase();
|
|
706
|
+
}
|
|
707
|
+
function isCaps(char) {
|
|
708
|
+
return /\p{Lu}/u.test(char);
|
|
709
|
+
}
|
|
710
|
+
function isDigit(char) {
|
|
711
|
+
return /[0-9]/.test(char);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// src/lib/objects/camelcase-keys.js
|
|
715
|
+
function camelCaseKeys(obj) {
|
|
716
|
+
if (typeof obj !== "object" || obj === null) {
|
|
717
|
+
return obj;
|
|
718
|
+
}
|
|
719
|
+
const result = {};
|
|
720
|
+
objectForEach(obj, ({ key, value }) => {
|
|
721
|
+
const camelCaseKey = toCamel(key);
|
|
722
|
+
result[camelCaseKey] = camelCaseKeys(value);
|
|
723
|
+
});
|
|
724
|
+
return result;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/lib/objects/empty.js
|
|
728
|
+
function isEmpty(obj) {
|
|
729
|
+
if (typeof obj === "undefined") return true;
|
|
730
|
+
if (obj === null) return true;
|
|
731
|
+
if (Array.isArray(obj)) return obj.length === 0;
|
|
732
|
+
return Object.keys(obj).length === 0;
|
|
733
|
+
}
|
|
734
|
+
function notEmpty(obj) {
|
|
735
|
+
return !isEmpty(obj);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// src/lib/objects/equal.js
|
|
739
|
+
var import_deep_eql = __toESM(require("deep-eql"), 1);
|
|
740
|
+
function isEqual(a, b) {
|
|
741
|
+
return (0, import_deep_eql.default)(a, b);
|
|
742
|
+
}
|
|
743
|
+
function notEqual(a, b) {
|
|
744
|
+
return !isEqual(a, b);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// src/lib/objects/mix/mix.js
|
|
748
|
+
var DEFAULT_OPTIONS = { array: "replace" };
|
|
749
|
+
var mix = createMix();
|
|
750
|
+
var concatMix = createMix({ array: "concat" });
|
|
751
|
+
function createMix(userOptions = {}) {
|
|
752
|
+
const options = { ...DEFAULT_OPTIONS, ...userOptions };
|
|
753
|
+
function _mix(...sources) {
|
|
754
|
+
const result = {};
|
|
755
|
+
for (const source of sources) {
|
|
756
|
+
if (source == null) continue;
|
|
757
|
+
merge(result, source, options);
|
|
758
|
+
}
|
|
759
|
+
return result;
|
|
760
|
+
}
|
|
761
|
+
return _mix;
|
|
762
|
+
}
|
|
763
|
+
function merge(output, input, options) {
|
|
764
|
+
const props = Object.keys(input);
|
|
765
|
+
for (const prop of props) {
|
|
766
|
+
if (prop === "__proto__") continue;
|
|
767
|
+
const descriptor = Object.getOwnPropertyDescriptor(input, prop);
|
|
768
|
+
const value = descriptor.value;
|
|
769
|
+
if (value) descriptor.value = cloneDescriptorValue(value);
|
|
770
|
+
if (!output[prop]) {
|
|
771
|
+
Object.defineProperty(output, prop, descriptor);
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
if (typeof output[prop] !== "object") {
|
|
775
|
+
Object.defineProperty(output, prop, descriptor);
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (descriptor.value == null || typeof descriptor.value !== "object") {
|
|
779
|
+
Object.defineProperty(output, prop, descriptor);
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (objectType(descriptor.value) === "[object Array]") {
|
|
783
|
+
output[prop] = options.array === "replace" ? descriptor.value.slice() : output[prop].concat(descriptor.value);
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
merge(output[prop], descriptor.value, options);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
function cloneDescriptorValue(value) {
|
|
790
|
+
if (objectType(value) === "[object Array]") {
|
|
791
|
+
const array = [];
|
|
792
|
+
for (let v of value) {
|
|
793
|
+
v = cloneDescriptorValue(v);
|
|
794
|
+
array.push(v);
|
|
795
|
+
}
|
|
796
|
+
return array;
|
|
797
|
+
}
|
|
798
|
+
if (objectType(value) === "[object Object]") {
|
|
799
|
+
const obj = {};
|
|
800
|
+
const props = Object.keys(value);
|
|
801
|
+
for (const prop of props) {
|
|
802
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, prop);
|
|
803
|
+
if (descriptor.value)
|
|
804
|
+
descriptor.value = cloneDescriptorValue(descriptor.value);
|
|
805
|
+
Object.defineProperty(obj, prop, descriptor);
|
|
806
|
+
}
|
|
807
|
+
return obj;
|
|
808
|
+
}
|
|
809
|
+
if (objectType(value) === "[object Date]") {
|
|
810
|
+
return new Date(value.getTime());
|
|
811
|
+
}
|
|
812
|
+
if (objectType(value) === "[object Map]") {
|
|
813
|
+
const map = /* @__PURE__ */ new Map();
|
|
814
|
+
for (const entry of value) {
|
|
815
|
+
map.set(entry[0], cloneDescriptorValue(entry[1]));
|
|
816
|
+
}
|
|
817
|
+
return map;
|
|
818
|
+
}
|
|
819
|
+
if (objectType(value) === "[object Set]") {
|
|
820
|
+
const set = /* @__PURE__ */ new Set();
|
|
821
|
+
for (const entry of value.entries()) {
|
|
822
|
+
set.add(cloneDescriptorValue(entry[0]));
|
|
823
|
+
}
|
|
824
|
+
return set;
|
|
825
|
+
}
|
|
826
|
+
return value;
|
|
827
|
+
}
|
|
828
|
+
function objectType(value) {
|
|
829
|
+
return Object.prototype.toString.call(value);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// src/lib/objects/extend.js
|
|
833
|
+
function extendObject(object) {
|
|
834
|
+
const orig = object;
|
|
835
|
+
const extended = mix({}, object);
|
|
836
|
+
extended.forEach = curry(objectForEach)(orig);
|
|
837
|
+
extended.map = curry(objectMap)(orig);
|
|
838
|
+
return { orig, extended };
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// src/lib/objects/flatten.js
|
|
842
|
+
function flattenObject(obj, { separator, prefix = "" }) {
|
|
843
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
844
|
+
const newKey = prefix ? `${prefix}${separator}${key}` : key;
|
|
845
|
+
const isAnObject = isObject(value);
|
|
846
|
+
const hasNestedObject = isAnObject && Object.values(value).some(isObject);
|
|
847
|
+
if (hasNestedObject) {
|
|
848
|
+
Object.assign(acc, flattenObject(value, { separator, prefix: newKey }));
|
|
849
|
+
} else {
|
|
850
|
+
acc[newKey] = value;
|
|
851
|
+
}
|
|
852
|
+
return acc;
|
|
853
|
+
}, {});
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
// src/lib/objects/json.js
|
|
857
|
+
function parseJSON(value, defaultValue = {}) {
|
|
858
|
+
try {
|
|
859
|
+
return JSON.parse(value);
|
|
860
|
+
} catch (e) {
|
|
861
|
+
return defaultValue;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// src/lib/objects/omit-empty.js
|
|
866
|
+
function omitEmpty(obj, shallow = false) {
|
|
867
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
868
|
+
if (obj instanceof Date) return obj;
|
|
869
|
+
const result = Array.isArray(obj) ? [] : {};
|
|
870
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
871
|
+
if (value === null || value === void 0 || value === "" || typeof value === "object" && !(value instanceof Date) && Object.keys(value).length === 0) {
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
result[key] = shallow ? value : omitEmpty(value);
|
|
875
|
+
}
|
|
876
|
+
return result;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/lib/objects/normalize-object.js
|
|
880
|
+
function normalizeObject(object) {
|
|
881
|
+
return pipe(omitEmpty, camelCaseKeys)(object);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// src/lib/objects/size.js
|
|
885
|
+
function sizeOf(obj) {
|
|
886
|
+
let bytes = 0;
|
|
887
|
+
function size(obj2) {
|
|
888
|
+
if (obj2 !== null && obj2 !== void 0) {
|
|
889
|
+
switch (typeof obj2) {
|
|
890
|
+
case "number":
|
|
891
|
+
bytes += 8;
|
|
892
|
+
break;
|
|
893
|
+
case "string":
|
|
894
|
+
bytes += obj2.length * 2;
|
|
895
|
+
break;
|
|
896
|
+
case "boolean":
|
|
897
|
+
bytes += 4;
|
|
898
|
+
break;
|
|
899
|
+
case "object":
|
|
900
|
+
const objClass = Object.prototype.toString.call(obj2).slice(8, -1);
|
|
901
|
+
if (objClass === "Object" || objClass === "Array") {
|
|
902
|
+
for (const key in obj2) {
|
|
903
|
+
if (!obj2.hasOwnProperty(key)) continue;
|
|
904
|
+
size(obj2[key]);
|
|
905
|
+
}
|
|
906
|
+
} else bytes += obj2.toString().length * 2;
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return bytes;
|
|
911
|
+
}
|
|
912
|
+
function formatByteSize(bytes2) {
|
|
913
|
+
if (bytes2 < 1024) return bytes2 + " bytes";
|
|
914
|
+
else if (bytes2 < 1048576) return (bytes2 / 1024).toFixed(3) + " KiB";
|
|
915
|
+
else if (bytes2 < 1073741824) return (bytes2 / 1048576).toFixed(3) + " MiB";
|
|
916
|
+
else return (bytes2 / 1073741824).toFixed(3) + " GiB";
|
|
917
|
+
}
|
|
918
|
+
return formatByteSize(size(obj));
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// src/lib/objects/split.js
|
|
922
|
+
function splitObject(obj, keys) {
|
|
923
|
+
const picked = {};
|
|
924
|
+
const omitted = { ...obj };
|
|
925
|
+
keys.forEach((key) => {
|
|
926
|
+
if (key in obj) {
|
|
927
|
+
picked[key] = obj[key];
|
|
928
|
+
delete omitted[key];
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
return { picked, omitted, p: picked, o: omitted };
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/lib/promises/reject.js
|
|
935
|
+
var import_statuses = __toESM(require("statuses"), 1);
|
|
936
|
+
function reject(props, { includeStack = true } = {}) {
|
|
937
|
+
const { status, statusText, body, message } = props;
|
|
938
|
+
const e = new Error();
|
|
939
|
+
const err = {
|
|
940
|
+
status,
|
|
941
|
+
statusText: statusText || status && (0, import_statuses.default)(status),
|
|
942
|
+
body,
|
|
943
|
+
message,
|
|
944
|
+
stack: includeStack && e.stack
|
|
945
|
+
};
|
|
946
|
+
return Promise.reject(omitEmpty(err));
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// src/lib/sse.js
|
|
950
|
+
function createSSE({ event, data, id, retry }) {
|
|
951
|
+
const eventString = event ? `event: ${event}
|
|
952
|
+
` : "";
|
|
953
|
+
const idString = id ? `id: ${id}
|
|
954
|
+
` : "";
|
|
955
|
+
const retryString = retry ? `retry: ${retry}
|
|
956
|
+
` : "";
|
|
957
|
+
if (typeof data === "object") data = JSON.stringify(data);
|
|
958
|
+
const dataString = data ? `data: ${data}
|
|
959
|
+
` : "";
|
|
960
|
+
return `${eventString}${dataString}${idString}${retryString}
|
|
961
|
+
`;
|
|
962
|
+
}
|
|
963
|
+
function parseSSE(message) {
|
|
964
|
+
const lines = message.split("\n");
|
|
965
|
+
const result = {
|
|
966
|
+
event: "message",
|
|
967
|
+
// Default event type
|
|
968
|
+
data: "",
|
|
969
|
+
id: null,
|
|
970
|
+
retry: null
|
|
971
|
+
};
|
|
972
|
+
for (const line of lines) {
|
|
973
|
+
if (line.startsWith("data:")) {
|
|
974
|
+
const data = line.slice(5).trim();
|
|
975
|
+
result.data = parseJSON(data);
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
if (line.startsWith("event:")) {
|
|
979
|
+
result.event = line.slice(6).trim();
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
if (line.startsWith("id:")) {
|
|
983
|
+
result.id = line.slice(3).trim();
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
if (line.startsWith("retry:")) {
|
|
987
|
+
result.retry = parseInt(line.slice(6).trim(), 10);
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
const ret = omitEmpty(result);
|
|
992
|
+
return ret.data ? ret : null;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// src/lib/strings/markdown.js
|
|
996
|
+
var import_markdown_it = __toESM(require("markdown-it"), 1);
|
|
997
|
+
var import_markdown_it_anchor = __toESM(require("markdown-it-anchor"), 1);
|
|
998
|
+
var md = (0, import_markdown_it.default)({
|
|
999
|
+
html: true,
|
|
1000
|
+
linkify: true,
|
|
1001
|
+
typographer: true
|
|
1002
|
+
});
|
|
1003
|
+
md.use(import_markdown_it_anchor.default, {
|
|
1004
|
+
permalink: false,
|
|
1005
|
+
slugify: (s) => s.toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]/g, "")
|
|
1006
|
+
});
|
|
1007
|
+
function markdown(content, options = {}) {
|
|
1008
|
+
const defaultOptions = { inline: false };
|
|
1009
|
+
const opts = { ...defaultOptions, ...options };
|
|
1010
|
+
const { content: treated } = treatMarkdownWhitespace(content, opts);
|
|
1011
|
+
if (opts.inline) return md.renderInline(treated);
|
|
1012
|
+
return md.render(treated);
|
|
1013
|
+
}
|
|
1014
|
+
function treatMarkdownWhitespace(content, { inline } = {}) {
|
|
1015
|
+
if (!content) return { content: "", inline };
|
|
1016
|
+
const lines = content.split("\n");
|
|
1017
|
+
if (lines[0] !== "" && inline) return { content, inline: true };
|
|
1018
|
+
const firstLineWithLeadingSpacesIndex = lines.findIndex(
|
|
1019
|
+
(line) => line.match(/^\s+/)
|
|
1020
|
+
);
|
|
1021
|
+
const firstLineWithLeadingSpaces = lines[firstLineWithLeadingSpacesIndex];
|
|
1022
|
+
const indentation = firstLineWithLeadingSpaces?.match(/^\s+/)?.[0]?.length ?? 0;
|
|
1023
|
+
const retContent = lines.map((line, index) => {
|
|
1024
|
+
if (index < firstLineWithLeadingSpacesIndex) return line + "\n";
|
|
1025
|
+
return line.slice(indentation) + "\n";
|
|
1026
|
+
}).join("");
|
|
1027
|
+
return {
|
|
1028
|
+
content: retContent,
|
|
1029
|
+
inline
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// src/lib/strings/name.js
|
|
1034
|
+
function parseFullName(name) {
|
|
1035
|
+
const parts = name.trim().split(/\s+/);
|
|
1036
|
+
if (parts.length === 1) {
|
|
1037
|
+
return { firstName: parts[0], middleName: "", lastName: "" };
|
|
1038
|
+
}
|
|
1039
|
+
if (parts.length === 2) {
|
|
1040
|
+
return { firstName: parts[0], middleName: "", lastName: parts[1] };
|
|
1041
|
+
}
|
|
1042
|
+
if (parts.length === 3) {
|
|
1043
|
+
const firstName2 = parts.slice(0, 2).join(" ");
|
|
1044
|
+
const lastName2 = parts[2];
|
|
1045
|
+
return { firstName: firstName2, middleName: "", lastName: lastName2 };
|
|
1046
|
+
}
|
|
1047
|
+
const firstName = parts.slice(0, 2).join(" ");
|
|
1048
|
+
const lastName = parts[parts.length - 1];
|
|
1049
|
+
const middleName = parts.slice(2, -1).join(" ");
|
|
1050
|
+
return { firstName, middleName, lastName };
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// src/lib/strings/pluralize.js
|
|
1054
|
+
var import_pluralize = __toESM(require("pluralize"), 1);
|
|
1055
|
+
var pluralize = import_pluralize.default;
|
|
1056
|
+
|
|
1057
|
+
// src/lib/strings/query-string.js
|
|
1058
|
+
function toQueryString(object) {
|
|
1059
|
+
const searchParams = new URLSearchParams(object);
|
|
1060
|
+
return searchParams.toString();
|
|
1061
|
+
}
|
|
1062
|
+
function plural(count, noun, suffix = "s") {
|
|
1063
|
+
console.warn("plural is deprecated. Use pluralize instead");
|
|
1064
|
+
return `${count} ${noun}${count !== 1 ? suffix : ""}`;
|
|
1065
|
+
}
|
|
1066
|
+
function stripNumbers(string) {
|
|
1067
|
+
return string.replace(/\d*/, "");
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// src/lib/style/index.js
|
|
1071
|
+
function toStyleString(style) {
|
|
1072
|
+
if (!style) return null;
|
|
1073
|
+
if (typeof style === "string") return style;
|
|
1074
|
+
return Object.entries(style).map(([k, v]) => {
|
|
1075
|
+
if (k.startsWith("--")) return `${k}:${v}`;
|
|
1076
|
+
else return `${toKebab(k)}:${v}`;
|
|
1077
|
+
}).join("; ").concat(";");
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// src/lib/symbols/symbols.js
|
|
1081
|
+
function getSymbol(object, description) {
|
|
1082
|
+
return Object.getOwnPropertySymbols(object).find(
|
|
1083
|
+
(s) => s.description === description
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
function getSymbolValue(object, description) {
|
|
1087
|
+
return object[getSymbol(object, description)];
|
|
1088
|
+
}
|
|
1089
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1090
|
+
0 && (module.exports = {
|
|
1091
|
+
AuthManager,
|
|
1092
|
+
DAYS,
|
|
1093
|
+
MONTHS,
|
|
1094
|
+
RouteManager,
|
|
1095
|
+
camelCaseKeys,
|
|
1096
|
+
compose,
|
|
1097
|
+
composeAsync,
|
|
1098
|
+
concatMix,
|
|
1099
|
+
createMix,
|
|
1100
|
+
createSSE,
|
|
1101
|
+
curry,
|
|
1102
|
+
debounce,
|
|
1103
|
+
delay,
|
|
1104
|
+
extendObject,
|
|
1105
|
+
flattenArrayFields,
|
|
1106
|
+
flattenObject,
|
|
1107
|
+
formDataToObject,
|
|
1108
|
+
getEnv,
|
|
1109
|
+
getNestedProperty,
|
|
1110
|
+
getNestedProperty2,
|
|
1111
|
+
getNestedValue,
|
|
1112
|
+
getSymbol,
|
|
1113
|
+
getSymbolValue,
|
|
1114
|
+
getTimeInMs,
|
|
1115
|
+
getType,
|
|
1116
|
+
isArray,
|
|
1117
|
+
isEmpty,
|
|
1118
|
+
isEqual,
|
|
1119
|
+
isFunction,
|
|
1120
|
+
isHashedValue,
|
|
1121
|
+
isLastItem,
|
|
1122
|
+
isObject,
|
|
1123
|
+
joinWithConjunction,
|
|
1124
|
+
last,
|
|
1125
|
+
lastArrayItem,
|
|
1126
|
+
markdown,
|
|
1127
|
+
mix,
|
|
1128
|
+
ms,
|
|
1129
|
+
normalizeObject,
|
|
1130
|
+
notEmpty,
|
|
1131
|
+
notEqual,
|
|
1132
|
+
notObject,
|
|
1133
|
+
objectForEach,
|
|
1134
|
+
objectMap,
|
|
1135
|
+
omitEmpty,
|
|
1136
|
+
parseFullName,
|
|
1137
|
+
parseJSON,
|
|
1138
|
+
parseSSE,
|
|
1139
|
+
pipe,
|
|
1140
|
+
pipeAsync,
|
|
1141
|
+
plural,
|
|
1142
|
+
pluralize,
|
|
1143
|
+
reject,
|
|
1144
|
+
sanitize,
|
|
1145
|
+
sanitizeArray,
|
|
1146
|
+
sanitizeObject,
|
|
1147
|
+
shuffle,
|
|
1148
|
+
sizeOf,
|
|
1149
|
+
sort,
|
|
1150
|
+
splitArray,
|
|
1151
|
+
splitObject,
|
|
1152
|
+
splitUnit,
|
|
1153
|
+
stripNumbers,
|
|
1154
|
+
throttle,
|
|
1155
|
+
timeout,
|
|
1156
|
+
times,
|
|
1157
|
+
toCamel,
|
|
1158
|
+
toDays,
|
|
1159
|
+
toDegrees,
|
|
1160
|
+
toHours,
|
|
1161
|
+
toKebab,
|
|
1162
|
+
toLower,
|
|
1163
|
+
toMinutes,
|
|
1164
|
+
toPascal,
|
|
1165
|
+
toQueryString,
|
|
1166
|
+
toRadians,
|
|
1167
|
+
toReadableTime,
|
|
1168
|
+
toSeconds,
|
|
1169
|
+
toSentence,
|
|
1170
|
+
toSlug,
|
|
1171
|
+
toStyleString,
|
|
1172
|
+
toTitle,
|
|
1173
|
+
toUpper,
|
|
1174
|
+
toWeeks,
|
|
1175
|
+
treatMarkdownWhitespace,
|
|
1176
|
+
uniqueArray,
|
|
1177
|
+
wait
|
|
1178
|
+
});
|