@stryke/helpers 0.9.26 → 0.9.28
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/CHANGELOG.md +16 -0
- package/dist/arg-identity.cjs +1 -1
- package/dist/arg-identity.d.cts +14 -2
- package/dist/arg-identity.d.cts.map +1 -0
- package/dist/arg-identity.d.mts +14 -2
- package/dist/arg-identity.d.mts.map +1 -0
- package/dist/arg-identity.mjs +2 -1
- package/dist/arg-identity.mjs.map +1 -0
- package/dist/convert/src/to-string-key.cjs +1 -0
- package/dist/convert/src/to-string-key.mjs +2 -0
- package/dist/convert/src/to-string-key.mjs.map +1 -0
- package/dist/debounce.cjs +1 -1
- package/dist/debounce.d.cts +47 -2
- package/dist/debounce.d.cts.map +1 -0
- package/dist/debounce.d.mts +47 -2
- package/dist/debounce.d.mts.map +1 -0
- package/dist/debounce.mjs +2 -1
- package/dist/debounce.mjs.map +1 -0
- package/dist/deep-clone.cjs +1 -1
- package/dist/deep-clone.d.cts +65 -2
- package/dist/deep-clone.d.cts.map +1 -0
- package/dist/deep-clone.d.mts +65 -2
- package/dist/deep-clone.d.mts.map +1 -0
- package/dist/deep-clone.mjs +2 -1
- package/dist/deep-clone.mjs.map +1 -0
- package/dist/deep-merge.cjs +1 -1
- package/dist/deep-merge.d.cts +26 -2
- package/dist/deep-merge.d.cts.map +1 -0
- package/dist/deep-merge.d.mts +26 -2
- package/dist/deep-merge.d.mts.map +1 -0
- package/dist/deep-merge.mjs +2 -1
- package/dist/deep-merge.mjs.map +1 -0
- package/dist/delay.cjs +1 -1
- package/dist/delay.d.cts +77 -2
- package/dist/delay.d.cts.map +1 -0
- package/dist/delay.d.mts +77 -2
- package/dist/delay.d.mts.map +1 -0
- package/dist/delay.mjs +2 -1
- package/dist/delay.mjs.map +1 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.mjs +2 -1
- package/dist/errors.mjs.map +1 -0
- package/dist/filter-empty.cjs +1 -1
- package/dist/filter-empty.d.cts +5 -2
- package/dist/filter-empty.d.cts.map +1 -0
- package/dist/filter-empty.d.mts +5 -2
- package/dist/filter-empty.d.mts.map +1 -0
- package/dist/filter-empty.mjs +2 -1
- package/dist/filter-empty.mjs.map +1 -0
- package/dist/flatten-object.cjs +1 -1
- package/dist/flatten-object.d.cts +35 -2
- package/dist/flatten-object.d.cts.map +1 -0
- package/dist/flatten-object.d.mts +35 -2
- package/dist/flatten-object.d.mts.map +1 -0
- package/dist/flatten-object.mjs +2 -1
- package/dist/flatten-object.mjs.map +1 -0
- package/dist/get-field.cjs +1 -1
- package/dist/get-field.d.cts +254 -2
- package/dist/get-field.d.cts.map +1 -0
- package/dist/get-field.d.mts +254 -2
- package/dist/get-field.d.mts.map +1 -0
- package/dist/get-field.mjs +2 -1
- package/dist/get-field.mjs.map +1 -0
- package/dist/get-ordered-by.cjs +1 -1
- package/dist/get-ordered-by.d.cts +39 -2
- package/dist/get-ordered-by.d.cts.map +1 -0
- package/dist/get-ordered-by.d.mts +39 -2
- package/dist/get-ordered-by.d.mts.map +1 -0
- package/dist/get-ordered-by.mjs +2 -1
- package/dist/get-ordered-by.mjs.map +1 -0
- package/dist/get-unique.cjs +1 -1
- package/dist/get-unique.d.cts +26 -2
- package/dist/get-unique.d.cts.map +1 -0
- package/dist/get-unique.d.mts +26 -2
- package/dist/get-unique.d.mts.map +1 -0
- package/dist/get-unique.mjs +2 -1
- package/dist/get-unique.mjs.map +1 -0
- package/dist/identity.cjs +1 -1
- package/dist/identity.d.cts +18 -2
- package/dist/identity.d.cts.map +1 -0
- package/dist/identity.d.mts +18 -2
- package/dist/identity.d.mts.map +1 -0
- package/dist/identity.mjs +2 -1
- package/dist/identity.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +31 -31
- package/dist/index.d.mts +31 -31
- package/dist/index.mjs +1 -1
- package/dist/is-equal.cjs +1 -1
- package/dist/is-equal.d.cts +22 -2
- package/dist/is-equal.d.cts.map +1 -0
- package/dist/is-equal.d.mts +22 -2
- package/dist/is-equal.d.mts.map +1 -0
- package/dist/is-equal.mjs +2 -1
- package/dist/is-equal.mjs.map +1 -0
- package/dist/lru-cache.cjs +1 -1
- package/dist/lru-cache.d.cts +103 -2
- package/dist/lru-cache.d.cts.map +1 -0
- package/dist/lru-cache.d.mts +103 -2
- package/dist/lru-cache.d.mts.map +1 -0
- package/dist/lru-cache.mjs +2 -1
- package/dist/lru-cache.mjs.map +1 -0
- package/dist/match-sorter.cjs +1 -1
- package/dist/match-sorter.d.cts +78 -2
- package/dist/match-sorter.d.cts.map +1 -0
- package/dist/match-sorter.d.mts +78 -2
- package/dist/match-sorter.d.mts.map +1 -0
- package/dist/match-sorter.mjs +2 -1
- package/dist/match-sorter.mjs.map +1 -0
- package/dist/memoize.cjs +1 -1
- package/dist/memoize.d.cts +11 -2
- package/dist/memoize.d.cts.map +1 -0
- package/dist/memoize.d.mts +11 -2
- package/dist/memoize.d.mts.map +1 -0
- package/dist/memoize.mjs +2 -1
- package/dist/memoize.mjs.map +1 -0
- package/dist/mutex.cjs +1 -1
- package/dist/mutex.d.cts +72 -2
- package/dist/mutex.d.cts.map +1 -0
- package/dist/mutex.d.mts +72 -2
- package/dist/mutex.d.mts.map +1 -0
- package/dist/mutex.mjs +2 -1
- package/dist/mutex.mjs.map +1 -0
- package/dist/noop.cjs +1 -1
- package/dist/noop.d.cts +22 -2
- package/dist/noop.d.cts.map +1 -0
- package/dist/noop.d.mts +22 -2
- package/dist/noop.d.mts.map +1 -0
- package/dist/noop.mjs +2 -1
- package/dist/noop.mjs.map +1 -0
- package/dist/omit.cjs +1 -1
- package/dist/omit.d.cts +22 -2
- package/dist/omit.d.cts.map +1 -0
- package/dist/omit.d.mts +22 -2
- package/dist/omit.d.mts.map +1 -0
- package/dist/omit.mjs +2 -1
- package/dist/omit.mjs.map +1 -0
- package/dist/once.cjs +1 -1
- package/dist/once.d.cts +13 -2
- package/dist/once.d.cts.map +1 -0
- package/dist/once.d.mts +13 -2
- package/dist/once.d.mts.map +1 -0
- package/dist/once.mjs +2 -1
- package/dist/once.mjs.map +1 -0
- package/dist/pick.cjs +1 -1
- package/dist/pick.d.cts +22 -2
- package/dist/pick.d.cts.map +1 -0
- package/dist/pick.d.mts +22 -2
- package/dist/pick.d.mts.map +1 -0
- package/dist/pick.mjs +2 -1
- package/dist/pick.mjs.map +1 -0
- package/dist/remove-accents.cjs +1 -1
- package/dist/remove-accents.d.cts +12 -2
- package/dist/remove-accents.d.cts.map +1 -0
- package/dist/remove-accents.d.mts +12 -2
- package/dist/remove-accents.d.mts.map +1 -0
- package/dist/remove-accents.mjs +2 -1
- package/dist/remove-accents.mjs.map +1 -0
- package/dist/remove-empty-items.cjs +1 -1
- package/dist/remove-empty-items.d.cts +11 -2
- package/dist/remove-empty-items.d.cts.map +1 -0
- package/dist/remove-empty-items.d.mts +11 -2
- package/dist/remove-empty-items.d.mts.map +1 -0
- package/dist/remove-empty-items.mjs +2 -1
- package/dist/remove-empty-items.mjs.map +1 -0
- package/dist/semaphore.cjs +1 -1
- package/dist/semaphore.d.cts +86 -2
- package/dist/semaphore.d.cts.map +1 -0
- package/dist/semaphore.d.mts +86 -2
- package/dist/semaphore.d.mts.map +1 -0
- package/dist/semaphore.mjs +2 -1
- package/dist/semaphore.mjs.map +1 -0
- package/dist/set-field.cjs +1 -1
- package/dist/set-field.d.cts +16 -2
- package/dist/set-field.d.cts.map +1 -0
- package/dist/set-field.d.mts +16 -2
- package/dist/set-field.d.mts.map +1 -0
- package/dist/set-field.mjs +2 -1
- package/dist/set-field.mjs.map +1 -0
- package/dist/throttle.cjs +1 -1
- package/dist/throttle.d.cts +32 -2
- package/dist/throttle.d.cts.map +1 -0
- package/dist/throttle.d.mts +32 -2
- package/dist/throttle.d.mts.map +1 -0
- package/dist/throttle.mjs +2 -1
- package/dist/throttle.mjs.map +1 -0
- package/dist/timeout.cjs +1 -1
- package/dist/timeout.d.cts +12 -2
- package/dist/timeout.d.cts.map +1 -0
- package/dist/timeout.d.mts +12 -2
- package/dist/timeout.d.mts.map +1 -0
- package/dist/timeout.mjs +2 -1
- package/dist/timeout.mjs.map +1 -0
- package/dist/to-deep-key.cjs +1 -1
- package/dist/to-deep-key.d.cts +42 -2
- package/dist/to-deep-key.d.cts.map +1 -0
- package/dist/to-deep-key.d.mts +42 -2
- package/dist/to-deep-key.d.mts.map +1 -0
- package/dist/to-deep-key.mjs +2 -1
- package/dist/to-deep-key.mjs.map +1 -0
- package/dist/to-path.cjs +1 -1
- package/dist/to-path.d.cts +24 -2
- package/dist/to-path.d.cts.map +1 -0
- package/dist/to-path.d.mts +24 -2
- package/dist/to-path.d.mts.map +1 -0
- package/dist/to-path.mjs +2 -1
- package/dist/to-path.mjs.map +1 -0
- package/dist/type-checks/src/get-object-tag.cjs +1 -0
- package/dist/type-checks/src/get-object-tag.mjs +2 -0
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
- package/dist/type-checks/src/is-deep-key.cjs +1 -0
- package/dist/type-checks/src/is-deep-key.mjs +2 -0
- package/dist/type-checks/src/is-deep-key.mjs.map +1 -0
- package/dist/type-checks/src/is-empty.cjs +1 -0
- package/dist/type-checks/src/is-empty.mjs +2 -0
- package/dist/type-checks/src/is-empty.mjs.map +1 -0
- package/dist/type-checks/src/is-function.cjs +1 -0
- package/dist/type-checks/src/is-function.mjs +2 -0
- package/dist/type-checks/src/is-function.mjs.map +1 -0
- package/dist/type-checks/src/is-mergeable-object.cjs +1 -0
- package/dist/type-checks/src/is-mergeable-object.mjs +2 -0
- package/dist/type-checks/src/is-mergeable-object.mjs.map +1 -0
- package/dist/type-checks/src/is-non-null-object.cjs +1 -0
- package/dist/type-checks/src/is-non-null-object.mjs +2 -0
- package/dist/type-checks/src/is-non-null-object.mjs.map +1 -0
- package/dist/type-checks/src/is-null.cjs +1 -0
- package/dist/type-checks/src/is-null.mjs +2 -0
- package/dist/type-checks/src/is-null.mjs.map +1 -0
- package/dist/type-checks/src/is-number.cjs +1 -0
- package/dist/type-checks/src/is-number.mjs +2 -0
- package/dist/type-checks/src/is-number.mjs.map +1 -0
- package/dist/type-checks/src/is-object-index.cjs +1 -0
- package/dist/type-checks/src/is-object-index.mjs +2 -0
- package/dist/type-checks/src/is-object-index.mjs.map +1 -0
- package/dist/type-checks/src/is-object.cjs +1 -0
- package/dist/type-checks/src/is-object.mjs +2 -0
- package/dist/type-checks/src/is-object.mjs.map +1 -0
- package/dist/type-checks/src/is-plain-object.cjs +1 -0
- package/dist/type-checks/src/is-plain-object.mjs +2 -0
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
- package/dist/type-checks/src/is-primitive.cjs +1 -0
- package/dist/type-checks/src/is-primitive.mjs +2 -0
- package/dist/type-checks/src/is-primitive.mjs.map +1 -0
- package/dist/type-checks/src/is-react-element.cjs +1 -0
- package/dist/type-checks/src/is-react-element.mjs +2 -0
- package/dist/type-checks/src/is-react-element.mjs.map +1 -0
- package/dist/type-checks/src/is-set-string.cjs +1 -0
- package/dist/type-checks/src/is-set-string.mjs +2 -0
- package/dist/type-checks/src/is-set-string.mjs.map +1 -0
- package/dist/type-checks/src/is-set.cjs +1 -0
- package/dist/type-checks/src/is-set.mjs +2 -0
- package/dist/type-checks/src/is-set.mjs.map +1 -0
- package/dist/{is-string-CvmuuuDj.mjs → type-checks/src/is-string.cjs} +1 -2
- package/dist/type-checks/src/is-string.mjs +2 -0
- package/dist/type-checks/src/is-string.mjs.map +1 -0
- package/dist/type-checks/src/is-typed-array.cjs +1 -0
- package/dist/type-checks/src/is-typed-array.mjs +2 -0
- package/dist/type-checks/src/is-typed-array.mjs.map +1 -0
- package/dist/type-checks/src/is-undefined.cjs +1 -0
- package/dist/type-checks/src/is-undefined.mjs +2 -0
- package/dist/type-checks/src/is-undefined.mjs.map +1 -0
- package/dist/type-checks/src/property-exists.cjs +1 -0
- package/dist/type-checks/src/property-exists.mjs +2 -0
- package/dist/type-checks/src/property-exists.mjs.map +1 -0
- package/dist/types/src/base.d.cts +6 -0
- package/dist/types/src/base.d.cts.map +1 -0
- package/dist/types/src/base.d.mts +6 -0
- package/dist/types/src/base.d.mts.map +1 -0
- package/dist/types/src/json.d.cts +28 -0
- package/dist/types/src/json.d.cts.map +1 -0
- package/dist/types/src/json.d.mts +28 -0
- package/dist/types/src/json.d.mts.map +1 -0
- package/dist/{object-CHmrmQna.d.mts → types/src/object.d.cts} +6 -40
- package/dist/types/src/object.d.cts.map +1 -0
- package/dist/{object-D8HGAGMr.d.cts → types/src/object.d.mts} +6 -40
- package/dist/types/src/object.d.mts.map +1 -0
- package/dist/types/src/string.d.cts +6 -0
- package/dist/types/src/string.d.cts.map +1 -0
- package/dist/types/src/string.d.mts +6 -0
- package/dist/types/src/string.d.mts.map +1 -0
- package/dist/types/src/utilities.d.cts +7 -0
- package/dist/types/src/utilities.d.cts.map +1 -0
- package/dist/types/src/utilities.d.mts +7 -0
- package/dist/types/src/utilities.d.mts.map +1 -0
- package/dist/unflatten-object.cjs +1 -1
- package/dist/unflatten-object.d.cts +35 -2
- package/dist/unflatten-object.d.cts.map +1 -0
- package/dist/unflatten-object.d.mts +35 -2
- package/dist/unflatten-object.d.mts.map +1 -0
- package/dist/unflatten-object.mjs +2 -1
- package/dist/unflatten-object.mjs.map +1 -0
- package/dist/union.cjs +1 -1
- package/dist/union.d.cts +24 -2
- package/dist/union.d.cts.map +1 -0
- package/dist/union.d.mts +24 -2
- package/dist/union.d.mts.map +1 -0
- package/dist/union.mjs +2 -1
- package/dist/union.mjs.map +1 -0
- package/dist/with-timeout.cjs +1 -1
- package/dist/with-timeout.d.cts +24 -2
- package/dist/with-timeout.d.cts.map +1 -0
- package/dist/with-timeout.d.mts +24 -2
- package/dist/with-timeout.d.mts.map +1 -0
- package/dist/with-timeout.mjs +2 -1
- package/dist/with-timeout.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/arg-identity-BIir8uzO.d.mts +0 -14
- package/dist/arg-identity-BIir8uzO.d.mts.map +0 -1
- package/dist/arg-identity-BfviduMt.mjs +0 -2
- package/dist/arg-identity-BfviduMt.mjs.map +0 -1
- package/dist/arg-identity-C-pVjd0u.d.cts +0 -14
- package/dist/arg-identity-C-pVjd0u.d.cts.map +0 -1
- package/dist/arg-identity-dlKw6BsD.cjs +0 -1
- package/dist/debounce-C5O3IDKy.mjs +0 -2
- package/dist/debounce-C5O3IDKy.mjs.map +0 -1
- package/dist/debounce-CIMf8-Yr.d.mts +0 -47
- package/dist/debounce-CIMf8-Yr.d.mts.map +0 -1
- package/dist/debounce-CLb-VvJv.d.cts +0 -47
- package/dist/debounce-CLb-VvJv.d.cts.map +0 -1
- package/dist/debounce-SIYbhEOF.cjs +0 -1
- package/dist/deep-clone-BlN5QTtW.mjs +0 -2
- package/dist/deep-clone-BlN5QTtW.mjs.map +0 -1
- package/dist/deep-clone-CoUy-Hrt.cjs +0 -1
- package/dist/deep-clone-CpLJcTgz.d.mts +0 -65
- package/dist/deep-clone-CpLJcTgz.d.mts.map +0 -1
- package/dist/deep-clone-jRNy1xoj.d.cts +0 -65
- package/dist/deep-clone-jRNy1xoj.d.cts.map +0 -1
- package/dist/deep-merge-BDZ6c79O.mjs +0 -2
- package/dist/deep-merge-BDZ6c79O.mjs.map +0 -1
- package/dist/deep-merge-BpFjvumi.cjs +0 -1
- package/dist/deep-merge-C9qDSleg.d.cts +0 -26
- package/dist/deep-merge-C9qDSleg.d.cts.map +0 -1
- package/dist/deep-merge-eCT712Cv.d.mts +0 -26
- package/dist/deep-merge-eCT712Cv.d.mts.map +0 -1
- package/dist/delay-Bd_sGzMj.d.mts +0 -77
- package/dist/delay-Bd_sGzMj.d.mts.map +0 -1
- package/dist/delay-UwR_fCwt.cjs +0 -1
- package/dist/delay-VkcrQf1l.d.cts +0 -77
- package/dist/delay-VkcrQf1l.d.cts.map +0 -1
- package/dist/delay-wdNbY6sk.mjs +0 -2
- package/dist/delay-wdNbY6sk.mjs.map +0 -1
- package/dist/errors-BXYY8wXj.cjs +0 -1
- package/dist/errors-DWX9ET_b.mjs +0 -2
- package/dist/errors-DWX9ET_b.mjs.map +0 -1
- package/dist/filter-empty-5_nMg04e.cjs +0 -1
- package/dist/filter-empty-BMtd0K07.d.mts +0 -5
- package/dist/filter-empty-BMtd0K07.d.mts.map +0 -1
- package/dist/filter-empty-C2fq9M7o.d.cts +0 -5
- package/dist/filter-empty-C2fq9M7o.d.cts.map +0 -1
- package/dist/filter-empty-Dsc1ymCj.mjs +0 -2
- package/dist/filter-empty-Dsc1ymCj.mjs.map +0 -1
- package/dist/flatten-object-Bk2VT-b2.d.mts +0 -35
- package/dist/flatten-object-Bk2VT-b2.d.mts.map +0 -1
- package/dist/flatten-object-D-EbEZqR.cjs +0 -1
- package/dist/flatten-object-DFCZmly9.mjs +0 -2
- package/dist/flatten-object-DFCZmly9.mjs.map +0 -1
- package/dist/flatten-object-DjaJJaY0.d.cts +0 -35
- package/dist/flatten-object-DjaJJaY0.d.cts.map +0 -1
- package/dist/get-field-5XqtknPs.d.mts +0 -254
- package/dist/get-field-5XqtknPs.d.mts.map +0 -1
- package/dist/get-field-D4F_p-Ov.cjs +0 -1
- package/dist/get-field-ngQ9O38X.mjs +0 -2
- package/dist/get-field-ngQ9O38X.mjs.map +0 -1
- package/dist/get-field-oltWWNRO.d.cts +0 -254
- package/dist/get-field-oltWWNRO.d.cts.map +0 -1
- package/dist/get-object-tag-D53RvMgo.cjs +0 -1
- package/dist/get-object-tag-oBoWkttN.mjs +0 -2
- package/dist/get-object-tag-oBoWkttN.mjs.map +0 -1
- package/dist/get-ordered-by-C45FfW2T.d.mts +0 -39
- package/dist/get-ordered-by-C45FfW2T.d.mts.map +0 -1
- package/dist/get-ordered-by-CBKKJr4R.mjs +0 -2
- package/dist/get-ordered-by-CBKKJr4R.mjs.map +0 -1
- package/dist/get-ordered-by-D2Sr6vUN.cjs +0 -1
- package/dist/get-ordered-by-DuD7QRma.d.cts +0 -39
- package/dist/get-ordered-by-DuD7QRma.d.cts.map +0 -1
- package/dist/get-unique-BOiakY6A.cjs +0 -1
- package/dist/get-unique-C0SBPUBv.d.cts +0 -26
- package/dist/get-unique-C0SBPUBv.d.cts.map +0 -1
- package/dist/get-unique-DZ6E1Kvc.d.mts +0 -26
- package/dist/get-unique-DZ6E1Kvc.d.mts.map +0 -1
- package/dist/get-unique-DzZ7Z34U.mjs +0 -2
- package/dist/get-unique-DzZ7Z34U.mjs.map +0 -1
- package/dist/identity-B_cGeF8o.d.mts +0 -18
- package/dist/identity-B_cGeF8o.d.mts.map +0 -1
- package/dist/identity-DBwwvmGU.mjs +0 -2
- package/dist/identity-DBwwvmGU.mjs.map +0 -1
- package/dist/identity-DRhIvbPG.d.cts +0 -18
- package/dist/identity-DRhIvbPG.d.cts.map +0 -1
- package/dist/identity-z2xaIqpe.cjs +0 -1
- package/dist/is-empty-C7vlSVFD.mjs +0 -2
- package/dist/is-empty-C7vlSVFD.mjs.map +0 -1
- package/dist/is-empty-DZZDqzjD.cjs +0 -1
- package/dist/is-equal-0Z-K2uIG.mjs +0 -2
- package/dist/is-equal-0Z-K2uIG.mjs.map +0 -1
- package/dist/is-equal-BJgVhUVS.cjs +0 -1
- package/dist/is-equal-BMlMHlVi.d.cts +0 -22
- package/dist/is-equal-BMlMHlVi.d.cts.map +0 -1
- package/dist/is-equal-Baqurdpn.d.mts +0 -22
- package/dist/is-equal-Baqurdpn.d.mts.map +0 -1
- package/dist/is-number-BcjxCzDM.cjs +0 -1
- package/dist/is-number-bwhfkHlC.mjs +0 -2
- package/dist/is-number-bwhfkHlC.mjs.map +0 -1
- package/dist/is-plain-object-BQuFhL4M.cjs +0 -1
- package/dist/is-plain-object-D8GSMOhY.mjs +0 -2
- package/dist/is-plain-object-D8GSMOhY.mjs.map +0 -1
- package/dist/is-set-B9o0NIT4.mjs +0 -2
- package/dist/is-set-B9o0NIT4.mjs.map +0 -1
- package/dist/is-set-ByJOY6h2.cjs +0 -1
- package/dist/is-set-string-48_jZFw0.cjs +0 -1
- package/dist/is-set-string-Dr1MlMk0.mjs +0 -2
- package/dist/is-set-string-Dr1MlMk0.mjs.map +0 -1
- package/dist/is-string-CvmuuuDj.mjs.map +0 -1
- package/dist/is-string-DPanLeA_.cjs +0 -1
- package/dist/lru-cache-CzQ_kKXk.d.mts +0 -103
- package/dist/lru-cache-CzQ_kKXk.d.mts.map +0 -1
- package/dist/lru-cache-D4VEIgtR.d.cts +0 -103
- package/dist/lru-cache-D4VEIgtR.d.cts.map +0 -1
- package/dist/lru-cache-DLY_yZRN.mjs +0 -2
- package/dist/lru-cache-DLY_yZRN.mjs.map +0 -1
- package/dist/lru-cache-DgTSGx5W.cjs +0 -1
- package/dist/match-sorter-B9_7YvTo.mjs +0 -2
- package/dist/match-sorter-B9_7YvTo.mjs.map +0 -1
- package/dist/match-sorter-BjnWjkKu.cjs +0 -1
- package/dist/match-sorter-CMYN3GuY.d.cts +0 -78
- package/dist/match-sorter-CMYN3GuY.d.cts.map +0 -1
- package/dist/match-sorter-DCRerxVe.d.mts +0 -78
- package/dist/match-sorter-DCRerxVe.d.mts.map +0 -1
- package/dist/memoize-Cr5jFKxi.mjs +0 -2
- package/dist/memoize-Cr5jFKxi.mjs.map +0 -1
- package/dist/memoize-TyrmWrfR.d.mts +0 -11
- package/dist/memoize-TyrmWrfR.d.mts.map +0 -1
- package/dist/memoize-qxvbI-0y.cjs +0 -1
- package/dist/memoize-tSTYY522.d.cts +0 -11
- package/dist/memoize-tSTYY522.d.cts.map +0 -1
- package/dist/mutex-CnQQBndt.cjs +0 -1
- package/dist/mutex-DAZduiSP.d.mts +0 -72
- package/dist/mutex-DAZduiSP.d.mts.map +0 -1
- package/dist/mutex-DCyX7B66.d.cts +0 -72
- package/dist/mutex-DCyX7B66.d.cts.map +0 -1
- package/dist/mutex-TqoKHosg.mjs +0 -2
- package/dist/mutex-TqoKHosg.mjs.map +0 -1
- package/dist/noop-B7OetrhD.mjs +0 -2
- package/dist/noop-B7OetrhD.mjs.map +0 -1
- package/dist/noop-BnXKMH6Z.d.mts +0 -22
- package/dist/noop-BnXKMH6Z.d.mts.map +0 -1
- package/dist/noop-CnJXOCpF.d.cts +0 -22
- package/dist/noop-CnJXOCpF.d.cts.map +0 -1
- package/dist/noop-Dpf7hIui.cjs +0 -1
- package/dist/object-CHmrmQna.d.mts.map +0 -1
- package/dist/object-D8HGAGMr.d.cts.map +0 -1
- package/dist/omit-A0uVyAS4.cjs +0 -1
- package/dist/omit-BROsDK0D.mjs +0 -2
- package/dist/omit-BROsDK0D.mjs.map +0 -1
- package/dist/omit-D1FKiOYz.d.cts +0 -22
- package/dist/omit-D1FKiOYz.d.cts.map +0 -1
- package/dist/omit-DpqOAtKt.d.mts +0 -22
- package/dist/omit-DpqOAtKt.d.mts.map +0 -1
- package/dist/once-DNPPQd3P.d.mts +0 -13
- package/dist/once-DNPPQd3P.d.mts.map +0 -1
- package/dist/once-DZCwmdkv.cjs +0 -1
- package/dist/once-DqmxXwEB.d.cts +0 -13
- package/dist/once-DqmxXwEB.d.cts.map +0 -1
- package/dist/once-txoW63yJ.mjs +0 -2
- package/dist/once-txoW63yJ.mjs.map +0 -1
- package/dist/pick-CuXTvXaw.mjs +0 -2
- package/dist/pick-CuXTvXaw.mjs.map +0 -1
- package/dist/pick-DXREvZBr.d.cts +0 -22
- package/dist/pick-DXREvZBr.d.cts.map +0 -1
- package/dist/pick-GDOwAh6I.cjs +0 -1
- package/dist/pick-ZrWD4de2.d.mts +0 -22
- package/dist/pick-ZrWD4de2.d.mts.map +0 -1
- package/dist/remove-accents-BFmyvTRZ.mjs +0 -2
- package/dist/remove-accents-BFmyvTRZ.mjs.map +0 -1
- package/dist/remove-accents-C4C0A2ex.d.mts +0 -12
- package/dist/remove-accents-C4C0A2ex.d.mts.map +0 -1
- package/dist/remove-accents-CXBUC-Id.cjs +0 -1
- package/dist/remove-accents-Yo3-2jWO.d.cts +0 -12
- package/dist/remove-accents-Yo3-2jWO.d.cts.map +0 -1
- package/dist/remove-empty-items-BglsRCyG.d.cts +0 -11
- package/dist/remove-empty-items-BglsRCyG.d.cts.map +0 -1
- package/dist/remove-empty-items-BzI9Vid9.mjs +0 -2
- package/dist/remove-empty-items-BzI9Vid9.mjs.map +0 -1
- package/dist/remove-empty-items-COwdCPHC.d.mts +0 -11
- package/dist/remove-empty-items-COwdCPHC.d.mts.map +0 -1
- package/dist/remove-empty-items-CjTxJuyS.cjs +0 -1
- package/dist/semaphore-4zJqtox8.mjs +0 -2
- package/dist/semaphore-4zJqtox8.mjs.map +0 -1
- package/dist/semaphore-CsGTxqsW.d.cts +0 -86
- package/dist/semaphore-CsGTxqsW.d.cts.map +0 -1
- package/dist/semaphore-DkHqPlow.cjs +0 -1
- package/dist/semaphore-WaZBtCk5.d.mts +0 -86
- package/dist/semaphore-WaZBtCk5.d.mts.map +0 -1
- package/dist/set-field-CUgbKEjW.mjs +0 -2
- package/dist/set-field-CUgbKEjW.mjs.map +0 -1
- package/dist/set-field-CcCiXZNl.d.cts +0 -16
- package/dist/set-field-CcCiXZNl.d.cts.map +0 -1
- package/dist/set-field-DyvXgpNP.d.mts +0 -16
- package/dist/set-field-DyvXgpNP.d.mts.map +0 -1
- package/dist/set-field-mr4GkhFb.cjs +0 -1
- package/dist/throttle-BOKOTo3m.cjs +0 -1
- package/dist/throttle-BWPQuZty.d.cts +0 -32
- package/dist/throttle-BWPQuZty.d.cts.map +0 -1
- package/dist/throttle-BgU4k6qs.d.mts +0 -32
- package/dist/throttle-BgU4k6qs.d.mts.map +0 -1
- package/dist/throttle-CYK3F0mZ.mjs +0 -2
- package/dist/throttle-CYK3F0mZ.mjs.map +0 -1
- package/dist/timeout-43rG9ETK.mjs +0 -2
- package/dist/timeout-43rG9ETK.mjs.map +0 -1
- package/dist/timeout-CLhwG-oo.d.mts +0 -12
- package/dist/timeout-CLhwG-oo.d.mts.map +0 -1
- package/dist/timeout-CoYbhliP.cjs +0 -1
- package/dist/timeout-DC38jHR8.d.cts +0 -12
- package/dist/timeout-DC38jHR8.d.cts.map +0 -1
- package/dist/to-deep-key-Cma9aiEz.cjs +0 -1
- package/dist/to-deep-key-D8uDBd6T.mjs +0 -2
- package/dist/to-deep-key-D8uDBd6T.mjs.map +0 -1
- package/dist/to-deep-key-DO-Z0Zjs.d.mts +0 -42
- package/dist/to-deep-key-DO-Z0Zjs.d.mts.map +0 -1
- package/dist/to-deep-key-DlsE4ziE.d.cts +0 -42
- package/dist/to-deep-key-DlsE4ziE.d.cts.map +0 -1
- package/dist/to-path-BajxeMmo.d.mts +0 -24
- package/dist/to-path-BajxeMmo.d.mts.map +0 -1
- package/dist/to-path-CdOFd4od.cjs +0 -1
- package/dist/to-path-D2zWXeYc.d.cts +0 -24
- package/dist/to-path-D2zWXeYc.d.cts.map +0 -1
- package/dist/to-path-Dm1fe-Ix.mjs +0 -2
- package/dist/to-path-Dm1fe-Ix.mjs.map +0 -1
- package/dist/unflatten-object-C7TE8J80.mjs +0 -2
- package/dist/unflatten-object-C7TE8J80.mjs.map +0 -1
- package/dist/unflatten-object-CPJIUozj.d.mts +0 -35
- package/dist/unflatten-object-CPJIUozj.d.mts.map +0 -1
- package/dist/unflatten-object-CvZj41LG.cjs +0 -1
- package/dist/unflatten-object-Cvbj7Q__.d.cts +0 -35
- package/dist/unflatten-object-Cvbj7Q__.d.cts.map +0 -1
- package/dist/union-BMOMEzO-.d.cts +0 -24
- package/dist/union-BMOMEzO-.d.cts.map +0 -1
- package/dist/union-C-2CRoFc.mjs +0 -2
- package/dist/union-C-2CRoFc.mjs.map +0 -1
- package/dist/union-D4bbjM2i.d.mts +0 -24
- package/dist/union-D4bbjM2i.d.mts.map +0 -1
- package/dist/union-EwdcZzNT.cjs +0 -1
- package/dist/with-timeout-BPaAIZtS.d.cts +0 -24
- package/dist/with-timeout-BPaAIZtS.d.cts.map +0 -1
- package/dist/with-timeout-BoZYdcOg.d.mts +0 -24
- package/dist/with-timeout-BoZYdcOg.d.mts.map +0 -1
- package/dist/with-timeout-CAuUr1ck.mjs +0 -2
- package/dist/with-timeout-CAuUr1ck.mjs.map +0 -1
- package/dist/with-timeout-CPUBGT4X.cjs +0 -1
package/dist/get-field.d.mts
CHANGED
|
@@ -1,2 +1,254 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/get-field.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* See the definition of `@types/lodash`.
|
|
4
|
+
*/
|
|
5
|
+
type GetIndexedField<T, K> = K extends keyof T ? T[K] : K extends `${number}` ? "length" extends keyof T ? number extends T["length"] ? number extends keyof T ? T[number] : undefined : undefined : undefined : undefined;
|
|
6
|
+
type FieldWithPossiblyUndefined<T, Key> = GetField<Exclude<T, undefined>, Key> | Extract<T, undefined>;
|
|
7
|
+
type IndexedFieldWithPossiblyUndefined<T, Key> = GetIndexedField<Exclude<T, undefined>, Key> | Extract<T, undefined>;
|
|
8
|
+
type GetField<T, P> = P extends `${infer Left}.${infer Right}` ? Left extends keyof Exclude<T, undefined> ? FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right> | Extract<T, undefined> : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined<IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey> : undefined : IndexedFieldWithPossiblyUndefined<T, P>;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type of the object.
|
|
13
|
+
* @template K - The type of the key in the object.
|
|
14
|
+
* @template D - The type of the default value.
|
|
15
|
+
*
|
|
16
|
+
* @param {T} object - The object to query.
|
|
17
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
18
|
+
* @returns {T[K]} - Returns the resolved value.
|
|
19
|
+
*/
|
|
20
|
+
declare function getField<T extends object, K extends keyof T>(object: T, path: K | readonly [K]): T[K];
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of the object.
|
|
25
|
+
* @template K - The type of the key in the object.
|
|
26
|
+
*
|
|
27
|
+
* @param {T | null | undefined} object - The object to query.
|
|
28
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
29
|
+
* @returns {T[K] | undefined} - Returns the resolved value.
|
|
30
|
+
*/
|
|
31
|
+
declare function getField<T extends object, K extends keyof T>(object: T | null | undefined, path: K | readonly [K]): T[K] | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
34
|
+
*
|
|
35
|
+
* @template T - The type of the object.
|
|
36
|
+
* @template K - The type of the key in the object.
|
|
37
|
+
* @template D - The type of the default value.
|
|
38
|
+
*
|
|
39
|
+
* @param {T | null | undefined} object - The object to query.
|
|
40
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
41
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
42
|
+
* @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.
|
|
43
|
+
*/
|
|
44
|
+
declare function getField<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | readonly [K], defaultValue: D): Exclude<T[K], undefined> | D;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
47
|
+
*
|
|
48
|
+
* @template T - The type of the object.
|
|
49
|
+
* @template K1 - The type of the first key in the object.
|
|
50
|
+
* @template K2 - The type of the second key in the object.
|
|
51
|
+
*
|
|
52
|
+
* @param {T} object - The object to query.
|
|
53
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
54
|
+
* @returns {T[K1][K2]} - Returns the resolved value.
|
|
55
|
+
*/
|
|
56
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: readonly [K1, K2]): T[K1][K2];
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
59
|
+
*
|
|
60
|
+
* @template T - The type of the object.
|
|
61
|
+
* @template K1 - The type of the first key in the object.
|
|
62
|
+
* @template K2 - The type of the second key in the object.
|
|
63
|
+
*
|
|
64
|
+
* @param {T | null | undefined} object - The object to query.
|
|
65
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
66
|
+
* @returns {T[K1][K2] | undefined} - Returns the resolved value.
|
|
67
|
+
*/
|
|
68
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
71
|
+
*
|
|
72
|
+
* @template T - The type of the object.
|
|
73
|
+
* @template K1 - The type of the first key in the object.
|
|
74
|
+
* @template K2 - The type of the second key in the object.
|
|
75
|
+
* @template D - The type of the default value.
|
|
76
|
+
*
|
|
77
|
+
* @param {T | null | undefined} object - The object to query.
|
|
78
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
79
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
80
|
+
* @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.
|
|
81
|
+
*/
|
|
82
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: readonly [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
85
|
+
*
|
|
86
|
+
* @template T - The type of the object.
|
|
87
|
+
* @template K1 - The type of the first key in the object.
|
|
88
|
+
* @template K2 - The type of the second key in the object.
|
|
89
|
+
* @template K3 - The type of the third key in the object.
|
|
90
|
+
*
|
|
91
|
+
* @param {T} object - The object to query.
|
|
92
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
93
|
+
* @returns {T[K1][K2][K3]} - Returns the resolved value.
|
|
94
|
+
*/
|
|
95
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3];
|
|
96
|
+
/**
|
|
97
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
98
|
+
*
|
|
99
|
+
* @template T - The type of the object.
|
|
100
|
+
* @template K1 - The type of the first key in the object.
|
|
101
|
+
* @template K2 - The type of the second key in the object.
|
|
102
|
+
* @template K3 - The type of the third key in the object.
|
|
103
|
+
*
|
|
104
|
+
* @param {T | null | undefined} object - The object to query.
|
|
105
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
106
|
+
* @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.
|
|
107
|
+
*/
|
|
108
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: readonly [K1, K2, K3]): T[K1][K2][K3] | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
111
|
+
*
|
|
112
|
+
* @template T - The type of the object.
|
|
113
|
+
* @template K1 - The type of the first key in the object.
|
|
114
|
+
* @template K2 - The type of the second key in the object.
|
|
115
|
+
* @template K3 - The type of the third key in the object.
|
|
116
|
+
* @template D - The type of the default value.
|
|
117
|
+
*
|
|
118
|
+
* @param {T | null | undefined} object - The object to query.
|
|
119
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
120
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
121
|
+
* @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.
|
|
122
|
+
*/
|
|
123
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: readonly [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
126
|
+
*
|
|
127
|
+
* @template T - The type of the object.
|
|
128
|
+
* @template K1 - The type of the first key in the object.
|
|
129
|
+
* @template K2 - The type of the second key in the object.
|
|
130
|
+
* @template K3 - The type of the third key in the object.
|
|
131
|
+
* @template K4 - The type of the fourth key in the object.
|
|
132
|
+
*
|
|
133
|
+
* @param {T} object - The object to query.
|
|
134
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
135
|
+
* @returns {T[K1][K2][K3][K4]} - Returns the resolved value.
|
|
136
|
+
*/
|
|
137
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
140
|
+
*
|
|
141
|
+
* @template T - The type of the object.
|
|
142
|
+
* @template K1 - The type of the first key in the object.
|
|
143
|
+
* @template K2 - The type of the second key in the object.
|
|
144
|
+
* @template K3 - The type of the third key in the object.
|
|
145
|
+
* @template K4 - The type of the fourth key in the object.
|
|
146
|
+
*
|
|
147
|
+
* @param {T | null | undefined} object - The object to query.
|
|
148
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
149
|
+
* @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.
|
|
150
|
+
*/
|
|
151
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
154
|
+
*
|
|
155
|
+
* @template T - The type of the object.
|
|
156
|
+
* @template K1 - The type of the first key in the object.
|
|
157
|
+
* @template K2 - The type of the second key in the object.
|
|
158
|
+
* @template K3 - The type of the third key in the object.
|
|
159
|
+
* @template K4 - The type of the fourth key in the object.
|
|
160
|
+
* @template D - The type of the default value.
|
|
161
|
+
*
|
|
162
|
+
* @param {T | null | undefined} object - The object to query.
|
|
163
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
164
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
165
|
+
* @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.
|
|
166
|
+
*/
|
|
167
|
+
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: readonly [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;
|
|
168
|
+
/**
|
|
169
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
170
|
+
*
|
|
171
|
+
* @template T - The type of the value.
|
|
172
|
+
*
|
|
173
|
+
* @param {Record<number, T>} object - The object to query.
|
|
174
|
+
* @param {number} path - The path of the property to get.
|
|
175
|
+
* @returns {T} - Returns the resolved value.
|
|
176
|
+
*/
|
|
177
|
+
declare function getField<T>(object: Record<number, T>, path: number): T;
|
|
178
|
+
/**
|
|
179
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
180
|
+
*
|
|
181
|
+
* @template T - The type of the value.
|
|
182
|
+
*
|
|
183
|
+
* @param {Record<number, T> | null | undefined} object - The object to query.
|
|
184
|
+
* @param {number} path - The path of the property to get.
|
|
185
|
+
* @returns {T | undefined} - Returns the resolved value.
|
|
186
|
+
*/
|
|
187
|
+
declare function getField<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
190
|
+
*
|
|
191
|
+
* @template T - The type of the value.
|
|
192
|
+
* @template D - The type of the default value.
|
|
193
|
+
*
|
|
194
|
+
* @param {Record<number, T> | null | undefined} object - The object to query.
|
|
195
|
+
* @param {number} path - The path of the property to get.
|
|
196
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
197
|
+
* @returns {T | D} - Returns the resolved value.
|
|
198
|
+
*/
|
|
199
|
+
declare function getField<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;
|
|
200
|
+
/**
|
|
201
|
+
* Retrieves the value at a given path from a null or undefined object, returning the default value.
|
|
202
|
+
*
|
|
203
|
+
* @template D - The type of the default value.
|
|
204
|
+
*
|
|
205
|
+
* @param {null | undefined} object - The object to query.
|
|
206
|
+
* @param {PropertyKey} path - The path of the property to get.
|
|
207
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
208
|
+
* @returns {D} - Returns the default value.
|
|
209
|
+
*/
|
|
210
|
+
declare function getField<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;
|
|
211
|
+
/**
|
|
212
|
+
* Retrieves the value at a given path from a null or undefined object, returning undefined.
|
|
213
|
+
*
|
|
214
|
+
* @param {null | undefined} object - The object to query.
|
|
215
|
+
* @param {PropertyKey} path - The path of the property to get.
|
|
216
|
+
* @returns {undefined} - Returns undefined.
|
|
217
|
+
*/
|
|
218
|
+
declare function getField(object: null | undefined, path: PropertyKey): undefined;
|
|
219
|
+
/**
|
|
220
|
+
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
221
|
+
*
|
|
222
|
+
* @template T - The type of the object.
|
|
223
|
+
* @template P - The type of the path.
|
|
224
|
+
*
|
|
225
|
+
* @param {T} data - The object to query.
|
|
226
|
+
* @param {P} path - The path of the property to get.
|
|
227
|
+
* @returns {string extends P ? any : GetField<T, P>} - Returns the resolved value.
|
|
228
|
+
*/
|
|
229
|
+
declare function getField<T, P extends string>(data: T, path: P): string extends P ? any : GetField<T, P>;
|
|
230
|
+
/**
|
|
231
|
+
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
232
|
+
*
|
|
233
|
+
* @template T - The type of the object.
|
|
234
|
+
* @template P - The type of the path.
|
|
235
|
+
* @template D - The type of the default value.
|
|
236
|
+
*
|
|
237
|
+
* @param {T} data - The object to query.
|
|
238
|
+
* @param {P} path - The path of the property to get.
|
|
239
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
240
|
+
* @returns {Exclude<GetField<T, P>, null | undefined> | D} - Returns the resolved value.
|
|
241
|
+
*/
|
|
242
|
+
declare function getField<T, P extends string, D = GetField<T, P>>(data: T, path: P, defaultValue: D): Exclude<GetField<T, P>, null | undefined> | D;
|
|
243
|
+
/**
|
|
244
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
245
|
+
*
|
|
246
|
+
* @param {unknown} object - The object to query.
|
|
247
|
+
* @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.
|
|
248
|
+
* @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.
|
|
249
|
+
* @returns {any} - Returns the resolved value.
|
|
250
|
+
*/
|
|
251
|
+
declare function getField(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;
|
|
252
|
+
//#endregion
|
|
253
|
+
export { GetField, getField };
|
|
254
|
+
//# sourceMappingURL=get-field.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-field.d.mts","names":[],"sources":["../src/get-field.ts"],"sourcesContent":[],"mappings":";;;;KAyBK,eAAwC,CAAA,CAAA,EAAA,CAAA,CAAA,GAAhB,CA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;;;;AAKyB,iBAkFT,QAlFS,CAAA,CAAA,EAAA,UAAA,MAAA,CAAA,CAAA,IAAA,EAmFjB,CAnFiB,EAAA,IAAA,EAoFjB,CApFiB,CAAA,EAAA,MAAA,SAqFP,CArFO,GAAA,GAAA,GAqFG,QArFH,CAqFY,CArFZ,EAqFe,CArFf,CAAA;;;;;;;;;;;;;AAMtB,iBA4Fa,QA5Fb,CAAA,CAAA,EAAA,UAAA,MAAA,EAAA,IA4F+C,QA5F/C,CA4FwD,CA5FxD,EA4F2D,CA5F3D,CAAA,CAAA,CAAA,IAAA,EA6FK,CA7FL,EAAA,IAAA,EA8FK,CA9FL,EAAA,YAAA,EA+Fa,CA/Fb,CAAA,EAgGA,OAhGA,CAgGQ,QAhGR,CAgGiB,CAhGjB,EAgGoB,CAhGpB,CAAA,EAAA,IAAA,GAAA,SAAA,CAAA,GAgG4C,CAhG5C;;;AAUH;;;;;AAUA;AACyB,iBAoFT,QAAA,CApFS,MAAA,EAAA,OAAA,EAAA,IAAA,EAsFjB,WAtFiB,GAAA,SAsFM,WAtFN,EAAA,EAAA,YAAA,CAAA,EAAA,OAAA,CAAA,EAAA,GAAA"}
|
package/dist/get-field.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isNumber as e}from"./type-checks/src/is-number.mjs";import{toStringKey as t}from"./convert/src/to-string-key.mjs";import{isDeepKey as n}from"./type-checks/src/is-deep-key.mjs";import{toPath as r}from"./to-path.mjs";function i(o,s,c){if(o===null)return c;switch(typeof s){case`string`:{let e=o[s];return e===void 0?n(s)?i(o,r(s),c):c:e}case`number`:case`symbol`:{e(s)&&(s=t(s));let n=Array.isArray(s)?void 0:o[s];return n===void 0?c:n}default:{if(Array.isArray(s))return a(o,s,c);s=Object.is(s?.valueOf(),-0)?`-0`:String(s);let e=o[s];return e===void 0?c:e}}}function a(e,t,n){if(t.length===0)return n;let r=e;for(let e of t){if(r===null)return n;r=r[e]}return r===void 0?n:r}export{i as getField};
|
|
2
|
+
//# sourceMappingURL=get-field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-field.mjs","names":[],"sources":["../src/get-field.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport { toStringKey } from \"@stryke/convert/to-string-key\";\nimport { isDeepKey } from \"@stryke/type-checks/is-deep-key\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { toPath } from \"./to-path\";\n\n/**\n * See the definition of `@types/lodash`.\n */\ntype GetIndexedField<T, K> = K extends keyof T\n ? T[K]\n : K extends `${number}`\n ? \"length\" extends keyof T\n ? number extends T[\"length\"]\n ? number extends keyof T\n ? T[number]\n : undefined\n : undefined\n : undefined\n : undefined;\n\ntype FieldWithPossiblyUndefined<T, Key> =\n | GetField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\ntype IndexedFieldWithPossiblyUndefined<T, Key> =\n | GetIndexedField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\nexport type GetField<T, P> = P extends `${infer Left}.${infer Right}`\n ? Left extends keyof Exclude<T, undefined>\n ?\n | FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right>\n | Extract<T, undefined>\n : Left extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? FieldWithPossiblyUndefined<\n IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>,\n Right\n >\n : undefined\n : undefined\n : P extends keyof T\n ? T[P]\n : P extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>\n : undefined\n : IndexedFieldWithPossiblyUndefined<T, P>;\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n *\n * @param {T} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K]} - Returns the resolved value.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T,\n path: K | readonly [K]\n): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K] | undefined} - Returns the resolved value.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T | null | undefined,\n path: K | readonly [K]\n): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.\n */\nexport function getField<T extends object, K extends keyof T, D>(\n object: T | null | undefined,\n path: K | readonly [K],\n defaultValue: D\n): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n *\n * @param {T} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2]} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T, path: readonly [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2] | undefined} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2],\n defaultValue: D\n): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n *\n * @param {T} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3]} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3]\n): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3],\n defaultValue: D\n): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n *\n * @param {T} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4]} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4]\n): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4],\n defaultValue: D\n): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the value.\n *\n * @param {Record<number, T>} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T} - Returns the resolved value.\n */\nexport function getField<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the value.\n *\n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T | undefined} - Returns the resolved value.\n */\nexport function getField<T>(\n object: Record<number, T> | null | undefined,\n path: number\n): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the value.\n * @template D - The type of the default value.\n *\n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {T | D} - Returns the resolved value.\n */\nexport function getField<T, D>(\n object: Record<number, T> | null | undefined,\n path: number,\n defaultValue: D\n): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n *\n * @template D - The type of the default value.\n *\n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {D} - Returns the default value.\n */\nexport function getField<D>(\n object: null | undefined,\n path: PropertyKey,\n defaultValue: D\n): D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n *\n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @returns {undefined} - Returns undefined.\n */\nexport function getField(\n object: null | undefined,\n path: PropertyKey\n): undefined;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template P - The type of the path.\n *\n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @returns {string extends P ? any : GetField<T, P>} - Returns the resolved value.\n */\nexport function getField<T, P extends string>(\n data: T,\n path: P\n): string extends P ? any : GetField<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template P - The type of the path.\n * @template D - The type of the default value.\n *\n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<GetField<T, P>, null | undefined> | D} - Returns the resolved value.\n */\nexport function getField<T, P extends string, D = GetField<T, P>>(\n data: T,\n path: P,\n defaultValue: D\n): Exclude<GetField<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param {unknown} object - The object to query.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.\n * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.\n * @returns {any} - Returns the resolved value.\n */\nexport function getField(\n object: unknown,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: unknown\n): any;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param {unknown} object - The object to query.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.\n * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.\n * @returns {any} - Returns the resolved value.\n */\nexport function getField(\n object: any,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (object === null) {\n return defaultValue;\n }\n\n switch (typeof path) {\n case \"string\": {\n const result = object[path];\n\n if (result === undefined) {\n if (isDeepKey(path)) {\n return getField(object, toPath(path), defaultValue);\n }\n return defaultValue;\n }\n\n return result;\n }\n case \"number\":\n case \"symbol\": {\n if (isNumber(path)) {\n path = toStringKey(path);\n }\n\n const result = Array.isArray(path)\n ? undefined\n : object[path as PropertyKey];\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n default: {\n if (Array.isArray(path)) {\n return getWithPath(object, path, defaultValue);\n }\n\n path = Object.is(path?.valueOf(), -0) ? \"-0\" : String(path);\n\n const result = object[path];\n\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n }\n}\n\nfunction getWithPath(\n object: any,\n path: readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (path.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n\n for (const element_ of path) {\n if (current === null) {\n return defaultValue;\n }\n\n current = current[element_];\n }\n\n if (current === undefined) {\n return defaultValue;\n }\n\n return current;\n}\n"],"mappings":"8NAkaA,SAAgB,EACd,EACA,EACA,EACK,CACL,GAAI,IAAW,KACb,OAAO,EAGT,OAAQ,OAAO,EAAf,CACE,IAAK,SAAU,CACb,IAAM,EAAS,EAAO,GAStB,OAPI,IAAW,IAAA,GACT,EAAU,EAAK,CACV,EAAS,EAAQ,EAAO,EAAK,CAAE,EAAa,CAE9C,EAGF,EAET,IAAK,SACL,IAAK,SAAU,CACT,EAAS,EAAK,GAChB,EAAO,EAAY,EAAK,EAG1B,IAAM,EAAS,MAAM,QAAQ,EAAK,CAC9B,IAAA,GACA,EAAO,GAKX,OAJI,IAAW,IAAA,GACN,EAGF,EAET,QAAS,CACP,GAAI,MAAM,QAAQ,EAAK,CACrB,OAAO,EAAY,EAAQ,EAAM,EAAa,CAGhD,EAAO,OAAO,GAAG,GAAM,SAAS,CAAE,GAAG,CAAG,KAAO,OAAO,EAAK,CAE3D,IAAM,EAAS,EAAO,GAMtB,OAJI,IAAW,IAAA,GACN,EAGF,IAKb,SAAS,EACP,EACA,EACA,EACK,CACL,GAAI,EAAK,SAAW,EAClB,OAAO,EAGT,IAAI,EAAU,EAEd,IAAK,IAAM,KAAY,EAAM,CAC3B,GAAI,IAAY,KACd,OAAO,EAGT,EAAU,EAAQ,GAOpB,OAJI,IAAY,IAAA,GACP,EAGF"}
|
package/dist/get-ordered-by.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t,n){let r=(e,t,n)=>e<t?n===`asc`?-1:1:e>t?n===`asc`?1:-1:0,i=t.map((e,t)=>n[t]??n.at(-1));return[...e].sort((e,n)=>{for(let[a,o]of t.entries()){let t=i[a],s=r(e[o],n[o],t);if(s!==0)return s}return 0})}exports.getOrderedBy=e;
|
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/get-ordered-by.d.ts
|
|
2
|
+
type Order = "asc" | "desc";
|
|
3
|
+
/**
|
|
4
|
+
* Sorts an array of objects based on multiple properties and their corresponding order directions.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This function takes an array of objects, an array of keys to sort by, and an array of order directions.
|
|
8
|
+
* It returns the sorted array, ordering by each key according to its corresponding direction
|
|
9
|
+
* ('asc' for ascending or 'desc' for descending). If values for a key are equal,
|
|
10
|
+
* it moves to the next key to determine the order.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Sort an array of objects by 'user' in ascending order and 'age' in descending order.
|
|
15
|
+
* const users = [
|
|
16
|
+
* { user: 'fred', age: 48 },
|
|
17
|
+
* { user: 'barney', age: 34 },
|
|
18
|
+
* { user: 'fred', age: 40 },
|
|
19
|
+
* { user: 'barney', age: 36 },
|
|
20
|
+
* ];
|
|
21
|
+
* const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);
|
|
22
|
+
* // result will be:
|
|
23
|
+
* // [
|
|
24
|
+
* // { user: 'barney', age: 36 },
|
|
25
|
+
* // { user: 'barney', age: 34 },
|
|
26
|
+
* // { user: 'fred', age: 48 },
|
|
27
|
+
* // { user: 'fred', age: 40 },
|
|
28
|
+
* // ]
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param collection - The array of objects to be sorted.
|
|
32
|
+
* @param keys - An array of keys (properties) by which to sort.
|
|
33
|
+
* @param orders - An array of order directions ('asc' for ascending or 'desc' for descending).
|
|
34
|
+
* @returns The sorted array.
|
|
35
|
+
*/
|
|
36
|
+
declare function getOrderedBy<T>(collection: T[], keys: (keyof T)[], orders: Order[]): T[];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { getOrderedBy };
|
|
39
|
+
//# sourceMappingURL=get-ordered-by.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ordered-by.d.cts","names":[],"sources":["../src/get-ordered-by.ts"],"sourcesContent":[],"mappings":";KAiBK,KAAA;;AAmCL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,4BACF,kBACC,cACL,UACP"}
|
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/get-ordered-by.d.ts
|
|
2
|
+
type Order = "asc" | "desc";
|
|
3
|
+
/**
|
|
4
|
+
* Sorts an array of objects based on multiple properties and their corresponding order directions.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This function takes an array of objects, an array of keys to sort by, and an array of order directions.
|
|
8
|
+
* It returns the sorted array, ordering by each key according to its corresponding direction
|
|
9
|
+
* ('asc' for ascending or 'desc' for descending). If values for a key are equal,
|
|
10
|
+
* it moves to the next key to determine the order.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Sort an array of objects by 'user' in ascending order and 'age' in descending order.
|
|
15
|
+
* const users = [
|
|
16
|
+
* { user: 'fred', age: 48 },
|
|
17
|
+
* { user: 'barney', age: 34 },
|
|
18
|
+
* { user: 'fred', age: 40 },
|
|
19
|
+
* { user: 'barney', age: 36 },
|
|
20
|
+
* ];
|
|
21
|
+
* const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);
|
|
22
|
+
* // result will be:
|
|
23
|
+
* // [
|
|
24
|
+
* // { user: 'barney', age: 36 },
|
|
25
|
+
* // { user: 'barney', age: 34 },
|
|
26
|
+
* // { user: 'fred', age: 48 },
|
|
27
|
+
* // { user: 'fred', age: 40 },
|
|
28
|
+
* // ]
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param collection - The array of objects to be sorted.
|
|
32
|
+
* @param keys - An array of keys (properties) by which to sort.
|
|
33
|
+
* @param orders - An array of order directions ('asc' for ascending or 'desc' for descending).
|
|
34
|
+
* @returns The sorted array.
|
|
35
|
+
*/
|
|
36
|
+
declare function getOrderedBy<T>(collection: T[], keys: (keyof T)[], orders: Order[]): T[];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { getOrderedBy };
|
|
39
|
+
//# sourceMappingURL=get-ordered-by.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ordered-by.d.mts","names":[],"sources":["../src/get-ordered-by.ts"],"sourcesContent":[],"mappings":";KAiBK,KAAA;;AAmCL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,4BACF,kBACC,cACL,UACP"}
|
package/dist/get-ordered-by.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t,n){let r=(e,t,n)=>e<t?n===`asc`?-1:1:e>t?n===`asc`?1:-1:0,i=t.map((e,t)=>n[t]??n.at(-1));return[...e].sort((e,n)=>{for(let[a,o]of t.entries()){let t=i[a],s=r(e[o],n[o],t);if(s!==0)return s}return 0})}export{e as getOrderedBy};
|
|
2
|
+
//# sourceMappingURL=get-ordered-by.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ordered-by.mjs","names":[],"sources":["../src/get-ordered-by.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\ntype Order = \"asc\" | \"desc\";\n\n/**\n * Sorts an array of objects based on multiple properties and their corresponding order directions.\n *\n * @remarks\n * This function takes an array of objects, an array of keys to sort by, and an array of order directions.\n * It returns the sorted array, ordering by each key according to its corresponding direction\n * ('asc' for ascending or 'desc' for descending). If values for a key are equal,\n * it moves to the next key to determine the order.\n *\n * @example\n * ```typescript\n * // Sort an array of objects by 'user' in ascending order and 'age' in descending order.\n * const users = [\n * { user: 'fred', age: 48 },\n * { user: 'barney', age: 34 },\n * { user: 'fred', age: 40 },\n * { user: 'barney', age: 36 },\n * ];\n * const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // result will be:\n * // [\n * // { user: 'barney', age: 36 },\n * // { user: 'barney', age: 34 },\n * // { user: 'fred', age: 48 },\n * // { user: 'fred', age: 40 },\n * // ]\n * ```\n *\n * @param collection - The array of objects to be sorted.\n * @param keys - An array of keys (properties) by which to sort.\n * @param orders - An array of order directions ('asc' for ascending or 'desc' for descending).\n * @returns The sorted array.\n */\nexport function getOrderedBy<T>(\n collection: T[],\n keys: (keyof T)[],\n orders: Order[]\n): T[] {\n const compareValues = (a: T[keyof T], b: T[keyof T], order: Order) => {\n if (a < b) {\n return order === \"asc\" ? -1 : 1;\n }\n if (a > b) {\n return order === \"asc\" ? 1 : -1;\n }\n return 0;\n };\n\n const effectiveOrders = keys.map(\n (_, index) => orders[index] ?? orders.at(-1)\n );\n\n return [...collection].sort((a, b) => {\n for (const [i, key] of keys.entries()) {\n const order = effectiveOrders[i];\n const result = compareValues(a[key], b[key], order!);\n if (result !== 0) {\n return result;\n }\n }\n return 0;\n });\n}\n"],"mappings":"AAoDA,SAAgB,EACd,EACA,EACA,EACK,CACL,IAAM,GAAiB,EAAe,EAAe,IAC/C,EAAI,EACC,IAAU,MAAQ,GAAK,EAE5B,EAAI,EACC,IAAU,MAAQ,EAAI,GAExB,EAGH,EAAkB,EAAK,KAC1B,EAAG,IAAU,EAAO,IAAU,EAAO,GAAG,GAAG,CAC7C,CAED,MAAO,CAAC,GAAG,EAAW,CAAC,MAAM,EAAG,IAAM,CACpC,IAAK,GAAM,CAAC,EAAG,KAAQ,EAAK,SAAS,CAAE,CACrC,IAAM,EAAQ,EAAgB,GACxB,EAAS,EAAc,EAAE,GAAM,EAAE,GAAM,EAAO,CACpD,GAAI,IAAW,EACb,OAAO,EAGX,MAAO,IACP"}
|
package/dist/get-unique.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=
|
|
1
|
+
const e=e=>[...new Set(e)];function t(e,t=e=>e){let n=new Map;for(let r of e){let e=t(r);n.has(e)||n.set(e,r)}return[...n.values()]}exports.getUnique=e,exports.getUniqueBy=t;
|
package/dist/get-unique.d.cts
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/get-unique.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of unique values from the given array.
|
|
4
|
+
*
|
|
5
|
+
* @param arr - The array to get unique values from.
|
|
6
|
+
* @returns An array of unique values.
|
|
7
|
+
*/
|
|
8
|
+
declare const getUnique: <T = any>(arr: T[]) => T[];
|
|
9
|
+
/**
|
|
10
|
+
* Returns a new array containing only the unique elements from the original array,
|
|
11
|
+
* based on the values returned by the mapper function.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
|
|
16
|
+
* // [1.2, 2.1, 3.2, 5.7, 7.19]
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param arr - The array to process.
|
|
20
|
+
* @param mapper - The function used to convert the array elements.
|
|
21
|
+
* @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.
|
|
22
|
+
*/
|
|
23
|
+
declare function getUniqueBy<T, U>(arr: readonly T[], mapper?: (item: T) => U): T[];
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getUnique, getUniqueBy };
|
|
26
|
+
//# sourceMappingURL=get-unique.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-unique.d.cts","names":[],"sources":["../src/get-unique.ts"],"sourcesContent":[],"mappings":";;AAwBA;AAkBA;;;;AAGG,cArBU,SAqBV,EAAA,CAAA,IAAA,GAAA,CAAA,CAAA,GAAA,EArBqC,CAqBrC,EAAA,EAAA,GArB2C,CAqB3C,EAAA;;;;;;;;;;;;;;;iBAHa,gCACA,qBACC,MAAM,IACpB"}
|
package/dist/get-unique.d.mts
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/get-unique.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of unique values from the given array.
|
|
4
|
+
*
|
|
5
|
+
* @param arr - The array to get unique values from.
|
|
6
|
+
* @returns An array of unique values.
|
|
7
|
+
*/
|
|
8
|
+
declare const getUnique: <T = any>(arr: T[]) => T[];
|
|
9
|
+
/**
|
|
10
|
+
* Returns a new array containing only the unique elements from the original array,
|
|
11
|
+
* based on the values returned by the mapper function.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
|
|
16
|
+
* // [1.2, 2.1, 3.2, 5.7, 7.19]
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param arr - The array to process.
|
|
20
|
+
* @param mapper - The function used to convert the array elements.
|
|
21
|
+
* @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.
|
|
22
|
+
*/
|
|
23
|
+
declare function getUniqueBy<T, U>(arr: readonly T[], mapper?: (item: T) => U): T[];
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getUnique, getUniqueBy };
|
|
26
|
+
//# sourceMappingURL=get-unique.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-unique.d.mts","names":[],"sources":["../src/get-unique.ts"],"sourcesContent":[],"mappings":";;AAwBA;AAkBA;;;;AAGG,cArBU,SAqBV,EAAA,CAAA,IAAA,GAAA,CAAA,CAAA,GAAA,EArBqC,CAqBrC,EAAA,EAAA,GArB2C,CAqB3C,EAAA;;;;;;;;;;;;;;;iBAHa,gCACA,qBACC,MAAM,IACpB"}
|
package/dist/get-unique.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=e=>[...new Set(e)];function t(e,t=e=>e){let n=new Map;for(let r of e){let e=t(r);n.has(e)||n.set(e,r)}return[...n.values()]}export{e as getUnique,t as getUniqueBy};
|
|
2
|
+
//# sourceMappingURL=get-unique.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-unique.mjs","names":[],"sources":["../src/get-unique.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":"AAwBA,MAAa,EAAsB,GAC1B,CAAC,GAAG,IAAI,IAAI,EAAI,CAAC,CAiB1B,SAAgB,EACd,EACA,EAAyB,GAAQ,EAC5B,CACL,IAAM,EAAM,IAAI,IAEhB,IAAK,IAAM,KAAQ,EAAK,CACtB,IAAM,EAAM,EAAO,EAAK,CAEnB,EAAI,IAAI,EAAI,EACf,EAAI,IAAI,EAAK,EAAK,CAItB,MAAO,CAAC,GAAG,EAAI,QAAQ,CAAC"}
|
package/dist/identity.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){return e}exports.identity=e;
|
package/dist/identity.d.cts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/identity.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns the input value unchanged.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* identity(5); // Returns 5
|
|
8
|
+
* identity('hello'); // Returns 'hello'
|
|
9
|
+
* identity({ key: 'value' }); // Returns { key: 'value' }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param x - The value to be returned.
|
|
13
|
+
* @returns The input value.
|
|
14
|
+
*/
|
|
15
|
+
declare function identity<T>(x: T): T;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { identity };
|
|
18
|
+
//# sourceMappingURL=identity.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.cts","names":[],"sources":["../src/identity.ts"],"sourcesContent":[],"mappings":";;AA8BA;;;;;;;;;;;;iBAAgB,eAAe,IAAI"}
|
package/dist/identity.d.mts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/identity.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns the input value unchanged.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* identity(5); // Returns 5
|
|
8
|
+
* identity('hello'); // Returns 'hello'
|
|
9
|
+
* identity({ key: 'value' }); // Returns { key: 'value' }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param x - The value to be returned.
|
|
13
|
+
* @returns The input value.
|
|
14
|
+
*/
|
|
15
|
+
declare function identity<T>(x: T): T;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { identity };
|
|
18
|
+
//# sourceMappingURL=identity.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.mts","names":[],"sources":["../src/identity.ts"],"sourcesContent":[],"mappings":";;AA8BA;;;;;;;;;;;;iBAAgB,eAAe,IAAI"}
|
package/dist/identity.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){return e}export{e as identity};
|
|
2
|
+
//# sourceMappingURL=identity.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.mjs","names":[],"sources":["../src/identity.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\n/**\n * Returns the input value unchanged.\n *\n * @example\n * ```ts\n * identity(5); // Returns 5\n * identity('hello'); // Returns 'hello'\n * identity({ key: 'value' }); // Returns { key: 'value' }\n * ```\n *\n * @param x - The value to be returned.\n * @returns The input value.\n */\nexport function identity<T>(x: T): T {\n return x;\n}\n"],"mappings":"AA8BA,SAAgB,EAAY,EAAS,CACnC,OAAO"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./arg-identity
|
|
1
|
+
const e=require(`./arg-identity.cjs`),t=require(`./debounce.cjs`),n=require(`./deep-clone.cjs`),r=require(`./deep-merge.cjs`),i=require(`./delay.cjs`),a=require(`./filter-empty.cjs`),o=require(`./flatten-object.cjs`),s=require(`./to-path.cjs`),c=require(`./get-field.cjs`),l=require(`./get-ordered-by.cjs`),u=require(`./get-unique.cjs`),d=require(`./identity.cjs`),f=require(`./is-equal.cjs`),p=require(`./lru-cache.cjs`),m=require(`./remove-accents.cjs`),h=require(`./match-sorter.cjs`),g=require(`./memoize.cjs`),_=require(`./semaphore.cjs`),v=require(`./mutex.cjs`),y=require(`./noop.cjs`),b=require(`./omit.cjs`),x=require(`./once.cjs`),S=require(`./pick.cjs`),C=require(`./remove-empty-items.cjs`),w=require(`./set-field.cjs`),T=require(`./throttle.cjs`),E=require(`./timeout.cjs`),D=require(`./to-deep-key.cjs`),O=require(`./unflatten-object.cjs`),k=require(`./union.cjs`),A=require(`./with-timeout.cjs`);exports.LRUCache=p.LRUCache,exports.Mutex=v.Mutex,exports.Semaphore=_.Semaphore,exports.addPathToDeepKey=D.addPathToDeepKey,exports.argIdentity=e.argIdentity,exports.asyncNoop=y.asyncNoop,exports.characterMap=m.characterMap,exports.debounce=t.debounce,exports.deepClone=n.deepClone,exports.deepMerge=r.deepMerge,exports.defaultBaseSortFn=h.defaultBaseSortFn,exports.delay=i.delay,exports.filterEmpty=a.filterEmpty,exports.flattenObject=o.flattenObject,exports.getField=c.getField,exports.getOrderedBy=l.getOrderedBy,exports.getUnique=u.getUnique,exports.getUniqueBy=u.getUniqueBy,exports.identity=d.identity,exports.isEqual=f.isEqual,exports.matchSorter=h.matchSorter,exports.memoizeOnId=g.memoizeOnId,exports.noop=y.noop,exports.omit=b.omit,exports.once=x.once,exports.pick=S.pick,exports.rankings=h.rankings,exports.removeAccents=m.removeAccents,exports.removeEmptyItems=C.removeEmptyItems,exports.safeFunctionCast=x.safeFunctionCast,exports.setField=w.setField,exports.sleep=i.sleep,exports.throttle=T.throttle,exports.timeout=E.timeout,exports.toDeepKey=D.toDeepKey,exports.toPath=s.toPath,exports.unflattenObject=O.unflattenObject,exports.union=k.union,exports.withTimeout=A.withTimeout;
|