@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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { lastArrayItem } from './item-position.js'
|
|
2
1
|
/**
|
|
3
2
|
* Joins an array with a conjunction (and/or)
|
|
4
3
|
* @param {Array<string>} array - Array of strings to join
|
|
@@ -9,12 +8,8 @@ import { lastArrayItem } from './item-position.js'
|
|
|
9
8
|
* joinWithConjunction(['a', 'b', 'c']) // 'a, b, and c'
|
|
10
9
|
* joinWithConjunction(['a', 'b'], { conjunction: 'or' }) // 'a or b'
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (array.length === 2) return `${array[0]} ${conjunction} ${array[1]}`
|
|
11
|
+
declare function joinWithConjunction(array: Array<string>, { conjunction }?: {
|
|
12
|
+
conjunction?: string;
|
|
13
|
+
}): string;
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
const rest = array.slice(0, -1)
|
|
19
|
-
return `${rest.join(', ')} ${conjunction} ${lastItem}`
|
|
20
|
-
}
|
|
15
|
+
export { joinWithConjunction };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sorts an array of objects, numbers, or strings without mutating the original array.
|
|
3
|
+
* Supports nested properties, multiple sort keys, and various data types.
|
|
4
|
+
*
|
|
5
|
+
* @template T
|
|
6
|
+
* @param {T[]} array - Array to sort
|
|
7
|
+
* @param {Object} [options] - Sort options
|
|
8
|
+
* @param {string|string[]|null} [options.props=null] - Property or array of properties to sort by. If null, sorts simple arrays
|
|
9
|
+
* @param {boolean} [options.reverse=false] - Whether to sort in reverse order
|
|
10
|
+
* @returns {T[]} New sorted array
|
|
11
|
+
* @example
|
|
12
|
+
* // Sort simple array
|
|
13
|
+
* sort([3, 1, 2]) // [1, 2, 3]
|
|
14
|
+
*
|
|
15
|
+
* // Sort objects by single property
|
|
16
|
+
* sort(users, { props: 'name' })
|
|
17
|
+
*
|
|
18
|
+
* // Sort objects by multiple properties
|
|
19
|
+
* sort(users, { props: ['age', 'name'] })
|
|
20
|
+
*
|
|
21
|
+
* // Sort in reverse order
|
|
22
|
+
* sort(users, { props: 'age', reverse: true })
|
|
23
|
+
*
|
|
24
|
+
* // Sort by nested property
|
|
25
|
+
* sort(users, { props: 'address.city' })
|
|
26
|
+
*/
|
|
27
|
+
declare function sort<T>(array: T[], { props, reverse }?: {
|
|
28
|
+
props?: string | string[] | null;
|
|
29
|
+
reverse?: boolean;
|
|
30
|
+
}): T[];
|
|
31
|
+
|
|
32
|
+
export { sort };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AuthManager, RouteManager } from './route-manager.cjs';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
// Usage ... Probably should use either protected or bypass, not both.
|
|
3
|
+
// Maybe ... glob would be a better for this
|
|
4
|
+
@example
|
|
5
|
+
const config = {
|
|
6
|
+
routeConfig: {
|
|
7
|
+
startsWith: ['/dashboard']
|
|
8
|
+
}
|
|
9
|
+
bypassRoutes: {
|
|
10
|
+
is: ['/'],
|
|
11
|
+
startsWith: ['/fonts', '/auth', '/favicon', '/images'],
|
|
12
|
+
includes: ['/meh'],
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const {isProtectedRoute, isBypassRoute} = AuthManager(config)
|
|
16
|
+
if (!isProtectedRoute(context.url.pathname)) return next() // Handle only protected routes
|
|
17
|
+
if (isBypassRoute(context.url.pathname)) return next() // Bypass all non protected routes
|
|
18
|
+
*/
|
|
19
|
+
declare function RouteManager(config: any): {
|
|
20
|
+
isProtectedRoute(pathname: any): any;
|
|
21
|
+
isBypassRoute(pathname: any): any;
|
|
22
|
+
};
|
|
23
|
+
declare function AuthManager(config: any): {
|
|
24
|
+
isProtectedRoute(pathname: any): any;
|
|
25
|
+
isBypassRoute(pathname: any): any;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { AuthManager, RouteManager };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a plain object (not an array or null)
|
|
3
|
+
* @param {unknown} x - The value to check
|
|
4
|
+
* @returns {boolean} True if the value is a plain object
|
|
5
|
+
* @example
|
|
6
|
+
* isObject({}) // true
|
|
7
|
+
* isObject([]) // false
|
|
8
|
+
* isObject(null) // false
|
|
9
|
+
*/
|
|
10
|
+
declare function isObject(x: unknown): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if a value is an array
|
|
13
|
+
* @param {unknown} x - The value to check
|
|
14
|
+
* @returns {boolean} True if the value is an array
|
|
15
|
+
* @example
|
|
16
|
+
* isArray([]) // true
|
|
17
|
+
* isArray({}) // false
|
|
18
|
+
*/
|
|
19
|
+
declare function isArray(x: unknown): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a value is not a plain object
|
|
22
|
+
* @param {unknown} x - The value to check
|
|
23
|
+
* @returns {boolean} True if the value is not a plain object
|
|
24
|
+
* @example
|
|
25
|
+
* notObject([]) // true
|
|
26
|
+
* notObject(null) // true
|
|
27
|
+
* notObject({}) // false
|
|
28
|
+
*/
|
|
29
|
+
declare function notObject(x: unknown): boolean;
|
|
30
|
+
declare function getType(x: any): "string" | "integer" | "float" | "boolean" | "function" | "undefined" | "symbol" | "bigint" | "array" | "object" | "unknown";
|
|
31
|
+
declare function isFunction(x: any): boolean;
|
|
32
|
+
|
|
33
|
+
export { getType, isArray, isFunction, isObject, notObject };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a time string to milliseconds
|
|
3
|
+
* @param {string} arg - The time string to convert
|
|
4
|
+
* @returns {number}
|
|
5
|
+
*/
|
|
6
|
+
declare function ms(arg: string): number;
|
|
7
|
+
declare function getTimeInMs(value: any, unit?: string): any;
|
|
8
|
+
declare function toWeeks(ms: any): number;
|
|
9
|
+
declare function toDays(ms: any): number;
|
|
10
|
+
declare function toHours(ms: any): number;
|
|
11
|
+
declare function toMinutes(ms: any): number;
|
|
12
|
+
declare function toSeconds(ms: any): number;
|
|
13
|
+
declare function toReadableTime(ms: any): {
|
|
14
|
+
weeks: number;
|
|
15
|
+
days: number;
|
|
16
|
+
hours: number;
|
|
17
|
+
minutes: number;
|
|
18
|
+
seconds: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { getTimeInMs, ms, toDays, toHours, toMinutes, toReadableTime, toSeconds, toWeeks };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts Form Data into an object
|
|
3
|
+
* @param {FormData} formData
|
|
4
|
+
* @returns Object
|
|
5
|
+
*/
|
|
6
|
+
declare function formDataToObject(formData: FormData): {};
|
|
7
|
+
declare function flattenArrayFields(inputObject: any): {};
|
|
8
|
+
|
|
9
|
+
export { flattenArrayFields, formDataToObject };
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* @property {Function} [sanitizer] - Function to sanitize strings
|
|
4
4
|
* @property {*} [additional] - Any additional properties are passed through to the sanitizer function
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Core sanitization function that handles different value types.
|
|
9
8
|
* Throws if no sanitizer function is provided.
|
|
10
9
|
* Any additional properties in options are passed through to the sanitizer function.
|
|
11
|
-
*
|
|
10
|
+
*
|
|
12
11
|
* @param {*} value - The value to sanitize
|
|
13
12
|
* @param {SanitizeOptions} [options={}] - Sanitization options
|
|
14
13
|
* @throws {Error} If sanitizer function is not provided
|
|
@@ -16,65 +15,46 @@
|
|
|
16
15
|
* @example
|
|
17
16
|
* // Basic sanitization
|
|
18
17
|
* sanitize('hello', { sanitizer: str => str.trim() })
|
|
19
|
-
*
|
|
18
|
+
*
|
|
20
19
|
* // With additional options passed to sanitizer
|
|
21
|
-
* sanitize('hello', {
|
|
20
|
+
* sanitize('hello', {
|
|
22
21
|
* sanitizer: (str, length, char) => str.padEnd(length, char),
|
|
23
22
|
* length: 10,
|
|
24
23
|
* char: '-'
|
|
25
24
|
* })
|
|
26
25
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
]),
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
return value
|
|
42
|
-
}
|
|
26
|
+
declare function sanitize(value: any, options?: SanitizeOptions): any;
|
|
27
|
+
type SanitizeOptions = {
|
|
28
|
+
/**
|
|
29
|
+
* - Function to sanitize strings
|
|
30
|
+
*/
|
|
31
|
+
sanitizer?: Function;
|
|
32
|
+
/**
|
|
33
|
+
* - Any additional properties are passed through to the sanitizer function
|
|
34
|
+
*/
|
|
35
|
+
additional?: any;
|
|
36
|
+
};
|
|
43
37
|
/**
|
|
44
38
|
* Sanitizes an array by recursively sanitizing each element.
|
|
45
39
|
* Throws if no sanitizer function is provided.
|
|
46
40
|
* Any additional properties in options are passed through to the sanitizer function.
|
|
47
|
-
*
|
|
41
|
+
*
|
|
48
42
|
* @param {Array} arr - Array to sanitize
|
|
49
43
|
* @param {SanitizeOptions} options - Sanitization options
|
|
50
44
|
* @throws {Error} If sanitizer function is not provided
|
|
51
45
|
* @returns {Array} New array with sanitized values
|
|
52
46
|
*/
|
|
53
|
-
function sanitizeArray(arr, { sanitizer, ...rest })
|
|
54
|
-
if (!sanitizer) throw new Error('sanitizer function is required')
|
|
55
|
-
return arr.map(item => sanitize(item, { sanitizer, ...rest }))
|
|
56
|
-
}
|
|
57
|
-
|
|
47
|
+
declare function sanitizeArray(arr: any[], { sanitizer, ...rest }: SanitizeOptions): any[];
|
|
58
48
|
/**
|
|
59
49
|
* Sanitizes all string values in an object recursively.
|
|
60
50
|
* Throws if no sanitizer function is not provided.
|
|
61
51
|
* Any additional properties in options are passed through to the sanitizer function.
|
|
62
|
-
*
|
|
52
|
+
*
|
|
63
53
|
* @param {Object} obj - Object to sanitize
|
|
64
54
|
* @param {SanitizeOptions} [options={}] - Sanitization options
|
|
65
55
|
* @throws {Error} If sanitizer function is not provided
|
|
66
56
|
* @returns {Object} New object with sanitized values
|
|
67
57
|
*/
|
|
68
|
-
function sanitizeObject(obj, { sanitizer, ...options }
|
|
69
|
-
if (!sanitizer) throw new Error('sanitizer function is required')
|
|
70
|
-
if (Array.isArray(obj)) return sanitizeArray(obj, { sanitizer, ...options })
|
|
71
|
-
|
|
72
|
-
return Object.fromEntries(
|
|
73
|
-
Object.entries(obj).map(([key, value]) => [
|
|
74
|
-
key,
|
|
75
|
-
sanitize(value, { sanitizer, ...options }),
|
|
76
|
-
]),
|
|
77
|
-
)
|
|
78
|
-
}
|
|
58
|
+
declare function sanitizeObject(obj: any, { sanitizer, ...options }?: SanitizeOptions): any;
|
|
79
59
|
|
|
80
|
-
export { sanitizeArray, sanitizeObject }
|
|
60
|
+
export { type SanitizeOptions, sanitize, sanitizeArray, sanitizeObject };
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* @param {Function|*} fn - The potential callback function
|
|
4
4
|
* @param {...*} data - Data arguments to pass to the callback
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
declare function runCallback(fn: Function | any, ...data: any[]): void;
|
|
7
|
+
|
|
8
|
+
export { runCallback };
|
|
@@ -10,18 +10,7 @@
|
|
|
10
10
|
* curriedAdd(1, 2)(3) // 6
|
|
11
11
|
* curriedAdd(1)(2, 3) // 6
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
return function curried(...args) {
|
|
15
|
-
if (args.length >= fn.length) {
|
|
16
|
-
return fn.apply(this, args)
|
|
17
|
-
} else {
|
|
18
|
-
return function (...moreArgs) {
|
|
19
|
-
return curried.apply(this, args.concat(moreArgs))
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
13
|
+
declare function curry(fn: Function): Function;
|
|
25
14
|
/**
|
|
26
15
|
* Composes functions from right to left (synchronous)
|
|
27
16
|
* @param {...Function} fns - Functions to compose
|
|
@@ -33,12 +22,7 @@ export function curry(fn) {
|
|
|
33
22
|
* const composed = compose(add1, multiply2)
|
|
34
23
|
* composed(3) // 7 (3 * 2 + 1)
|
|
35
24
|
*/
|
|
36
|
-
|
|
37
|
-
return function (value) {
|
|
38
|
-
return fns.reduceRight((acc, fn) => fn(acc), value)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
25
|
+
declare function compose(...fns: Function[]): Function;
|
|
42
26
|
/**
|
|
43
27
|
* Composes functions from right to left (asynchronous)
|
|
44
28
|
* @param {...Function} fns - Functions to compose (can be sync or async)
|
|
@@ -49,15 +33,7 @@ export function compose(...fns) {
|
|
|
49
33
|
* const multiplyAsync = async x => x * 2
|
|
50
34
|
* await composeAsync(add1, multiplyAsync)(3) // 7 (3 * 2 + 1)
|
|
51
35
|
*/
|
|
52
|
-
|
|
53
|
-
return async function (value) {
|
|
54
|
-
return fns.reduceRight(async (acc, fn) => {
|
|
55
|
-
const result = await acc
|
|
56
|
-
return await fn(result)
|
|
57
|
-
}, value)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
36
|
+
declare function composeAsync(...fns: Function[]): Function;
|
|
61
37
|
/**
|
|
62
38
|
* Pipes functions from left to right (synchronous)
|
|
63
39
|
* @param {...Function} fns - Functions to pipe
|
|
@@ -69,12 +45,7 @@ export function composeAsync(...fns) {
|
|
|
69
45
|
* const piped = pipe(add1, multiply2)
|
|
70
46
|
* piped(3) // 8 (3 + 1) * 2
|
|
71
47
|
*/
|
|
72
|
-
|
|
73
|
-
return function (value) {
|
|
74
|
-
return fns.reduce((acc, fn) => fn(acc), value)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
48
|
+
declare function pipe(...fns: Function[]): Function;
|
|
78
49
|
/**
|
|
79
50
|
* Pipes functions from left to right (asynchronous)
|
|
80
51
|
* @param {...Function} fns - Functions to pipe (can be sync or async)
|
|
@@ -85,15 +56,7 @@ export function pipe(...fns) {
|
|
|
85
56
|
* const multiplyAsync = async x => x * 2
|
|
86
57
|
* await pipeAsync(add1, multiplyAsync)(3) // 8 ((3 + 1) * 2)
|
|
87
58
|
*/
|
|
88
|
-
|
|
89
|
-
return async function (value) {
|
|
90
|
-
return fns.reduce(async (acc, fn) => {
|
|
91
|
-
const result = await acc
|
|
92
|
-
return await fn(result)
|
|
93
|
-
}, value)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
59
|
+
declare function pipeAsync(...fns: Function[]): Function;
|
|
97
60
|
/**
|
|
98
61
|
* Calls a function n times with the current index and returns an array of results
|
|
99
62
|
* @param {Function} fn - Function to call (receives index as argument)
|
|
@@ -104,10 +67,6 @@ export function pipeAsync(...fns) {
|
|
|
104
67
|
* times(i => i * 2, 3) // [0, 2, 4]
|
|
105
68
|
* times(() => Math.random(), 2) // [0.123, 0.456] (random values)
|
|
106
69
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
result.push(fn(i))
|
|
111
|
-
}
|
|
112
|
-
return result
|
|
113
|
-
}
|
|
70
|
+
declare function times(fn: Function, n: number): any[];
|
|
71
|
+
|
|
72
|
+
export { compose, composeAsync, curry, pipe, pipeAsync, times };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { debounce } from './debounce.cjs';
|
|
2
|
+
export { getEnv } from './env.cjs';
|
|
3
|
+
export { compose, composeAsync, curry, pipe, pipeAsync, times } from './functional.cjs';
|
|
4
|
+
export { throttle } from './throttle.cjs';
|
|
5
|
+
export { delay, timeout, wait } from './timeout.cjs';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export { isLastItem, last, lastArrayItem } from './arrays/item-position.cjs';
|
|
2
|
+
export { joinWithConjunction } from './arrays/join.cjs';
|
|
3
|
+
export { shuffle } from './arrays/shuffle.cjs';
|
|
4
|
+
export { sort } from './arrays/sort.cjs';
|
|
5
|
+
export { splitArray } from './arrays/split-array.cjs';
|
|
6
|
+
export { uniqueArray } from './arrays/unique.cjs';
|
|
7
|
+
export { AuthManager, RouteManager } from './auth/route-manager.cjs';
|
|
8
|
+
export { getType, isArray, isFunction, isObject, notObject } from './checks.cjs';
|
|
9
|
+
export { DAYS } from './date/days.cjs';
|
|
10
|
+
export { MONTHS } from './date/months.cjs';
|
|
11
|
+
export { getTimeInMs, ms, toDays, toHours, toMinutes, toReadableTime, toSeconds, toWeeks } from './date/time.cjs';
|
|
12
|
+
export { flattenArrayFields, formDataToObject } from './form/form-data.cjs';
|
|
13
|
+
export { SanitizeOptions, sanitize, sanitizeArray, sanitizeObject } from './form/sanitize.cjs';
|
|
14
|
+
export { debounce } from './functions/debounce.cjs';
|
|
15
|
+
export { getEnv } from './functions/env.cjs';
|
|
16
|
+
export { compose, composeAsync, curry, pipe, pipeAsync, times } from './functions/functional.cjs';
|
|
17
|
+
export { throttle } from './functions/throttle.cjs';
|
|
18
|
+
export { delay, timeout, wait } from './functions/timeout.cjs';
|
|
19
|
+
export { isHashedValue } from './hash.cjs';
|
|
20
|
+
export { splitUnit } from './numbers/index.cjs';
|
|
21
|
+
export { camelCaseKeys } from './objects/camelcase-keys.cjs';
|
|
22
|
+
export { isEmpty, notEmpty } from './objects/empty.cjs';
|
|
23
|
+
export { isEqual, notEqual } from './objects/equal.cjs';
|
|
24
|
+
export { extendObject } from './objects/extend.cjs';
|
|
25
|
+
export { flattenObject } from './objects/flatten.cjs';
|
|
26
|
+
export { parseJSON } from './objects/json.cjs';
|
|
27
|
+
export { objectForEach, objectMap } from './objects/loop.cjs';
|
|
28
|
+
export { concatMix, createMix, mix } from './objects/mix/mix.cjs';
|
|
29
|
+
export { getNestedProperty, getNestedProperty2, getNestedValue } from './objects/nested-property.cjs';
|
|
30
|
+
export { normalizeObject } from './objects/normalize-object.cjs';
|
|
31
|
+
export { omitEmpty } from './objects/omit-empty.cjs';
|
|
32
|
+
export { sizeOf } from './objects/size.cjs';
|
|
33
|
+
export { splitObject } from './objects/split.cjs';
|
|
34
|
+
export { reject } from './promises/reject.cjs';
|
|
35
|
+
export { createSSE, parseSSE } from './sse.cjs';
|
|
36
|
+
export { toCamel, toKebab, toLower, toPascal, toSentence, toSlug, toTitle, toUpper } from './strings/convert-case/convert-case.cjs';
|
|
37
|
+
export { markdown, treatMarkdownWhitespace } from './strings/markdown.cjs';
|
|
38
|
+
export { parseFullName } from './strings/name.cjs';
|
|
39
|
+
export { pluralize } from './strings/pluralize.cjs';
|
|
40
|
+
export { plural, stripNumbers, toQueryString } from './strings/query-string.cjs';
|
|
41
|
+
export { toStyleString } from './style/index.cjs';
|
|
42
|
+
export { getSymbol, getSymbolValue } from './symbols/symbols.cjs';
|
|
43
|
+
export { toDegrees, toRadians } from './numbers/math.cjs';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { camelCaseKeys } from './camelcase-keys.cjs';
|
|
2
|
+
export { isEmpty, notEmpty } from './empty.cjs';
|
|
3
|
+
export { isEqual, notEqual } from './equal.cjs';
|
|
4
|
+
export { extendObject } from './extend.cjs';
|
|
5
|
+
export { flattenObject } from './flatten.cjs';
|
|
6
|
+
export { parseJSON } from './json.cjs';
|
|
7
|
+
export { objectForEach, objectMap } from './loop.cjs';
|
|
8
|
+
export { concatMix, createMix, mix } from './mix/mix.cjs';
|
|
9
|
+
export { getNestedProperty, getNestedProperty2, getNestedValue } from './nested-property.cjs';
|
|
10
|
+
export { normalizeObject } from './normalize-object.cjs';
|
|
11
|
+
export { omitEmpty } from './omit-empty.cjs';
|
|
12
|
+
export { sizeOf } from './size.cjs';
|
|
13
|
+
export { splitObject } from './split.cjs';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a customized mix function with specific options for array handling.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} [userOptions={}] - Configuration options for the mix function.
|
|
5
|
+
* @param {('replace'|'concat')} [userOptions.array='replace'] - How to handle array merging:
|
|
6
|
+
* - 'replace': Arrays from later sources completely replace arrays from earlier sources
|
|
7
|
+
* - 'concat': Arrays are concatenated together
|
|
8
|
+
* @return {Function} A mix function configured with the provided options.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Create mix function that concatenates arrays
|
|
12
|
+
* const concatMix = createMix({ array: 'concat' })
|
|
13
|
+
* const obj1 = { items: [1, 2] }
|
|
14
|
+
* const obj2 = { items: [3, 4] }
|
|
15
|
+
* const result = concatMix(obj1, obj2)
|
|
16
|
+
* // Returns: { items: [1, 2, 3, 4] }
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create mix function that replaces arrays (default behavior)
|
|
20
|
+
* const replaceMix = createMix({ array: 'replace' })
|
|
21
|
+
* const obj1 = { items: [1, 2] }
|
|
22
|
+
* const obj2 = { items: [3, 4] }
|
|
23
|
+
* const result = replaceMix(obj1, obj2)
|
|
24
|
+
* // Returns: { items: [3, 4] }
|
|
25
|
+
*/
|
|
26
|
+
declare function createMix(userOptions?: {
|
|
27
|
+
array?: ("replace" | "concat");
|
|
28
|
+
}): Function;
|
|
29
|
+
/**
|
|
30
|
+
* Deep merges multiple objects into a new object with intelligent handling of arrays and nested objects.
|
|
31
|
+
*
|
|
32
|
+
* @param {...Object} sources - Objects to merge. Null and undefined values are skipped.
|
|
33
|
+
* @return {Object} A new object containing the merged properties from all sources.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const obj1 = { a: 1, b: { x: 10 } }
|
|
37
|
+
* const obj2 = { b: { y: 20 }, c: 3 }
|
|
38
|
+
* const result = mix(obj1, obj2)
|
|
39
|
+
* // Returns: { a: 1, b: { x: 10, y: 20 }, c: 3 }
|
|
40
|
+
*/
|
|
41
|
+
declare const mix: Function;
|
|
42
|
+
declare const concatMix: Function;
|
|
43
|
+
|
|
44
|
+
export { concatMix, createMix, mix };
|
|
@@ -17,25 +17,8 @@
|
|
|
17
17
|
* let path = ['one', 'two', 'three'];
|
|
18
18
|
* console.log(getNestedProperty(object, path)); // Outputs: "value"
|
|
19
19
|
*/
|
|
20
|
+
declare function getNestedProperty(object: any, pathArr: any[]): any;
|
|
21
|
+
declare function getNestedProperty2(object: any, path: any): any;
|
|
22
|
+
declare function getNestedValue(object: any, path: any): any;
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
export function getNestedProperty(object, pathArr) {
|
|
23
|
-
return pathArr.reduce(
|
|
24
|
-
(nestedObject, key) =>
|
|
25
|
-
nestedObject && nestedObject[key] !== 'undefined'
|
|
26
|
-
? nestedObject[key]
|
|
27
|
-
: undefined,
|
|
28
|
-
object,
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Dot syntax
|
|
33
|
-
export function getNestedProperty2(object, path) {
|
|
34
|
-
const pathArray = path.split('.')
|
|
35
|
-
return getNestedProperty(object, pathArray)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Same as dot syntax, but terser and more readable name
|
|
39
|
-
export function getNestedValue(object, path) {
|
|
40
|
-
return path.split('.').reduce((acc, part) => acc?.[part], object)
|
|
41
|
-
}
|
|
24
|
+
export { getNestedProperty, getNestedProperty2, getNestedValue };
|