@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/match-sorter.d.mts
CHANGED
|
@@ -1,2 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/match-sorter.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Forked from match-sorter by Kent C. Dodds
|
|
4
|
+
*/
|
|
5
|
+
interface KeyAttributes {
|
|
6
|
+
threshold?: Ranking;
|
|
7
|
+
maxRanking: Ranking;
|
|
8
|
+
minRanking: Ranking;
|
|
9
|
+
}
|
|
10
|
+
interface RankingInfo {
|
|
11
|
+
rankedValue: string;
|
|
12
|
+
rank: Ranking;
|
|
13
|
+
keyIndex: number;
|
|
14
|
+
keyThreshold: Ranking | undefined;
|
|
15
|
+
}
|
|
16
|
+
interface ValueGetterKey<ItemType> {
|
|
17
|
+
(item: ItemType): string | Array<string>;
|
|
18
|
+
}
|
|
19
|
+
interface IndexedItem<ItemType> {
|
|
20
|
+
item: ItemType;
|
|
21
|
+
index: number;
|
|
22
|
+
}
|
|
23
|
+
interface RankedItem<ItemType> extends RankingInfo, IndexedItem<ItemType> {}
|
|
24
|
+
interface BaseSorter<ItemType> {
|
|
25
|
+
(a: RankedItem<ItemType>, b: RankedItem<ItemType>): number;
|
|
26
|
+
}
|
|
27
|
+
interface Sorter<ItemType> {
|
|
28
|
+
(matchItems: Array<RankedItem<ItemType>>): Array<RankedItem<ItemType>>;
|
|
29
|
+
}
|
|
30
|
+
interface KeyAttributesOptions<ItemType> {
|
|
31
|
+
key?: string | ValueGetterKey<ItemType>;
|
|
32
|
+
threshold?: Ranking;
|
|
33
|
+
maxRanking?: Ranking;
|
|
34
|
+
minRanking?: Ranking;
|
|
35
|
+
}
|
|
36
|
+
type KeyOption<ItemType> = KeyAttributesOptions<ItemType> | ValueGetterKey<ItemType> | string;
|
|
37
|
+
interface MatchSorterOptions<ItemType = unknown> {
|
|
38
|
+
keys?: ReadonlyArray<KeyOption<ItemType>>;
|
|
39
|
+
threshold?: Ranking;
|
|
40
|
+
baseSort?: BaseSorter<ItemType>;
|
|
41
|
+
keepDiacritics?: boolean;
|
|
42
|
+
sorter?: Sorter<ItemType>;
|
|
43
|
+
}
|
|
44
|
+
declare const rankings: {
|
|
45
|
+
readonly CASE_SENSITIVE_EQUAL: 7;
|
|
46
|
+
readonly EQUAL: 6;
|
|
47
|
+
readonly STARTS_WITH: 5;
|
|
48
|
+
readonly WORD_STARTS_WITH: 4;
|
|
49
|
+
readonly CONTAINS: 3;
|
|
50
|
+
readonly ACRONYM: 2;
|
|
51
|
+
readonly MATCHES: 1;
|
|
52
|
+
readonly NO_MATCH: 0;
|
|
53
|
+
};
|
|
54
|
+
type Ranking = (typeof rankings)[keyof typeof rankings];
|
|
55
|
+
declare const defaultBaseSortFn: BaseSorter<unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Takes an array of items and a value and returns a new array with the items that match the given value
|
|
58
|
+
* @param items - the items to sort
|
|
59
|
+
* @param value - the value to use for ranking
|
|
60
|
+
* @param options - Some options to configure the sorter
|
|
61
|
+
* @returns - the new sorted array
|
|
62
|
+
*/
|
|
63
|
+
declare function matchSorter<ItemType = string>(items: ReadonlyArray<ItemType>, value: string, options?: MatchSorterOptions<ItemType>): Array<ItemType>;
|
|
64
|
+
declare namespace matchSorter {
|
|
65
|
+
var rankings: {
|
|
66
|
+
readonly CASE_SENSITIVE_EQUAL: 7;
|
|
67
|
+
readonly EQUAL: 6;
|
|
68
|
+
readonly STARTS_WITH: 5;
|
|
69
|
+
readonly WORD_STARTS_WITH: 4;
|
|
70
|
+
readonly CONTAINS: 3;
|
|
71
|
+
readonly ACRONYM: 2;
|
|
72
|
+
readonly MATCHES: 1;
|
|
73
|
+
readonly NO_MATCH: 0;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { type KeyAttributes, type KeyAttributesOptions, type KeyOption, type MatchSorterOptions, type RankingInfo, type ValueGetterKey, defaultBaseSortFn, matchSorter, rankings };
|
|
78
|
+
//# sourceMappingURL=match-sorter.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-sorter.d.mts","names":[],"sources":["../src/match-sorter.ts"],"sourcesContent":[],"mappings":";;;;UAyBU,aAAA,CAEI;EACA,SAAA,CAAA,EAFA,OAEA;EAAO,UAAA,EADP,OACO;EAEX,UAAA,EAFI,OAEO;AAIE;AAIW,UARxB,WAAA,CAUW;EAIX,WAAA,EAAU,MAAA;EAA4C,IAAA,EAZxD,OAYwD;EAAzB,QAAA,EAAA,MAAA;EAAa,YAAA,EAVpC,OAUoC,GAAA,SAAA;;AAAW,UAPrD,cASU,CAAA,QAAA,CAAA,CAAA;EACH,CAAA,IAAA,EATR,QASQ,CAAA,EAAA,MAAA,GATY,KASZ,CAAA,MAAA,CAAA;;UAPP,WAOgC,CAAA,QAAA,CAAA,CAAA;EAAX,IAAA,EANvB,QAMuB;EAAU,KAAA,EAAA,MAAA;AAAA;UAH/B,UAOsB,CAAA,QAAA,CAAA,SAPO,WAOP,EAPoB,WAOpB,CAPgC,QAOhC,CAAA,CAAA;UALtB,UAKK,CAAA,QAAA,CAAA,CAAA;EAA+C,CAAA,CAAA,EAJxD,UAIwD,CAJ7C,QAI6C,CAAA,EAAA,CAAA,EAJ/B,UAI+B,CAJpB,QAIoB,CAAA,CAAA,EAAA,MAAA;;UADpD,MACmC,CAAA,QAAA,CAAA,CAAA;EAAK,CAAA,UAAA,EAAnC,KAAmC,CAA7B,UAA6B,CAAlB,QAAkB,CAAA,CAAA,CAAA,EAAL,KAAK,CAAC,UAAD,CAAY,QAAZ,CAAA,CAAA;AAAA;UAGxC,oBACsB,CAAA,QAAA,CAAA,CAAA;EAAf,GAAA,CAAA,EAAA,MAAA,GAAA,cAAA,CAAe,QAAf,CAAA;EACH,SAAA,CAAA,EAAA,OAAA;EACC,UAAA,CAAA,EAAA,OAAA;EACA,UAAA,CAAA,EAAA,OAAA;;AAAO,KAGjB,SAAA,CAAA,QAAS,CAAA,GACV,oBADU,CACW,QADX,CAAA,GAEV,cAFU,CAEK,QAFL,CAAA,GAAA,MAAA;UAKJ,kBAJe,CAAA,WAAA,OAAA,CAAA,CAAA;EAArB,IAAA,CAAA,EAKK,aALL,CAKmB,SALnB,CAK6B,QAL7B,CAAA,CAAA;EACe,SAAA,CAAA,EAKL,OALK;EAAf,QAAA,CAAA,EAMS,UANT,CAMoB,QANpB,CAAA;EAAc,cAAA,CAAA,EAAA,OAAA;EAGR,MAAA,CAAA,EAKC,MALD,CAKQ,QALU,CAAA;;cAStB,QARiB,EAAA;EAAd,SAAA,oBAAA,EAAA,CAAA;EACK,SAAA,KAAA,EAAA,CAAA;EACU,SAAA,WAAA,EAAA,CAAA;EAAX,SAAA,gBAAA,EAAA,CAAA;EAEK,SAAA,QAAA,EAAA,CAAA;EAAP,SAAA,OAAA,EAAA,CAAA;EAAM,SAAA,OAAA,EAAA,CAAA;EAIX,SAAA,QASI,EAAA,CAAA;AAAA,CAAA;AAE4C,KAAjD,OAAA,GAEC,CAAA,OAFiB,QAGqC,CAAA,CAAA,MADnC,OAFqB,QAEX,CAAA;AAAA,cAA7B,iBAUc,EAVK,UAUL,CAAA,OAAA,CAAA;;;;;;;;AAIZ,iBAJC,WAAW,CAAA,WAAA,MAAA,CAAA,CAAA,KAAA,EACX,aADW,CACG,QADH,CAAA,EAAA,KAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAGT,kBAHS,CAGU,QAHV,CAAA,CAAA,EAIjB,KAJiB,CAIX,QAJW,CAAA;kBAAX,WAAA"}
|
package/dist/match-sorter.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import"./remove-accents
|
|
1
|
+
import{removeAccents as e}from"./remove-accents.mjs";const t={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},n=(e,t)=>String(e.rankedValue).localeCompare(String(t.rankedValue));function r(e,r,a={}){let{keys:o,threshold:s=t.MATCHES,baseSort:l=n,sorter:u=e=>e.sort((e,t)=>c(e,t,l))}=a;return u(e.reduce((e,t,n)=>d(e,t,n),[])).map(({item:e})=>e);function d(e,t,n){let c=i(t,o,r,a),{rank:l,keyThreshold:u=s}=c;return l>=u&&e.push({...c,item:t,index:n}),e}}r.rankings=t;function i(e,n,r,i){if(!n){let t=e;return{rankedValue:t,rank:a(t,r,i),keyIndex:-1,keyThreshold:i.threshold}}return f(e,n).reduce(({rank:e,rankedValue:n,keyIndex:o,keyThreshold:s},{itemValue:c,attributes:l},u)=>{let d=a(c,r,i),f=n,{minRanking:p,maxRanking:m,threshold:h}=l;return d<p&&d>=t.MATCHES?d=p:d>m&&(d=m),d>e&&(e=d,o=u,s=h,f=c),{rankedValue:f,rank:e,keyIndex:o,keyThreshold:s}},{rankedValue:e,rank:t.NO_MATCH,keyIndex:-1,keyThreshold:i.threshold})}function a(e,n,r){return e=l(e,r),n=l(n,r),n.length>e.length?t.NO_MATCH:e===n?t.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase(),n=n.toLowerCase(),e===n?t.EQUAL:e.startsWith(n)?t.STARTS_WITH:e.includes(` ${n}`)?t.WORD_STARTS_WITH:e.includes(n)?t.CONTAINS:n.length===1?t.NO_MATCH:o(e).includes(n)?t.ACRONYM:s(e,n))}function o(e){let t=``,n=e.split(` `);for(let e of n){let n=e.split(`-`);for(let e of n)t+=e.slice(0,1)}return t}function s(e,n){let r=0,i=0;function a(e,t,n){for(let i=n,a=t.length;i<a;i++)if(t[i]===e)return r+=1,i+1;return-1}function o(e){let i=1/e,a=r/n.length;return t.MATCHES+a*i}let s=a(n[0],e,0);if(s<0)return t.NO_MATCH;i=s;for(let r=1,o=n.length;r<o;r++){let o=n[r];if(i=a(o,e,i),!(i>-1))return t.NO_MATCH}return o(i-s)}function c(e,t,n){let{rank:r,keyIndex:i}=e,{rank:a,keyIndex:o}=t;return r===a?i===o?n(e,t):i<o?-1:1:r>a?-1:1}function l(t,{keepDiacritics:n}){return t=`${t}`,n||(t=e(t)),t}function u(e,t){typeof t==`object`&&(t=t.key);let n;if(typeof t==`function`)n=t(e);else if(e===null)n=null;else if(Object.hasOwnProperty.call(e,t))n=e[t];else if(t.includes(`.`))return d(t,e);else n=null;return n===null?[]:Array.isArray(n)?n:[String(n)]}function d(e,t){let n=e.split(`.`),r=[t];for(let e=0,t=n.length;e<t;e++){let t=n[e],i=[];for(let e=0,n=r.length;e<n;e++){let n=r[e];if(n!==null)if(t&&Object.hasOwnProperty.call(n,t)){let e=n[t];e!==null&&i.push(e)}else n&&t===`*`&&(i=[...i,n])}r=i}return Array.isArray(r[0])?[].concat(...r):r}function f(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r],a=m(i),o=u(e,i);for(let e=0,t=o.length;e<t;e++)n.push({itemValue:o[e],attributes:a})}return n}const p={maxRanking:1/0,minRanking:-1/0};function m(e){return typeof e==`string`?p:{...p,...e}}export{n as defaultBaseSortFn,r as matchSorter,t as rankings};
|
|
2
|
+
//# sourceMappingURL=match-sorter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-sorter.mjs","names":["defaultBaseSortFn: BaseSorter<unknown>","value: string | Array<string> | null | unknown","values: ValueA","nestedValues: ValueA","allValues: Array<{ itemValue: string; attributes: KeyAttributes }>"],"sources":["../src/match-sorter.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 { removeAccents } from \"./remove-accents\";\n\n/* eslint-disable @cspell/spellchecker */\n\n/**\n * Forked from match-sorter by Kent C. Dodds\n */\n\ninterface KeyAttributes {\n threshold?: Ranking;\n maxRanking: Ranking;\n minRanking: Ranking;\n}\ninterface RankingInfo {\n rankedValue: string;\n rank: Ranking;\n keyIndex: number;\n keyThreshold: Ranking | undefined;\n}\n\ninterface ValueGetterKey<ItemType> {\n (item: ItemType): string | Array<string>;\n}\ninterface IndexedItem<ItemType> {\n item: ItemType;\n index: number;\n}\ninterface RankedItem<ItemType> extends RankingInfo, IndexedItem<ItemType> {}\n\ninterface BaseSorter<ItemType> {\n (a: RankedItem<ItemType>, b: RankedItem<ItemType>): number;\n}\n\ninterface Sorter<ItemType> {\n (matchItems: Array<RankedItem<ItemType>>): Array<RankedItem<ItemType>>;\n}\n\ninterface KeyAttributesOptions<ItemType> {\n key?: string | ValueGetterKey<ItemType>;\n threshold?: Ranking;\n maxRanking?: Ranking;\n minRanking?: Ranking;\n}\n\ntype KeyOption<ItemType> =\n | KeyAttributesOptions<ItemType>\n | ValueGetterKey<ItemType>\n | string;\n\ninterface MatchSorterOptions<ItemType = unknown> {\n keys?: ReadonlyArray<KeyOption<ItemType>>;\n threshold?: Ranking;\n baseSort?: BaseSorter<ItemType>;\n keepDiacritics?: boolean;\n sorter?: Sorter<ItemType>;\n}\ntype IndexableByString = Record<string, unknown>;\n\nconst rankings = {\n CASE_SENSITIVE_EQUAL: 7,\n EQUAL: 6,\n STARTS_WITH: 5,\n WORD_STARTS_WITH: 4,\n CONTAINS: 3,\n ACRONYM: 2,\n MATCHES: 1,\n NO_MATCH: 0\n} as const;\n\ntype Ranking = (typeof rankings)[keyof typeof rankings];\n\nconst defaultBaseSortFn: BaseSorter<unknown> = (a, b) =>\n String(a.rankedValue).localeCompare(String(b.rankedValue));\n\n/**\n * Takes an array of items and a value and returns a new array with the items that match the given value\n * @param items - the items to sort\n * @param value - the value to use for ranking\n * @param options - Some options to configure the sorter\n * @returns - the new sorted array\n */\nfunction matchSorter<ItemType = string>(\n items: ReadonlyArray<ItemType>,\n value: string,\n options: MatchSorterOptions<ItemType> = {}\n): Array<ItemType> {\n const {\n keys,\n threshold = rankings.MATCHES,\n baseSort = defaultBaseSortFn,\n sorter = matchedItems =>\n matchedItems.sort((a, b) => sortRankedValues(a, b, baseSort))\n } = options;\n const matchedItems = items.reduce(\n (ret: Array<RankedItem<ItemType>>, item: ItemType, index: number) =>\n reduceItemsToRanked(ret, item, index),\n []\n );\n\n return sorter(matchedItems).map(({ item }) => item);\n\n function reduceItemsToRanked(\n matches: Array<RankedItem<ItemType>>,\n item: ItemType,\n index: number\n ): Array<RankedItem<ItemType>> {\n const rankingInfo = getHighestRanking(item, keys, value, options);\n const { rank, keyThreshold = threshold } = rankingInfo;\n if (rank >= keyThreshold) {\n matches.push({\n ...rankingInfo,\n item,\n index\n });\n }\n return matches;\n }\n}\n\nmatchSorter.rankings = rankings;\n\n/**\n * Gets the highest ranking for value for the given item based on its values for the given keys\n * @param item - the item to rank\n * @param keys - the keys to get values from the item for the ranking\n * @param value - the value to rank against\n * @param options - options to control the ranking\n * @returns The highest ranking\n */\nfunction getHighestRanking<ItemType>(\n item: ItemType,\n keys: ReadonlyArray<KeyOption<ItemType>> | undefined,\n value: string,\n options: MatchSorterOptions<ItemType>\n): RankingInfo {\n if (!keys) {\n // if keys is not specified, then we assume the item given is ready to be matched\n const stringItem = item as unknown as string;\n\n return {\n // ends up being duplicate of 'item' in matches but consistent\n rankedValue: stringItem,\n rank: getMatchRanking(stringItem, value, options),\n keyIndex: -1,\n keyThreshold: options.threshold\n };\n }\n const valuesToRank = getAllValuesToRank(item, keys);\n\n return valuesToRank.reduce(\n (\n { rank, rankedValue, keyIndex, keyThreshold },\n { itemValue, attributes },\n i\n ) => {\n let newRank = getMatchRanking(itemValue, value, options);\n let newRankedValue = rankedValue;\n const { minRanking, maxRanking, threshold } = attributes;\n if (newRank < minRanking && newRank >= rankings.MATCHES) {\n newRank = minRanking;\n } else if (newRank > maxRanking) {\n newRank = maxRanking;\n }\n if (newRank > rank) {\n rank = newRank;\n keyIndex = i;\n keyThreshold = threshold;\n newRankedValue = itemValue;\n }\n return {\n rankedValue: newRankedValue,\n rank,\n keyIndex,\n keyThreshold\n };\n },\n {\n rankedValue: item as unknown as string,\n rank: rankings.NO_MATCH as Ranking,\n keyIndex: -1,\n keyThreshold: options.threshold\n }\n );\n}\n\n/**\n * Gives a rankings score based on how well the two strings match.\n * @param testString - the string to test against\n * @param stringToRank - the string to rank\n * @param options - options for the match (like keepDiacritics for comparison)\n * @returns the ranking for how well stringToRank matches testString\n */\nfunction getMatchRanking<ItemType>(\n testString: string,\n stringToRank: string,\n options: MatchSorterOptions<ItemType>\n): Ranking {\n testString = prepareValueForComparison(testString, options);\n stringToRank = prepareValueForComparison(stringToRank, options);\n\n // too long\n if (stringToRank.length > testString.length) {\n return rankings.NO_MATCH;\n }\n\n // case sensitive equals\n if (testString === stringToRank) {\n return rankings.CASE_SENSITIVE_EQUAL;\n }\n\n // Lower casing before further comparison\n testString = testString.toLowerCase();\n stringToRank = stringToRank.toLowerCase();\n\n // case insensitive equals\n if (testString === stringToRank) {\n return rankings.EQUAL;\n }\n\n // starts with\n if (testString.startsWith(stringToRank)) {\n return rankings.STARTS_WITH;\n }\n\n // word starts with\n if (testString.includes(` ${stringToRank}`)) {\n return rankings.WORD_STARTS_WITH;\n }\n\n // contains\n if (testString.includes(stringToRank)) {\n return rankings.CONTAINS;\n } else if (stringToRank.length === 1) {\n // If the only character in the given stringToRank\n // isn't even contained in the testString, then\n // it's definitely not a match.\n return rankings.NO_MATCH;\n }\n\n // acronym\n if (getAcronym(testString).includes(stringToRank)) {\n return rankings.ACRONYM;\n }\n\n // will return a number between rankings.MATCHES and\n // rankings.MATCHES + 1 depending on how close of a match it is.\n return getClosenessRanking(testString, stringToRank);\n}\n\n/**\n * Generates an acronym for a string.\n *\n * @param value - the string for which to produce the acronym\n * @returns the acronym\n */\nfunction getAcronym(value: string): string {\n let acronym = \"\";\n const wordsInString = value.split(\" \");\n for (const wordInString of wordsInString) {\n const splitByHyphenWords = wordInString.split(\"-\");\n for (const splitByHyphenWord of splitByHyphenWords) {\n acronym += splitByHyphenWord.slice(0, 1);\n }\n }\n return acronym;\n}\n\n/**\n * Returns a score based on how spread apart the\n * characters from the stringToRank are within the testString.\n * A number close to rankings.MATCHES represents a loose match. A number close\n * to rankings.MATCHES + 1 represents a tighter match.\n * @param testString - the string to test against\n * @param stringToRank - the string to rank\n * @returns the number between rankings.MATCHES and\n * rankings.MATCHES + 1 for how well stringToRank matches testString\n */\nfunction getClosenessRanking(\n testString: string,\n stringToRank: string\n): Ranking {\n let matchingInOrderCharCount = 0;\n let charNumber = 0;\n function findMatchingCharacter(\n matchChar: string,\n string: string,\n index: number\n ) {\n for (let j = index, J = string.length; j < J; j++) {\n const stringChar = string[j];\n if (stringChar === matchChar) {\n matchingInOrderCharCount += 1;\n return j + 1;\n }\n }\n return -1;\n }\n function getRanking(spread: number) {\n const spreadPercentage = 1 / spread;\n const inOrderPercentage = matchingInOrderCharCount / stringToRank.length;\n const ranking = rankings.MATCHES + inOrderPercentage * spreadPercentage;\n\n return ranking as Ranking;\n }\n const firstIndex = findMatchingCharacter(stringToRank[0]!, testString, 0);\n if (firstIndex < 0) {\n return rankings.NO_MATCH;\n }\n charNumber = firstIndex;\n for (let i = 1, I = stringToRank.length; i < I; i++) {\n const matchChar = stringToRank[i];\n charNumber = findMatchingCharacter(matchChar!, testString, charNumber);\n const found = charNumber > -1;\n if (!found) {\n return rankings.NO_MATCH;\n }\n }\n\n const spread = charNumber - firstIndex;\n\n return getRanking(spread);\n}\n\n/**\n * Sorts items that have a rank, index, and keyIndex\n * @param a - the first item to sort\n * @param b - the second item to sort\n * @returns -1 if a should come first, 1 if b should come first, 0 if equal\n */\nfunction sortRankedValues<ItemType>(\n a: RankedItem<ItemType>,\n b: RankedItem<ItemType>,\n baseSort: BaseSorter<ItemType>\n): number {\n const aFirst = -1;\n const bFirst = 1;\n const { rank: aRank, keyIndex: aKeyIndex } = a;\n const { rank: bRank, keyIndex: bKeyIndex } = b;\n const same = aRank === bRank;\n if (same) {\n if (aKeyIndex === bKeyIndex) {\n // use the base sort function as a tie-breaker\n return baseSort(a, b);\n }\n return aKeyIndex < bKeyIndex ? aFirst : bFirst;\n }\n return aRank > bRank ? aFirst : bFirst;\n}\n\n/**\n * Prepares value for comparison by stringifying it, removing diacritics (if specified)\n * @param value - the value to clean\n * @param options - options for the match (like keepDiacritics for comparison)\n * @returns the prepared value\n */\nfunction prepareValueForComparison<ItemType>(\n value: string,\n { keepDiacritics }: MatchSorterOptions<ItemType>\n): string {\n // value might not actually be a string at this point (we don't get to choose)\n // so part of preparing the value for comparison is ensure that it is a string\n value = `${value}`; // toString\n if (!keepDiacritics) {\n value = removeAccents(value);\n }\n return value;\n}\n\n/**\n * Gets value for key in item at arbitrarily nested keypath\n * @param item - the item\n * @param key - the potentially nested keypath or property callback\n * @returns - an array containing the value(s) at the nested keypath\n */\nfunction getItemValues<ItemType>(\n item: ItemType,\n key: KeyOption<ItemType>\n): Array<string> {\n if (typeof key === \"object\") {\n key = key.key as string;\n }\n let value: string | Array<string> | null | unknown;\n if (typeof key === \"function\") {\n value = key(item);\n } else if (item === null) {\n value = null;\n } else if (Object.hasOwnProperty.call(item, key)) {\n value = (item as IndexableByString)[key];\n } else if (key.includes(\".\")) {\n return getNestedValues<ItemType>(key, item);\n } else {\n value = null;\n }\n\n // because `value` can also be undefined\n if (value === null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [String(value)];\n}\n\n/**\n * Given path: \"foo.bar.baz\"\n * And item: \\{foo: \\{bar: \\{baz: 'buzz'\\}\\}\\}\n * -\\> 'buzz'\n *\n * @param path - a dot-separated set of keys\n * @param item - the item to get the value from\n */\nfunction getNestedValues<ItemType>(\n path: string,\n item: ItemType\n): Array<string> {\n const keys = path.split(\".\");\n\n type ValueA = Array<ItemType | IndexableByString | string>;\n let values: ValueA = [item];\n\n for (let i = 0, I = keys.length; i < I; i++) {\n const nestedKey = keys[i];\n let nestedValues: ValueA = [];\n\n for (let j = 0, J = values.length; j < J; j++) {\n const nestedItem = values[j];\n\n if (nestedItem === null) {\n continue;\n }\n\n if (nestedKey && Object.hasOwnProperty.call(nestedItem, nestedKey)) {\n const nestedValue = (nestedItem as IndexableByString)[nestedKey];\n if (nestedValue !== null) {\n nestedValues.push(nestedValue as IndexableByString | string);\n }\n } else if (nestedItem && nestedKey === \"*\") {\n // ensure that values is an array\n nestedValues = [...nestedValues, nestedItem];\n }\n }\n\n values = nestedValues;\n }\n\n if (Array.isArray(values[0])) {\n // keep allowing the implicit wildcard for an array of strings at the end of\n // the path; don't use `.flat()` because that's not available in node.js v10\n const result: Array<string> = [];\n\n return result.concat(...(values as Array<string>));\n }\n // Based on our logic it should be an array of strings by now...\n // assuming the user's path terminated in strings\n return values as Array<string>;\n}\n\n/**\n * Gets all the values for the given keys in the given item and returns an array of those values\n * @param item - the item from which the values will be retrieved\n * @param keys - the keys to use to retrieve the values\n * @returns objects with \\{itemValue, attributes\\}\n */\nfunction getAllValuesToRank<ItemType>(\n item: ItemType,\n keys: ReadonlyArray<KeyOption<ItemType>>\n) {\n const allValues: Array<{ itemValue: string; attributes: KeyAttributes }> = [];\n for (let j = 0, J = keys.length; j < J; j++) {\n const key = keys[j];\n const attributes = getKeyAttributes(key!);\n const itemValues = getItemValues(item, key!);\n for (let i = 0, I = itemValues.length; i < I; i++) {\n allValues.push({\n itemValue: itemValues[i]!,\n attributes\n });\n }\n }\n return allValues;\n}\n\nconst defaultKeyAttributes = {\n maxRanking: Infinity as Ranking,\n minRanking: -Infinity as Ranking\n};\n/**\n * Gets all the attributes for the given key\n * @param key - the key from which the attributes will be retrieved\n * @returns object containing the key's attributes\n */\nfunction getKeyAttributes<ItemType>(key: KeyOption<ItemType>): KeyAttributes {\n if (typeof key === \"string\") {\n return defaultKeyAttributes;\n }\n return {\n ...defaultKeyAttributes,\n ...key\n };\n}\n\nexport { defaultBaseSortFn, matchSorter, rankings };\n\nexport type {\n KeyAttributes,\n KeyAttributesOptions,\n KeyOption,\n MatchSorterOptions,\n RankingInfo,\n ValueGetterKey\n};\n"],"mappings":"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"}
|
package/dist/memoize.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=
|
|
1
|
+
const e=e=>{let t=Object.prototype.hasOwnProperty,n={};return r=>t.call(n,r)?n[r]:n[r]=e(r)};exports.memoizeOnId=e;
|
package/dist/memoize.d.cts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/memoize.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Memoizes a function based on its string identifier.
|
|
4
|
+
*
|
|
5
|
+
* @param fn - The function to memoize.
|
|
6
|
+
* @returns A memoized version of the input function.
|
|
7
|
+
*/
|
|
8
|
+
declare const memoizeOnId: <T>(fn: (id: string) => T) => (id: string) => T | undefined;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { memoizeOnId };
|
|
11
|
+
//# sourceMappingURL=memoize.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoize.d.cts","names":[],"sources":["../src/memoize.ts"],"sourcesContent":[],"mappings":";;AAwBA;;;;;cAAa,qCAAsC,sBAKnB"}
|
package/dist/memoize.d.mts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/memoize.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Memoizes a function based on its string identifier.
|
|
4
|
+
*
|
|
5
|
+
* @param fn - The function to memoize.
|
|
6
|
+
* @returns A memoized version of the input function.
|
|
7
|
+
*/
|
|
8
|
+
declare const memoizeOnId: <T>(fn: (id: string) => T) => (id: string) => T | undefined;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { memoizeOnId };
|
|
11
|
+
//# sourceMappingURL=memoize.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoize.d.mts","names":[],"sources":["../src/memoize.ts"],"sourcesContent":[],"mappings":";;AAwBA;;;;;cAAa,qCAAsC,sBAKnB"}
|
package/dist/memoize.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=e=>{let t=Object.prototype.hasOwnProperty,n={};return r=>t.call(n,r)?n[r]:n[r]=e(r)};export{e as memoizeOnId};
|
|
2
|
+
//# sourceMappingURL=memoize.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoize.mjs","names":["results: Record<string, T>"],"sources":["../src/memoize.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 * Memoizes a function based on its string identifier.\n *\n * @param fn - The function to memoize.\n * @returns A memoized version of the input function.\n */\nexport const memoizeOnId = <T>(fn: (id: string) => T) => {\n // eslint-disable-next-line ts/unbound-method\n const hasOwnProperty = Object.prototype.hasOwnProperty;\n const results: Record<string, T> = {};\n\n const memoizedFn = (id: string) => {\n if (hasOwnProperty.call(results, id)) {\n return results[id];\n }\n return (results[id] = fn(id));\n };\n\n return memoizedFn;\n};\n"],"mappings":"AAwBA,MAAa,EAAkB,GAA0B,CAEvD,IAAM,EAAiB,OAAO,UAAU,eAClCA,EAA6B,EAAE,CASrC,MAPoB,IACd,EAAe,KAAK,EAAS,EAAG,CAC3B,EAAQ,GAET,EAAQ,GAAM,EAAG,EAAG"}
|
package/dist/mutex.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./
|
|
1
|
+
const e=require(`./semaphore.cjs`);var t=class{semaphore=new e.Semaphore(1);get isLocked(){return this.semaphore.available===0}async acquire(){return this.semaphore.acquire()}release(){this.semaphore.release()}};exports.Mutex=t;
|
package/dist/mutex.d.cts
CHANGED
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/mutex.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A Mutex (mutual exclusion lock) for async functions.
|
|
4
|
+
* It allows only one async task to access a critical section at a time.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const mutex = new Mutex();
|
|
9
|
+
*
|
|
10
|
+
* async function criticalSection() {
|
|
11
|
+
* await mutex.acquire();
|
|
12
|
+
* try {
|
|
13
|
+
* // This code section cannot be executed simultaneously
|
|
14
|
+
* } finally {
|
|
15
|
+
* mutex.release();
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* criticalSection();
|
|
20
|
+
* criticalSection(); // This call will wait until the first call releases the mutex.
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare class Mutex {
|
|
24
|
+
private semaphore;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the mutex is currently locked.
|
|
27
|
+
* @returns True if the mutex is locked, false otherwise.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const mutex = new Mutex();
|
|
31
|
+
* console.log(mutex.isLocked); // false
|
|
32
|
+
* await mutex.acquire();
|
|
33
|
+
* console.log(mutex.isLocked); // true
|
|
34
|
+
* mutex.release();
|
|
35
|
+
* console.log(mutex.isLocked); // false
|
|
36
|
+
*/
|
|
37
|
+
get isLocked(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Acquires the mutex, blocking if necessary until it is available.
|
|
40
|
+
* @returns A promise that resolves when the mutex is acquired.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const mutex = new Mutex();
|
|
45
|
+
* await mutex.acquire();
|
|
46
|
+
* try {
|
|
47
|
+
* // This code section cannot be executed simultaneously
|
|
48
|
+
* } finally {
|
|
49
|
+
* mutex.release();
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
acquire(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Releases the mutex, allowing another waiting task to proceed.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const mutex = new Mutex();
|
|
60
|
+
* await mutex.acquire();
|
|
61
|
+
* try {
|
|
62
|
+
* // This code section cannot be executed simultaneously
|
|
63
|
+
* } finally {
|
|
64
|
+
* mutex.release(); // Allows another waiting task to proceed.
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
release(): void;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { Mutex };
|
|
72
|
+
//# sourceMappingURL=mutex.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutex.d.cts","names":[],"sources":["../src/mutex.ts"],"sourcesContent":[],"mappings":";;AAyCA;;;;;;;;;;;;;;;;;;;;cAAa,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAkCa"}
|
package/dist/mutex.d.mts
CHANGED
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/mutex.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A Mutex (mutual exclusion lock) for async functions.
|
|
4
|
+
* It allows only one async task to access a critical section at a time.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const mutex = new Mutex();
|
|
9
|
+
*
|
|
10
|
+
* async function criticalSection() {
|
|
11
|
+
* await mutex.acquire();
|
|
12
|
+
* try {
|
|
13
|
+
* // This code section cannot be executed simultaneously
|
|
14
|
+
* } finally {
|
|
15
|
+
* mutex.release();
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* criticalSection();
|
|
20
|
+
* criticalSection(); // This call will wait until the first call releases the mutex.
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare class Mutex {
|
|
24
|
+
private semaphore;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the mutex is currently locked.
|
|
27
|
+
* @returns True if the mutex is locked, false otherwise.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const mutex = new Mutex();
|
|
31
|
+
* console.log(mutex.isLocked); // false
|
|
32
|
+
* await mutex.acquire();
|
|
33
|
+
* console.log(mutex.isLocked); // true
|
|
34
|
+
* mutex.release();
|
|
35
|
+
* console.log(mutex.isLocked); // false
|
|
36
|
+
*/
|
|
37
|
+
get isLocked(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Acquires the mutex, blocking if necessary until it is available.
|
|
40
|
+
* @returns A promise that resolves when the mutex is acquired.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const mutex = new Mutex();
|
|
45
|
+
* await mutex.acquire();
|
|
46
|
+
* try {
|
|
47
|
+
* // This code section cannot be executed simultaneously
|
|
48
|
+
* } finally {
|
|
49
|
+
* mutex.release();
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
acquire(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Releases the mutex, allowing another waiting task to proceed.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const mutex = new Mutex();
|
|
60
|
+
* await mutex.acquire();
|
|
61
|
+
* try {
|
|
62
|
+
* // This code section cannot be executed simultaneously
|
|
63
|
+
* } finally {
|
|
64
|
+
* mutex.release(); // Allows another waiting task to proceed.
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
release(): void;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { Mutex };
|
|
72
|
+
//# sourceMappingURL=mutex.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutex.d.mts","names":[],"sources":["../src/mutex.ts"],"sourcesContent":[],"mappings":";;AAyCA;;;;;;;;;;;;;;;;;;;;cAAa,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAkCa"}
|
package/dist/mutex.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Semaphore as e}from"./semaphore.mjs";var t=class{semaphore=new e(1);get isLocked(){return this.semaphore.available===0}async acquire(){return this.semaphore.acquire()}release(){this.semaphore.release()}};export{t as Mutex};
|
|
2
|
+
//# sourceMappingURL=mutex.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutex.mjs","names":[],"sources":["../src/mutex.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\nimport { Semaphore } from \"./semaphore\";\n\n/**\n * A Mutex (mutual exclusion lock) for async functions.\n * It allows only one async task to access a critical section at a time.\n *\n * @example\n * ```typescript\n * const mutex = new Mutex();\n *\n * async function criticalSection() {\n * await mutex.acquire();\n * try {\n * // This code section cannot be executed simultaneously\n * } finally {\n * mutex.release();\n * }\n * }\n *\n * criticalSection();\n * criticalSection(); // This call will wait until the first call releases the mutex.\n * ```\n */\nexport class Mutex {\n private semaphore = new Semaphore(1);\n\n /**\n * Checks if the mutex is currently locked.\n * @returns True if the mutex is locked, false otherwise.\n *\n * @example\n * const mutex = new Mutex();\n * console.log(mutex.isLocked); // false\n * await mutex.acquire();\n * console.log(mutex.isLocked); // true\n * mutex.release();\n * console.log(mutex.isLocked); // false\n */\n public get isLocked(): boolean {\n return this.semaphore.available === 0;\n }\n\n /**\n * Acquires the mutex, blocking if necessary until it is available.\n * @returns A promise that resolves when the mutex is acquired.\n *\n * @example\n * ```typescript\n * const mutex = new Mutex();\n * await mutex.acquire();\n * try {\n * // This code section cannot be executed simultaneously\n * } finally {\n * mutex.release();\n * }\n * ```\n */\n public async acquire(): Promise<void> {\n return this.semaphore.acquire();\n }\n\n /**\n * Releases the mutex, allowing another waiting task to proceed.\n *\n * @example\n * ```typescript\n * const mutex = new Mutex();\n * await mutex.acquire();\n * try {\n * // This code section cannot be executed simultaneously\n * } finally {\n * mutex.release(); // Allows another waiting task to proceed.\n * }\n * ```\n */\n public release(): void {\n this.semaphore.release();\n }\n}\n"],"mappings":"4CAyCA,IAAa,EAAb,KAAmB,CACjB,UAAoB,IAAI,EAAU,EAAE,CAcpC,IAAW,UAAoB,CAC7B,OAAO,KAAK,UAAU,YAAc,EAkBtC,MAAa,SAAyB,CACpC,OAAO,KAAK,UAAU,SAAS,CAiBjC,SAAuB,CACrB,KAAK,UAAU,SAAS"}
|
package/dist/noop.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=
|
|
1
|
+
const e=e=>{};async function t(e){}exports.asyncNoop=t,exports.noop=e;
|
package/dist/noop.d.cts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/noop.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A no op, or no-op, function for no operation
|
|
4
|
+
*
|
|
5
|
+
* @remarks Please see {@link https://dev.to/praneshpsg239/noop-in-javascript-478h | this article} for more information.
|
|
6
|
+
*
|
|
7
|
+
* @param _params - An optional parameter passed to the function. It can be anything (but is not used in any way)
|
|
8
|
+
*/
|
|
9
|
+
declare const noop: (_params?: unknown) => void;
|
|
10
|
+
/**
|
|
11
|
+
* An asynchronous no-operation function that does nothing.
|
|
12
|
+
* This can be used as a placeholder or default function.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* asyncNoop(); // Does nothing
|
|
16
|
+
*
|
|
17
|
+
* @returns This function returns a Promise that resolves to undefined.
|
|
18
|
+
*/
|
|
19
|
+
declare function asyncNoop(_params?: unknown): Promise<void>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { asyncNoop, noop };
|
|
22
|
+
//# sourceMappingURL=noop.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.d.cts","names":[],"sources":["../src/noop.ts"],"sourcesContent":[],"mappings":";;AAwBA;AAWA;;;;;cAXa;;;;;;;;;;iBAWS,SAAA,qBAA8B"}
|
package/dist/noop.d.mts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/noop.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A no op, or no-op, function for no operation
|
|
4
|
+
*
|
|
5
|
+
* @remarks Please see {@link https://dev.to/praneshpsg239/noop-in-javascript-478h | this article} for more information.
|
|
6
|
+
*
|
|
7
|
+
* @param _params - An optional parameter passed to the function. It can be anything (but is not used in any way)
|
|
8
|
+
*/
|
|
9
|
+
declare const noop: (_params?: unknown) => void;
|
|
10
|
+
/**
|
|
11
|
+
* An asynchronous no-operation function that does nothing.
|
|
12
|
+
* This can be used as a placeholder or default function.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* asyncNoop(); // Does nothing
|
|
16
|
+
*
|
|
17
|
+
* @returns This function returns a Promise that resolves to undefined.
|
|
18
|
+
*/
|
|
19
|
+
declare function asyncNoop(_params?: unknown): Promise<void>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { asyncNoop, noop };
|
|
22
|
+
//# sourceMappingURL=noop.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.d.mts","names":[],"sources":["../src/noop.ts"],"sourcesContent":[],"mappings":";;AAwBA;AAWA;;;;;cAXa;;;;;;;;;;iBAWS,SAAA,qBAA8B"}
|
package/dist/noop.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=e=>{};async function t(e){}export{t as asyncNoop,e as noop};
|
|
2
|
+
//# sourceMappingURL=noop.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.mjs","names":[],"sources":["../src/noop.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 * A no op, or no-op, function for no operation\n *\n * @remarks Please see {@link https://dev.to/praneshpsg239/noop-in-javascript-478h | this article} for more information.\n *\n * @param _params - An optional parameter passed to the function. It can be anything (but is not used in any way)\n */\nexport const noop = (_params?: unknown): void => {};\n\n/**\n * An asynchronous no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * asyncNoop(); // Does nothing\n *\n * @returns This function returns a Promise that resolves to undefined.\n */\nexport async function asyncNoop(_params?: unknown): Promise<void> {}\n"],"mappings":"AAwBA,MAAa,EAAQ,GAA4B,GAWjD,eAAsB,EAAU,EAAkC"}
|
package/dist/omit.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];r&&delete n[r]}return n}exports.omit=e;
|
package/dist/omit.d.cts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/omit.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new object with specified keys omitted.
|
|
4
|
+
*
|
|
5
|
+
* This function takes an object and an array of keys, and returns a new object that
|
|
6
|
+
* excludes the properties corresponding to the specified keys.
|
|
7
|
+
*
|
|
8
|
+
* @param obj - The object to omit keys from.
|
|
9
|
+
* @param keys - An array of keys to be omitted from the object.
|
|
10
|
+
* @returns A new object with the specified keys omitted.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
15
|
+
* const result = omit(obj, ['b', 'c']);
|
|
16
|
+
* // result will be { a: 1 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { omit };
|
|
22
|
+
//# sourceMappingURL=omit.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.d.cts","names":[],"sources":["../src/omit.ts"],"sourcesContent":[],"mappings":";;AAmCA;;;;;;;;;;;;;;;;iBAAgB,eAAe,qCAAqC,QAC7D,kBACU,MACd,KAAK,GAAG"}
|
package/dist/omit.d.mts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/omit.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new object with specified keys omitted.
|
|
4
|
+
*
|
|
5
|
+
* This function takes an object and an array of keys, and returns a new object that
|
|
6
|
+
* excludes the properties corresponding to the specified keys.
|
|
7
|
+
*
|
|
8
|
+
* @param obj - The object to omit keys from.
|
|
9
|
+
* @param keys - An array of keys to be omitted from the object.
|
|
10
|
+
* @returns A new object with the specified keys omitted.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
15
|
+
* const result = omit(obj, ['b', 'c']);
|
|
16
|
+
* // result will be { a: 1 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { omit };
|
|
22
|
+
//# sourceMappingURL=omit.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.d.mts","names":[],"sources":["../src/omit.ts"],"sourcesContent":[],"mappings":";;AAmCA;;;;;;;;;;;;;;;;iBAAgB,eAAe,qCAAqC,QAC7D,kBACU,MACd,KAAK,GAAG"}
|
package/dist/omit.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];r&&delete n[r]}return n}export{e as omit};
|
|
2
|
+
//# sourceMappingURL=omit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.mjs","names":[],"sources":["../src/omit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software \n\n This code was released as part of a Storm Software project. The project\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/license.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software\n Documentation: https://stormsoftware.com/docs\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @param obj - The object to omit keys from.\n * @param keys - An array of keys to be omitted from the object.\n * @returns A new object with the specified keys omitted.\n *\n * @example\n * ```typescript\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n * ```\n */\nexport function omit<T extends Record<string, any>, K extends keyof T>(\n obj: T,\n keys: readonly K[]\n): Omit<T, K> {\n const result = { ...obj };\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (key) {\n delete result[key];\n }\n }\n\n return result as Omit<T, K>;\n}\n"],"mappings":"AAmCA,SAAgB,EACd,EACA,EACY,CACZ,IAAM,EAAS,CAAE,GAAG,EAAK,CAEzB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAAK,CACpC,IAAM,EAAM,EAAK,GACb,GACF,OAAO,EAAO,GAIlB,OAAO"}
|
package/dist/once.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){return e}function t(t){let n,r=!1;return e(function(...e){return r||=(n=t.apply(this,e),!0),n})}exports.once=t,exports.safeFunctionCast=e;
|
package/dist/once.d.cts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/once.d.ts
|
|
2
|
+
/** silence "error TS2322" but practically this is safer and more convenient than resorting to `any` in a random place */
|
|
3
|
+
declare function safeFunctionCast<TFunc extends (...args: any[]) => any>(fn: (...args: Parameters<TFunc>) => ReturnType<TFunc>): TFunc;
|
|
4
|
+
/**
|
|
5
|
+
* Executes a function only once.
|
|
6
|
+
*
|
|
7
|
+
* @param fn - The function to be executed only once.
|
|
8
|
+
* @returns A function that, when called, will execute the original function only once.
|
|
9
|
+
*/
|
|
10
|
+
declare function once<TFunc extends (...args: any[]) => any>(fn: TFunc): TFunc;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { once, safeFunctionCast };
|
|
13
|
+
//# sourceMappingURL=once.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"once.d.cts","names":[],"sources":["../src/once.ts"],"sourcesContent":[],"mappings":";;AAmBgB,iBAAA,gBAAgB,CAAA,cAAA,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GAAA,GAAA,CAAA,CAAA,EAAA,EAAA,CAAA,GAAA,IAAA,EAChB,UADgB,CACL,KADK,CAAA,EAAA,GACM,UADN,CACiB,KADjB,CAAA,CAAA,EAE7B,KAF6B;;;;;;;AAehB,iBAAA,IAAgD,CAAA,cAAa,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GAAA,GAAA,CAAA,CAAA,EAAA,EAAb,KAAa,CAAA,EAAL,KAAK"}
|
package/dist/once.d.mts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/once.d.ts
|
|
2
|
+
/** silence "error TS2322" but practically this is safer and more convenient than resorting to `any` in a random place */
|
|
3
|
+
declare function safeFunctionCast<TFunc extends (...args: any[]) => any>(fn: (...args: Parameters<TFunc>) => ReturnType<TFunc>): TFunc;
|
|
4
|
+
/**
|
|
5
|
+
* Executes a function only once.
|
|
6
|
+
*
|
|
7
|
+
* @param fn - The function to be executed only once.
|
|
8
|
+
* @returns A function that, when called, will execute the original function only once.
|
|
9
|
+
*/
|
|
10
|
+
declare function once<TFunc extends (...args: any[]) => any>(fn: TFunc): TFunc;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { once, safeFunctionCast };
|
|
13
|
+
//# sourceMappingURL=once.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"once.d.mts","names":[],"sources":["../src/once.ts"],"sourcesContent":[],"mappings":";;AAmBgB,iBAAA,gBAAgB,CAAA,cAAA,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GAAA,GAAA,CAAA,CAAA,EAAA,EAAA,CAAA,GAAA,IAAA,EAChB,UADgB,CACL,KADK,CAAA,EAAA,GACM,UADN,CACiB,KADjB,CAAA,CAAA,EAE7B,KAF6B;;;;;;;AAehB,iBAAA,IAAgD,CAAA,cAAa,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GAAA,GAAA,CAAA,CAAA,EAAA,EAAb,KAAa,CAAA,EAAL,KAAK"}
|
package/dist/once.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){return e}function t(t){let n,r=!1;return e(function(...e){return r||=(n=t.apply(this,e),!0),n})}export{t as once,e as safeFunctionCast};
|
|
2
|
+
//# sourceMappingURL=once.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"once.mjs","names":["result: ReturnType<TFunc>"],"sources":["../src/once.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/** silence \"error TS2322\" but practically this is safer and more convenient than resorting to `any` in a random place */\nexport function safeFunctionCast<TFunc extends (...args: any[]) => any>(\n fn: (...args: Parameters<TFunc>) => ReturnType<TFunc>\n): TFunc {\n // @ts-expect-error\n // error TS2322: Type '(...args: Parameters<F>) => ReturnType<F>' is not assignable to type 'F'.\n // '(...args: Parameters<F>) => ReturnType<F>' is assignable to the constraint of type 'F', but 'F' could be instantiated with a different subtype of constraint '(...args: any[]) => any'.\n return fn;\n}\n\n/**\n * Executes a function only once.\n *\n * @param fn - The function to be executed only once.\n * @returns A function that, when called, will execute the original function only once.\n */\nexport function once<TFunc extends (...args: any[]) => any>(fn: TFunc): TFunc {\n let result: ReturnType<TFunc>;\n let called = false;\n\n // eslint-disable-next-line func-names\n return safeFunctionCast<TFunc>(function (this: unknown, ...args) {\n if (!called) {\n result = fn.apply(this, args);\n called = true;\n }\n return result;\n });\n}\n"],"mappings":"AAmBA,SAAgB,EACd,EACO,CAIP,OAAO,EAST,SAAgB,EAA4C,EAAkB,CAC5E,IAAIA,EACA,EAAS,GAGb,OAAO,EAAwB,SAAyB,GAAG,EAAM,CAK/D,MAJA,CAEE,KADA,EAAS,EAAG,MAAM,KAAM,EAAK,CACpB,IAEJ,GACP"}
|
package/dist/pick.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t){let n={};for(let r=0;r<t.length;r++){let i=t[r];i&&Object.hasOwn(e,i)&&(n[i]=e[i])}return n}exports.pick=e;
|
package/dist/pick.d.cts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/pick.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new object composed of the picked object properties.
|
|
4
|
+
*
|
|
5
|
+
* This function takes an object and an array of keys, and returns a new object that
|
|
6
|
+
* includes only the properties corresponding to the specified keys.
|
|
7
|
+
*
|
|
8
|
+
* @param obj - The object to pick keys from.
|
|
9
|
+
* @param keys - An array of keys to be picked from the object.
|
|
10
|
+
* @returns A new object with the specified keys picked.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
15
|
+
* const result = pick(obj, ['a', 'c']);
|
|
16
|
+
* // result will be { a: 1, c: 3 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Pick<T, K>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { pick };
|
|
22
|
+
//# sourceMappingURL=pick.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.d.cts","names":[],"sources":["../src/pick.ts"],"sourcesContent":[],"mappings":";;AAmCA;;;;;;;;;;;;;;;;iBAAgB,eAAe,qCAAqC,QAC7D,kBACU,MACd,KAAK,GAAG"}
|