ts-data-forge 5.0.1 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -50
- package/dist/array/impl/array-utils-creation.d.mts +14 -0
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs +12 -0
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts +10 -0
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +6 -0
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.d.mts +14 -0
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +34 -10
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +34 -4
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts +20 -7
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +20 -7
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +5 -2
- package/dist/array/impl/array-utils-size.d.mts.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +5 -2
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.d.mts +2 -0
- package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts +17 -2
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +9 -2
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +27 -0
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +6 -0
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts +35 -18
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +25 -14
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +35 -15
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +5 -3
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +46 -19
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +9 -2
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +48 -19
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +9 -2
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts +65 -25
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +13 -5
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts +60 -25
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +12 -5
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +1 -1
- package/dist/functional/match.d.mts +1 -1
- package/dist/functional/match.d.mts.map +1 -1
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts +3 -2
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-filter.d.mts +3 -0
- package/dist/functional/optional/impl/optional-filter.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.d.mts +2 -0
- package/dist/functional/optional/impl/optional-flat-map.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.d.mts +2 -0
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +2 -0
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.d.mts +1 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +1 -1
- package/dist/functional/optional/impl/optional-is-optional.d.mts +4 -2
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +4 -2
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts +2 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +2 -1
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-map.d.mts +2 -0
- package/dist/functional/optional/impl/optional-map.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-none.d.mts +4 -2
- package/dist/functional/optional/impl/optional-none.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +4 -2
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.d.mts +4 -0
- package/dist/functional/optional/impl/optional-or-else.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-some.d.mts +5 -3
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +4 -2
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +4 -2
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +4 -2
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +7 -4
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +2 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +2 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.d.mts +4 -2
- package/dist/functional/optional/impl/optional-unwrap.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-zip.d.mts +3 -1
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +3 -1
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/pipe.d.mts +2 -2
- package/dist/functional/result/impl/result-err.d.mts +4 -2
- package/dist/functional/result/impl/result-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +3 -1
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.d.mts +3 -2
- package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.d.mts +5 -0
- package/dist/functional/result/impl/result-flat-map.d.mts.map +1 -1
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-fold.d.mts +4 -0
- package/dist/functional/result/impl/result-fold.d.mts.map +1 -1
- package/dist/functional/result/impl/result-fold.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.d.mts +4 -1
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +4 -1
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts +3 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +3 -1
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.d.mts +4 -2
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +4 -2
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.d.mts +4 -2
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +4 -2
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.d.mts +7 -3
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +7 -3
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
- package/dist/functional/result/impl/result-map-err.d.mts +3 -0
- package/dist/functional/result/impl/result-map-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-map.d.mts +4 -0
- package/dist/functional/result/impl/result-map.d.mts.map +1 -1
- package/dist/functional/result/impl/result-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-ok.d.mts +4 -2
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +3 -1
- package/dist/functional/result/impl/result-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-or-else.d.mts +4 -0
- package/dist/functional/result/impl/result-or-else.d.mts.map +1 -1
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
- package/dist/functional/result/impl/result-swap.d.mts +2 -0
- package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
- package/dist/functional/result/impl/result-swap.mjs +2 -0
- package/dist/functional/result/impl/result-swap.mjs.map +1 -1
- package/dist/functional/result/impl/result-to-optional.d.mts +2 -0
- package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
- package/dist/functional/result/impl/result-to-optional.mjs +2 -0
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts +7 -4
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +3 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +3 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts +3 -2
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +3 -2
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +7 -4
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.d.mts +3 -2
- package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts +3 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +3 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-zip.d.mts +3 -1
- package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
- package/dist/functional/result/impl/result-zip.mjs +3 -1
- package/dist/functional/result/impl/result-zip.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +3 -2
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +3 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +3 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +3 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +3 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +7 -3
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +7 -3
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +3 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +3 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +6 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
- package/dist/globals.d.mts +12 -1
- package/dist/guard/has-key.d.mts +6 -3
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +2 -2
- package/dist/guard/index.mjs +1 -1
- package/dist/guard/is-record.d.mts +31 -0
- package/dist/guard/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +32 -1
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.d.mts +3 -0
- package/dist/guard/is-type.d.mts.map +1 -1
- package/dist/guard/is-type.mjs +3 -0
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts +3 -2
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +3 -2
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterator/range.d.mts +4 -0
- package/dist/iterator/range.d.mts.map +1 -1
- package/dist/iterator/range.mjs +1 -0
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.d.mts +42 -21
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +42 -21
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +33 -19
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +33 -19
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +2 -2
- package/dist/number/branded-types/positive-int.d.mts +34 -20
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +34 -20
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +47 -26
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +48 -27
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +48 -27
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +50 -29
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +1 -1
- package/dist/number/branded-types/uint.d.mts +31 -19
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +31 -19
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/num.d.mts +29 -20
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +24 -17
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +33 -11
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +33 -11
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts +12 -3
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +10 -3
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/tuple.d.mts +14 -3
- package/dist/others/tuple.d.mts.map +1 -1
- package/dist/others/tuple.mjs +14 -3
- package/dist/others/tuple.mjs.map +1 -1
- package/dist/others/unknown-to-string.d.mts.map +1 -1
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/promise.d.mts +8 -4
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +8 -4
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +26 -28
- package/src/array/impl/array-utils-creation.mts +20 -0
- package/src/array/impl/array-utils-creation.test.mts +72 -1
- package/src/array/impl/array-utils-element-access.mts +13 -0
- package/src/array/impl/array-utils-element-access.test.mts +36 -15
- package/src/array/impl/array-utils-iterators.test.mts +17 -0
- package/src/array/impl/array-utils-modification.mts +78 -19
- package/src/array/impl/array-utils-modification.test.mts +75 -0
- package/src/array/impl/array-utils-overload-type-error.test.mts +19 -0
- package/src/array/impl/array-utils-reducing-value.mts +61 -16
- package/src/array/impl/array-utils-reducing-value.test.mts +107 -25
- package/src/array/impl/array-utils-search.mts +57 -4
- package/src/array/impl/array-utils-search.test.mts +61 -10
- package/src/array/impl/array-utils-set-op.mts +26 -7
- package/src/array/impl/array-utils-set-op.test.mts +129 -13
- package/src/array/impl/array-utils-size.mts +5 -2
- package/src/array/impl/array-utils-size.test.mts +1 -0
- package/src/array/impl/array-utils-slice-clamped.mts +7 -0
- package/src/array/impl/array-utils-slice-clamped.test.mts +20 -0
- package/src/array/impl/array-utils-slicing.mts +29 -2
- package/src/array/impl/array-utils-slicing.test.mts +57 -0
- package/src/array/impl/array-utils-transformation.mts +58 -0
- package/src/array/impl/array-utils-transformation.test.mts +115 -3
- package/src/array/impl/array-utils-validation.mts +41 -18
- package/src/array/impl/array-utils-validation.test.mts +176 -78
- package/src/array/impl/array.test.mts +18 -6
- package/src/collections/imap-mapped.mts +11 -0
- package/src/collections/imap-mapped.test.mts +86 -18
- package/src/collections/imap.mts +47 -15
- package/src/collections/imap.test.mts +137 -31
- package/src/collections/iset-mapped.mts +54 -19
- package/src/collections/iset-mapped.test.mts +163 -52
- package/src/collections/iset.mts +53 -19
- package/src/collections/iset.test.mts +323 -130
- package/src/collections/queue.mts +78 -25
- package/src/collections/queue.test.mts +65 -35
- package/src/collections/stack.mts +67 -25
- package/src/collections/stack.test.mts +59 -15
- package/src/functional/match.mts +17 -1
- package/src/functional/match.test.mts +2 -0
- package/src/functional/optional/impl/optional-expect-to-be.mts +5 -2
- package/src/functional/optional/impl/optional-filter.mts +6 -0
- package/src/functional/optional/impl/optional-flat-map.mts +4 -0
- package/src/functional/optional/impl/optional-from-nullable.mts +2 -0
- package/src/functional/optional/impl/optional-is-none.mts +1 -1
- package/src/functional/optional/impl/optional-is-optional.mts +4 -2
- package/src/functional/optional/impl/optional-is-some.mts +2 -1
- package/src/functional/optional/impl/optional-map.mts +5 -0
- package/src/functional/optional/impl/optional-none.mts +4 -2
- package/src/functional/optional/impl/optional-or-else.mts +6 -0
- package/src/functional/optional/impl/optional-some.mts +5 -3
- package/src/functional/optional/impl/optional-to-nullable.mts +4 -2
- package/src/functional/optional/impl/optional-unwrap-or.mts +9 -4
- package/src/functional/optional/impl/optional-unwrap-throw.mts +2 -1
- package/src/functional/optional/impl/optional-unwrap.mts +4 -2
- package/src/functional/optional/impl/optional-zip.mts +3 -1
- package/src/functional/optional.test.mts +126 -54
- package/src/functional/pipe.mts +2 -2
- package/src/functional/pipe.test.mts +7 -4
- package/src/functional/result/impl/result-err.mts +4 -2
- package/src/functional/result/impl/result-expect-to-be.mts +5 -2
- package/src/functional/result/impl/result-flat-map.mts +7 -0
- package/src/functional/result/impl/result-fold.mts +6 -0
- package/src/functional/result/impl/result-from-promise.mts +4 -1
- package/src/functional/result/impl/result-from-throwable.mts +5 -1
- package/src/functional/result/impl/result-is-err.mts +4 -2
- package/src/functional/result/impl/result-is-ok.mts +4 -2
- package/src/functional/result/impl/result-is-result.mts +7 -3
- package/src/functional/result/impl/result-map-err.mts +5 -0
- package/src/functional/result/impl/result-map.mts +6 -0
- package/src/functional/result/impl/result-ok.mts +4 -2
- package/src/functional/result/impl/result-or-else.mts +6 -0
- package/src/functional/result/impl/result-swap.mts +2 -0
- package/src/functional/result/impl/result-to-optional.mts +2 -0
- package/src/functional/result/impl/result-unwrap-err-or.mts +9 -4
- package/src/functional/result/impl/result-unwrap-err-throw.mts +3 -1
- package/src/functional/result/impl/result-unwrap-err.mts +3 -2
- package/src/functional/result/impl/result-unwrap-ok-or.mts +9 -4
- package/src/functional/result/impl/result-unwrap-ok.mts +4 -2
- package/src/functional/result/impl/result-unwrap-throw.mts +3 -1
- package/src/functional/result/impl/result-zip.mts +3 -1
- package/src/functional/result.test.mts +182 -152
- package/src/functional/ternary-result/impl/ternary-result-err.mts +3 -2
- package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +4 -0
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +7 -0
- package/src/functional/ternary-result/impl/ternary-result-fold.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +3 -1
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +4 -1
- package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +7 -3
- package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-map-err.mts +6 -0
- package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +6 -0
- package/src/functional/ternary-result/impl/ternary-result-map.mts +9 -0
- package/src/functional/ternary-result/impl/ternary-result-ok.mts +1 -1
- package/src/functional/ternary-result/impl/ternary-result-or-else.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +3 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-warn.mts +4 -1
- package/src/functional/ternary-result/impl/ternary-result-zip.mts +4 -0
- package/src/functional/ternary-result.test.mts +99 -8
- package/src/globals.d.mts +12 -1
- package/src/guard/has-key.mts +8 -5
- package/src/guard/has-key.test.mts +9 -5
- package/src/guard/is-error.test.mts +143 -0
- package/src/guard/is-non-empty-string.test.mts +44 -24
- package/src/guard/is-non-null-object.test.mts +45 -26
- package/src/guard/is-primitive.test.mts +51 -28
- package/src/guard/is-record.mts +34 -0
- package/src/guard/is-record.test.mts +28 -7
- package/src/guard/is-type.mts +3 -0
- package/src/guard/is-type.test.mts +285 -155
- package/src/guard/key-is-in.mts +3 -2
- package/src/guard/key-is-in.test.mts +2 -2
- package/src/iterator/range.mts +9 -0
- package/src/json/json.mts +50 -21
- package/src/json/json.test.mts +224 -176
- package/src/number/branded-types/finite-number.test.mts +51 -11
- package/src/number/branded-types/int.mts +33 -19
- package/src/number/branded-types/int.test.mts +56 -14
- package/src/number/branded-types/int16.test.mts +63 -16
- package/src/number/branded-types/int32.test.mts +63 -16
- package/src/number/branded-types/non-negative-finite-number.test.mts +52 -12
- package/src/number/branded-types/non-negative-int16.test.mts +59 -16
- package/src/number/branded-types/non-negative-int32.test.mts +59 -16
- package/src/number/branded-types/non-zero-finite-number.test.mts +65 -14
- package/src/number/branded-types/non-zero-int.test.mts +72 -19
- package/src/number/branded-types/non-zero-int16.test.mts +60 -16
- package/src/number/branded-types/non-zero-int32.test.mts +60 -16
- package/src/number/branded-types/non-zero-safe-int.mts +2 -2
- package/src/number/branded-types/non-zero-safe-int.test.mts +85 -23
- package/src/number/branded-types/non-zero-uint16.test.mts +53 -16
- package/src/number/branded-types/non-zero-uint32.test.mts +53 -16
- package/src/number/branded-types/positive-finite-number.test.mts +59 -14
- package/src/number/branded-types/positive-int.mts +34 -20
- package/src/number/branded-types/positive-int.test.mts +64 -17
- package/src/number/branded-types/positive-int16.test.mts +50 -15
- package/src/number/branded-types/positive-int32.test.mts +50 -15
- package/src/number/branded-types/positive-safe-int.mts +48 -27
- package/src/number/branded-types/positive-safe-int.test.mts +68 -19
- package/src/number/branded-types/positive-uint16.test.mts +53 -16
- package/src/number/branded-types/positive-uint32.test.mts +53 -16
- package/src/number/branded-types/safe-int.mts +50 -29
- package/src/number/branded-types/safe-int.test.mts +70 -18
- package/src/number/branded-types/safe-uint.mts +1 -1
- package/src/number/branded-types/safe-uint.test.mts +65 -17
- package/src/number/branded-types/uint.mts +31 -19
- package/src/number/branded-types/uint.test.mts +58 -15
- package/src/number/branded-types/uint16.test.mts +56 -15
- package/src/number/branded-types/uint32.test.mts +56 -15
- package/src/number/enum/int8.test.mts +7 -1
- package/src/number/enum/uint8.test.mts +7 -1
- package/src/number/num.mts +32 -21
- package/src/number/num.test.mts +88 -26
- package/src/number/refined-number-utils.mts +38 -13
- package/src/object/object.mts +19 -3
- package/src/object/object.test.mts +16 -6
- package/src/others/cast-mutable.test.mts +8 -1
- package/src/others/cast-readonly.test.mts +21 -4
- package/src/others/if-then.test.mts +40 -24
- package/src/others/map-nullable.mts +3 -0
- package/src/others/map-nullable.test.mts +27 -0
- package/src/others/memoize-function.test.mts +41 -0
- package/src/others/tuple.mts +14 -3
- package/src/others/unknown-to-string.mts +2 -0
- package/src/others/unknown-to-string.test.mts +10 -0
- package/src/promise/promise.mts +8 -4
- package/src/promise/promise.test.mts +8 -13
|
@@ -15,33 +15,41 @@ describe('Arr search operations', () => {
|
|
|
15
15
|
describe(find, () => {
|
|
16
16
|
test('should find first element matching predicate', () => {
|
|
17
17
|
const numbers = [1, 2, 3, 4, 5];
|
|
18
|
+
|
|
18
19
|
const firstEven = find(numbers, (n) => n % 2 === 0);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
assert.isTrue(Optional.isSome(firstEven));
|
|
22
|
+
|
|
21
23
|
expect(Optional.unwrap(firstEven)).toBe(2);
|
|
22
24
|
});
|
|
23
25
|
|
|
24
26
|
test('should return None when no element matches', () => {
|
|
25
27
|
const odds = [1, 3, 5];
|
|
28
|
+
|
|
26
29
|
const firstEven = find(odds, (n) => n % 2 === 0);
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
assert.isTrue(Optional.isNone(firstEven));
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
test('should work with curried version', () => {
|
|
32
35
|
const isEven = (n: number): boolean => n % 2 === 0;
|
|
36
|
+
|
|
33
37
|
const findEven = find<number>(isEven);
|
|
34
38
|
|
|
35
39
|
const result1 = findEven([1, 2, 3]);
|
|
40
|
+
|
|
36
41
|
const result2 = findEven([1, 3, 5]);
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
assert.isTrue(Optional.isSome(result1));
|
|
44
|
+
|
|
39
45
|
expect(Optional.unwrap(result1)).toBe(2);
|
|
40
|
-
|
|
46
|
+
|
|
47
|
+
assert.isTrue(Optional.isNone(result2));
|
|
41
48
|
});
|
|
42
49
|
|
|
43
50
|
test('should work with type guard predicate', () => {
|
|
44
51
|
const values: readonly (string | number)[] = [1, 'a', 2, 'b'];
|
|
52
|
+
|
|
45
53
|
const firstString = find(
|
|
46
54
|
values,
|
|
47
55
|
(x): x is string => typeof x === 'string',
|
|
@@ -49,12 +57,14 @@ describe('Arr search operations', () => {
|
|
|
49
57
|
|
|
50
58
|
expectType<typeof firstString, Optional<string>>('=');
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
assert.isTrue(Optional.isSome(firstString));
|
|
61
|
+
|
|
53
62
|
expect(Optional.unwrap(firstString)).toBe('a');
|
|
54
63
|
});
|
|
55
64
|
|
|
56
65
|
test('should provide index and array to predicate', () => {
|
|
57
66
|
const numbers = [10, 20, 30];
|
|
67
|
+
|
|
58
68
|
const foundWithIndex = find(numbers, (value, index, arr) => {
|
|
59
69
|
expect(arr).toBe(numbers);
|
|
60
70
|
|
|
@@ -66,6 +76,7 @@ describe('Arr search operations', () => {
|
|
|
66
76
|
|
|
67
77
|
test('should return first match when multiple elements match', () => {
|
|
68
78
|
const numbers = [2, 4, 6, 8];
|
|
79
|
+
|
|
69
80
|
const firstEven = find(numbers, (n) => n % 2 === 0);
|
|
70
81
|
|
|
71
82
|
expect(Optional.unwrap(firstEven)).toBe(2);
|
|
@@ -73,46 +84,55 @@ describe('Arr search operations', () => {
|
|
|
73
84
|
|
|
74
85
|
test('should work with empty array', () => {
|
|
75
86
|
const empty: readonly number[] = [];
|
|
87
|
+
|
|
76
88
|
const result = find(empty, () => true);
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
assert.isTrue(Optional.isNone(result));
|
|
79
91
|
});
|
|
80
92
|
});
|
|
81
93
|
|
|
82
94
|
describe(findLast, () => {
|
|
83
95
|
test('should find last element matching predicate', () => {
|
|
84
96
|
const numbers = [1, 2, 3, 4, 5];
|
|
97
|
+
|
|
85
98
|
const lastEven = findLast(numbers, (n) => n % 2 === 0);
|
|
86
99
|
|
|
87
|
-
|
|
100
|
+
assert.isTrue(Optional.isSome(lastEven));
|
|
101
|
+
|
|
88
102
|
expect(Optional.unwrap(lastEven)).toBe(4);
|
|
89
103
|
});
|
|
90
104
|
|
|
91
105
|
test('should return None when no element matches', () => {
|
|
92
106
|
const odds = [1, 3, 5];
|
|
107
|
+
|
|
93
108
|
const lastEven = findLast(odds, (n) => n % 2 === 0);
|
|
94
109
|
|
|
95
|
-
|
|
110
|
+
assert.isTrue(Optional.isNone(lastEven));
|
|
96
111
|
});
|
|
97
112
|
|
|
98
113
|
test('should work with curried version', () => {
|
|
99
114
|
const isPositive = (n: number): boolean => n > 0;
|
|
115
|
+
|
|
100
116
|
const findLastPositive = findLast(isPositive);
|
|
117
|
+
|
|
101
118
|
const result = findLastPositive([-1, 2, -3, 4]);
|
|
102
119
|
|
|
103
|
-
|
|
120
|
+
assert.isTrue(Optional.isSome(result));
|
|
121
|
+
|
|
104
122
|
expect(Optional.unwrap(result)).toBe(4);
|
|
105
123
|
});
|
|
106
124
|
|
|
107
125
|
test('should work with empty array', () => {
|
|
108
126
|
const empty: number[] = [];
|
|
127
|
+
|
|
109
128
|
const result = findLast(empty, (n) => n > 0);
|
|
110
129
|
|
|
111
|
-
|
|
130
|
+
assert.isTrue(Optional.isNone(result));
|
|
112
131
|
});
|
|
113
132
|
|
|
114
133
|
test('should pass index and array to predicate', () => {
|
|
115
134
|
const numbers = [10, 20, 30, 40];
|
|
135
|
+
|
|
116
136
|
const lastWithIndex2 = findLast(numbers, (_, idx, arr) => {
|
|
117
137
|
expect(arr).toBe(numbers);
|
|
118
138
|
|
|
@@ -124,6 +144,7 @@ describe('Arr search operations', () => {
|
|
|
124
144
|
|
|
125
145
|
test('should find last occurrence', () => {
|
|
126
146
|
const numbers = [1, 2, 2, 3, 2, 4];
|
|
147
|
+
|
|
127
148
|
const lastTwo = findLast(numbers, (n) => n === 2);
|
|
128
149
|
|
|
129
150
|
expect(Optional.unwrap(lastTwo)).toBe(2);
|
|
@@ -138,6 +159,7 @@ describe('Arr search operations', () => {
|
|
|
138
159
|
describe(findIndex, () => {
|
|
139
160
|
test('should find index of matching element', () => {
|
|
140
161
|
const arr = ['a', 'b', 'c'];
|
|
162
|
+
|
|
141
163
|
const result = findIndex(arr, (x) => x === 'b');
|
|
142
164
|
|
|
143
165
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
@@ -149,6 +171,7 @@ describe('Arr search operations', () => {
|
|
|
149
171
|
|
|
150
172
|
test('should return None for no match', () => {
|
|
151
173
|
const arr = ['a', 'b', 'c'];
|
|
174
|
+
|
|
152
175
|
const result = findIndex(arr, (x) => x === 'd');
|
|
153
176
|
|
|
154
177
|
expect(result).toBe(-1);
|
|
@@ -158,6 +181,7 @@ describe('Arr search operations', () => {
|
|
|
158
181
|
describe(findLastIndex, () => {
|
|
159
182
|
test('should find last index matching predicate', () => {
|
|
160
183
|
const numbers = [1, 2, 3, 4, 2, 5];
|
|
184
|
+
|
|
161
185
|
const lastTwoIndex = findLastIndex(numbers, (n) => n === 2);
|
|
162
186
|
|
|
163
187
|
expect(lastTwoIndex).toBe(4);
|
|
@@ -165,6 +189,7 @@ describe('Arr search operations', () => {
|
|
|
165
189
|
|
|
166
190
|
test('should return -1 when no element matches', () => {
|
|
167
191
|
const odds = [1, 3, 5];
|
|
192
|
+
|
|
168
193
|
const lastEvenIndex = findLastIndex(odds, (n) => n % 2 === 0);
|
|
169
194
|
|
|
170
195
|
expect(lastEvenIndex).toBe(-1);
|
|
@@ -172,7 +197,9 @@ describe('Arr search operations', () => {
|
|
|
172
197
|
|
|
173
198
|
test('should work with curried version', () => {
|
|
174
199
|
const isPositive = (n: number): boolean => n > 0;
|
|
200
|
+
|
|
175
201
|
const findLastPositiveIndex = findLastIndex(isPositive);
|
|
202
|
+
|
|
176
203
|
const result = findLastPositiveIndex([-1, 2, -3, 4, -5]);
|
|
177
204
|
|
|
178
205
|
expect(result).toBe(3); // index of last positive number (4)
|
|
@@ -180,6 +207,7 @@ describe('Arr search operations', () => {
|
|
|
180
207
|
|
|
181
208
|
test('should work with empty array', () => {
|
|
182
209
|
const empty: number[] = [];
|
|
210
|
+
|
|
183
211
|
const result = findLastIndex(empty, (n) => n > 0);
|
|
184
212
|
|
|
185
213
|
expect(result).toBe(-1);
|
|
@@ -187,6 +215,7 @@ describe('Arr search operations', () => {
|
|
|
187
215
|
|
|
188
216
|
test('should pass index and array to predicate', () => {
|
|
189
217
|
const numbers = [10, 20, 30, 40];
|
|
218
|
+
|
|
190
219
|
const lastWithIndex2OrHigher = findLastIndex(numbers, (_, idx, arr) => {
|
|
191
220
|
expect(arr).toBe(numbers);
|
|
192
221
|
|
|
@@ -204,6 +233,7 @@ describe('Arr search operations', () => {
|
|
|
204
233
|
{ id: 4, active: false },
|
|
205
234
|
{ id: 5, active: true },
|
|
206
235
|
];
|
|
236
|
+
|
|
207
237
|
const lastActiveIndex = findLastIndex(data, (item) => item.active);
|
|
208
238
|
|
|
209
239
|
expect(lastActiveIndex).toBe(4); // last active item
|
|
@@ -211,6 +241,7 @@ describe('Arr search operations', () => {
|
|
|
211
241
|
|
|
212
242
|
test('should work with tuples', () => {
|
|
213
243
|
const tuple = [10, 20, 30, 20, 40] as const;
|
|
244
|
+
|
|
214
245
|
const lastTwentyIndex = findLastIndex(tuple, (x) => x === 20);
|
|
215
246
|
|
|
216
247
|
expect(lastTwentyIndex).toBe(3); // last occurrence of 20
|
|
@@ -219,10 +250,12 @@ describe('Arr search operations', () => {
|
|
|
219
250
|
test('should search from end to beginning', () => {
|
|
220
251
|
// Verify search order by using side effects
|
|
221
252
|
const numbers = [1, 2, 3, 4, 5];
|
|
253
|
+
|
|
222
254
|
const mut_searchOrder: number[] = [];
|
|
223
255
|
|
|
224
256
|
findLastIndex(numbers, (val, idx) => {
|
|
225
257
|
mut_searchOrder.push(idx);
|
|
258
|
+
|
|
226
259
|
return val === 3;
|
|
227
260
|
});
|
|
228
261
|
|
|
@@ -232,15 +265,19 @@ describe('Arr search operations', () => {
|
|
|
232
265
|
|
|
233
266
|
test('should handle single element array', () => {
|
|
234
267
|
const single = [42];
|
|
268
|
+
|
|
235
269
|
const foundIndex = findLastIndex(single, (n) => n === 42);
|
|
270
|
+
|
|
236
271
|
const notFoundIndex = findLastIndex(single, (n) => n === 0);
|
|
237
272
|
|
|
238
273
|
expect(foundIndex).toBe(0);
|
|
274
|
+
|
|
239
275
|
expect(notFoundIndex).toBe(-1);
|
|
240
276
|
});
|
|
241
277
|
|
|
242
278
|
test('should work with string arrays', () => {
|
|
243
279
|
const words = ['hello', 'world', 'test', 'hello', 'end'];
|
|
280
|
+
|
|
244
281
|
const lastHelloIndex = findLastIndex(words, (word) => word === 'hello');
|
|
245
282
|
|
|
246
283
|
expect(lastHelloIndex).toBe(3);
|
|
@@ -250,6 +287,7 @@ describe('Arr search operations', () => {
|
|
|
250
287
|
describe(indexOf, () => {
|
|
251
288
|
test('should find index of element', () => {
|
|
252
289
|
const arr = ['a', 'b', 'c', 'b'];
|
|
290
|
+
|
|
253
291
|
const result = indexOf(arr, 'b');
|
|
254
292
|
|
|
255
293
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
@@ -263,6 +301,7 @@ describe('Arr search operations', () => {
|
|
|
263
301
|
|
|
264
302
|
test('should return -1 for non-existent element', () => {
|
|
265
303
|
const arr = ['a', 'b', 'c'];
|
|
304
|
+
|
|
266
305
|
const result = indexOf(arr, 'd');
|
|
267
306
|
|
|
268
307
|
expect(result).toBe(-1);
|
|
@@ -272,6 +311,7 @@ describe('Arr search operations', () => {
|
|
|
272
311
|
describe(indexOfFrom, () => {
|
|
273
312
|
test('should find index of element from specified index', () => {
|
|
274
313
|
const arr = ['a', 'b', 'c', 'b'];
|
|
314
|
+
|
|
275
315
|
const result = indexOfFrom(arr, 'b', 2);
|
|
276
316
|
|
|
277
317
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
@@ -285,6 +325,7 @@ describe('Arr search operations', () => {
|
|
|
285
325
|
|
|
286
326
|
test('should return -1 when element not found from index', () => {
|
|
287
327
|
const arr = ['a', 'b', 'c', 'b'];
|
|
328
|
+
|
|
288
329
|
const result = indexOfFrom(arr, 'a', 1);
|
|
289
330
|
|
|
290
331
|
expect(result).toBe(-1);
|
|
@@ -292,6 +333,7 @@ describe('Arr search operations', () => {
|
|
|
292
333
|
|
|
293
334
|
test('should find first occurrence when fromIndex is 0', () => {
|
|
294
335
|
const arr = ['a', 'b', 'c', 'b'];
|
|
336
|
+
|
|
295
337
|
const result = indexOfFrom(arr, 'b', 0);
|
|
296
338
|
|
|
297
339
|
expect(result).toBe(1);
|
|
@@ -299,6 +341,7 @@ describe('Arr search operations', () => {
|
|
|
299
341
|
|
|
300
342
|
test('should handle negative fromIndex', () => {
|
|
301
343
|
const arr = ['a', 'b', 'c', 'b'];
|
|
344
|
+
|
|
302
345
|
const result = indexOfFrom(arr, 'b', -2);
|
|
303
346
|
|
|
304
347
|
expect(result).toBe(3);
|
|
@@ -306,6 +349,7 @@ describe('Arr search operations', () => {
|
|
|
306
349
|
|
|
307
350
|
test('should handle fromIndex beyond array length', () => {
|
|
308
351
|
const arr = ['a', 'b', 'c'];
|
|
352
|
+
|
|
309
353
|
const result = indexOfFrom(arr, 'a', 10);
|
|
310
354
|
|
|
311
355
|
expect(result).toBe(-1);
|
|
@@ -315,6 +359,7 @@ describe('Arr search operations', () => {
|
|
|
315
359
|
describe(lastIndexOf, () => {
|
|
316
360
|
test('should find last index of element', () => {
|
|
317
361
|
const arr = ['a', 'b', 'c', 'b'];
|
|
362
|
+
|
|
318
363
|
const result = lastIndexOf(arr, 'b');
|
|
319
364
|
|
|
320
365
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
@@ -328,6 +373,7 @@ describe('Arr search operations', () => {
|
|
|
328
373
|
|
|
329
374
|
test('should return -1 for non-existent element', () => {
|
|
330
375
|
const arr = ['a', 'b', 'c'];
|
|
376
|
+
|
|
331
377
|
const result = lastIndexOf(arr, 'd');
|
|
332
378
|
|
|
333
379
|
expect(result).toBe(-1);
|
|
@@ -337,6 +383,7 @@ describe('Arr search operations', () => {
|
|
|
337
383
|
describe(lastIndexOfFrom, () => {
|
|
338
384
|
test('should find last index of element from specified index', () => {
|
|
339
385
|
const arr = ['a', 'b', 'c', 'b', 'e'];
|
|
386
|
+
|
|
340
387
|
const result = lastIndexOfFrom(arr, 'b', 2);
|
|
341
388
|
|
|
342
389
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
@@ -350,6 +397,7 @@ describe('Arr search operations', () => {
|
|
|
350
397
|
|
|
351
398
|
test('should return -1 when element not found before index', () => {
|
|
352
399
|
const arr = ['a', 'b', 'c', 'b'];
|
|
400
|
+
|
|
353
401
|
const result = lastIndexOfFrom(arr, 'b', 0);
|
|
354
402
|
|
|
355
403
|
expect(result).toBe(-1);
|
|
@@ -357,6 +405,7 @@ describe('Arr search operations', () => {
|
|
|
357
405
|
|
|
358
406
|
test('should find last occurrence when fromIndex covers all elements', () => {
|
|
359
407
|
const arr = ['a', 'b', 'c', 'b'];
|
|
408
|
+
|
|
360
409
|
const result = lastIndexOfFrom(arr, 'b', 10);
|
|
361
410
|
|
|
362
411
|
expect(result).toBe(3);
|
|
@@ -364,6 +413,7 @@ describe('Arr search operations', () => {
|
|
|
364
413
|
|
|
365
414
|
test('should handle negative fromIndex', () => {
|
|
366
415
|
const arr = ['a', 'b', 'c', 'b'];
|
|
416
|
+
|
|
367
417
|
const result = lastIndexOfFrom(arr, 'b', -1);
|
|
368
418
|
|
|
369
419
|
expect(result).toBe(3);
|
|
@@ -371,6 +421,7 @@ describe('Arr search operations', () => {
|
|
|
371
421
|
|
|
372
422
|
test('should handle fromIndex of 0', () => {
|
|
373
423
|
const arr = ['a', 'b', 'c', 'b'];
|
|
424
|
+
|
|
374
425
|
const result = lastIndexOfFrom(arr, 'a', 0);
|
|
375
426
|
|
|
376
427
|
expect(result).toBe(0);
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
7
|
* const numbers = [1, 2, 3] as const;
|
|
8
|
+
*
|
|
8
9
|
* const sameNumbers = [1, 2, 3] as const;
|
|
10
|
+
*
|
|
9
11
|
* const differentNumbers = [1, 2, 4] as const;
|
|
10
12
|
*
|
|
11
|
-
* assert.
|
|
12
|
-
*
|
|
13
|
+
* assert.isTrue(Arr.eq(numbers, sameNumbers));
|
|
14
|
+
*
|
|
15
|
+
* assert.isFalse(Arr.eq(numbers, differentNumbers));
|
|
13
16
|
* ```
|
|
14
17
|
*/
|
|
15
18
|
export const eq = <E,>(
|
|
@@ -35,11 +38,14 @@ export const equal = eq;
|
|
|
35
38
|
*
|
|
36
39
|
* ```ts
|
|
37
40
|
* const subset = [1, 2] as const;
|
|
41
|
+
*
|
|
38
42
|
* const superset = [1, 2, 3] as const;
|
|
43
|
+
*
|
|
39
44
|
* const notSubset = [2, 4] as const;
|
|
40
45
|
*
|
|
41
|
-
* assert.
|
|
42
|
-
*
|
|
46
|
+
* assert.isTrue(Arr.isSubset(subset, superset));
|
|
47
|
+
*
|
|
48
|
+
* assert.isFalse(Arr.isSubset(notSubset, superset));
|
|
43
49
|
* ```
|
|
44
50
|
*/
|
|
45
51
|
export const isSubset = <E1 extends Primitive, E2 extends Primitive = E1>(
|
|
@@ -58,12 +64,16 @@ export const isSubset = <E1 extends Primitive, E2 extends Primitive = E1>(
|
|
|
58
64
|
*
|
|
59
65
|
* ```ts
|
|
60
66
|
* const potentialSuperset = ['a', 'b', 'c'] as const;
|
|
67
|
+
*
|
|
61
68
|
* const subset = ['a', 'c'] as const;
|
|
69
|
+
*
|
|
62
70
|
* const notSuperset = ['a', 'd'] as const;
|
|
63
71
|
*
|
|
64
|
-
* assert.
|
|
65
|
-
*
|
|
66
|
-
* assert.
|
|
72
|
+
* assert.isTrue(Arr.isSuperset(potentialSuperset, subset));
|
|
73
|
+
*
|
|
74
|
+
* assert.isFalse(Arr.isSuperset(subset, potentialSuperset));
|
|
75
|
+
*
|
|
76
|
+
* assert.isFalse(Arr.isSuperset(potentialSuperset, notSuperset));
|
|
67
77
|
* ```
|
|
68
78
|
*/
|
|
69
79
|
export const isSuperset = <E1 extends Primitive, E2 extends Primitive = E1>(
|
|
@@ -78,6 +88,7 @@ export const isSuperset = <E1 extends Primitive, E2 extends Primitive = E1>(
|
|
|
78
88
|
*
|
|
79
89
|
* ```ts
|
|
80
90
|
* const refs = ['Ada', 'Alan', 'Grace'] as const;
|
|
91
|
+
*
|
|
81
92
|
* const attendees = ['Grace', 'Alan', 'Barbara'] as const;
|
|
82
93
|
*
|
|
83
94
|
* const both = Arr.setIntersection(refs, attendees);
|
|
@@ -102,6 +113,7 @@ export const setIntersection = <
|
|
|
102
113
|
*
|
|
103
114
|
* ```ts
|
|
104
115
|
* const baseline = [1, 2, 3, 4] as const;
|
|
116
|
+
*
|
|
105
117
|
* const removed = [2, 4] as const;
|
|
106
118
|
*
|
|
107
119
|
* const remaining = Arr.setDifference(baseline, removed);
|
|
@@ -121,6 +133,7 @@ export const setDifference = <E extends Primitive>(
|
|
|
121
133
|
*
|
|
122
134
|
* ```ts
|
|
123
135
|
* const upcoming = [1, 3, 5, 7, 9] as const;
|
|
136
|
+
*
|
|
124
137
|
* const completed = [3, 4, 7] as const;
|
|
125
138
|
*
|
|
126
139
|
* const remaining = Arr.sortedNumSetDifference(upcoming, completed);
|
|
@@ -135,27 +148,33 @@ export const sortedNumSetDifference = <E extends number>(
|
|
|
135
148
|
sortedList2: readonly E[],
|
|
136
149
|
): readonly E[] => {
|
|
137
150
|
const mut_result: E[] = [];
|
|
151
|
+
|
|
138
152
|
let mut_it1 = 0; // iterator for sortedList1
|
|
153
|
+
|
|
139
154
|
let mut_it2 = 0; // iterator for sortedList2
|
|
140
155
|
|
|
141
156
|
while (mut_it1 < sortedList1.length && mut_it2 < sortedList2.length) {
|
|
142
157
|
// Non-null assertions are safe due to loop condition
|
|
143
158
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
144
159
|
const val1 = sortedList1[mut_it1]!;
|
|
160
|
+
|
|
145
161
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
146
162
|
const val2 = sortedList2[mut_it2]!;
|
|
147
163
|
|
|
148
164
|
if (val1 === val2) {
|
|
149
165
|
mut_it1 += 1;
|
|
166
|
+
|
|
150
167
|
mut_it2 += 1;
|
|
151
168
|
} else if (val1 < val2) {
|
|
152
169
|
mut_result.push(val1);
|
|
170
|
+
|
|
153
171
|
mut_it1 += 1;
|
|
154
172
|
} else {
|
|
155
173
|
// val1 > val2
|
|
156
174
|
mut_it2 += 1;
|
|
157
175
|
}
|
|
158
176
|
}
|
|
177
|
+
|
|
159
178
|
// Add remaining elements from sortedList1
|
|
160
179
|
for (; mut_it1 < sortedList1.length; mut_it1 += 1) {
|
|
161
180
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|