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
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
|
|
23
23
|
describe('Arr transformations', () => {
|
|
24
24
|
describe(map, () => {
|
|
25
|
-
const mapped = map([1, 2, 3], (x, i): number => x
|
|
25
|
+
const mapped = map([1, 2, 3], (x, i): number => x ** 2 * i);
|
|
26
26
|
|
|
27
27
|
expectType<typeof mapped, ArrayOfLength<3, number>>('=');
|
|
28
28
|
|
|
@@ -32,7 +32,9 @@ describe('Arr transformations', () => {
|
|
|
32
32
|
|
|
33
33
|
test('should work with empty tuple', () => {
|
|
34
34
|
const empty = [] as const;
|
|
35
|
+
|
|
35
36
|
const mappedEmpty = map(empty, (x) => String(x));
|
|
37
|
+
|
|
36
38
|
expectType<typeof mappedEmpty, readonly []>('=');
|
|
37
39
|
|
|
38
40
|
assert.deepStrictEqual(mappedEmpty, []);
|
|
@@ -40,7 +42,9 @@ describe('Arr transformations', () => {
|
|
|
40
42
|
|
|
41
43
|
test('should preserve tuple length with different types', () => {
|
|
42
44
|
const mixed = [1, 'hello', true] as const;
|
|
45
|
+
|
|
43
46
|
const mappedMixed = map(mixed, (x) => typeof x);
|
|
47
|
+
|
|
44
48
|
expectType<typeof mappedMixed, readonly [string, string, string]>('<=');
|
|
45
49
|
|
|
46
50
|
assert.deepStrictEqual(mappedMixed, ['number', 'string', 'boolean']);
|
|
@@ -48,7 +52,9 @@ describe('Arr transformations', () => {
|
|
|
48
52
|
|
|
49
53
|
test('should work with index parameter', () => {
|
|
50
54
|
const tuple = ['a', 'b', 'c'] as const;
|
|
55
|
+
|
|
51
56
|
const mappedWithIndex = map(tuple, (x, i) => `${i}:${x}`);
|
|
57
|
+
|
|
52
58
|
expectType<typeof mappedWithIndex, readonly [string, string, string]>(
|
|
53
59
|
'<=',
|
|
54
60
|
);
|
|
@@ -60,6 +66,7 @@ describe('Arr transformations', () => {
|
|
|
60
66
|
describe(scan, () => {
|
|
61
67
|
test('should compute running sum', () => {
|
|
62
68
|
const numbers = [1, 2, 3, 4];
|
|
69
|
+
|
|
63
70
|
const runningSum = scan(numbers, (acc, curr) => acc + curr, 0);
|
|
64
71
|
|
|
65
72
|
expectType<typeof runningSum, readonly [number, ...number[]]>('<=');
|
|
@@ -69,6 +76,7 @@ describe('Arr transformations', () => {
|
|
|
69
76
|
|
|
70
77
|
test('should include initial value as first element', () => {
|
|
71
78
|
const numbers = [10, 20, 30];
|
|
79
|
+
|
|
72
80
|
const result = scan(numbers, (acc, curr) => acc + curr, 100);
|
|
73
81
|
|
|
74
82
|
assert.deepStrictEqual(result, [100, 110, 130, 160]);
|
|
@@ -80,20 +88,24 @@ describe('Arr transformations', () => {
|
|
|
80
88
|
const scanSum = scan<number, number>((acc, curr) => acc + curr, 0);
|
|
81
89
|
|
|
82
90
|
const result1 = scanSum([1, 2, 3]);
|
|
91
|
+
|
|
83
92
|
const result2 = scanSum([5, 10]);
|
|
84
93
|
|
|
85
94
|
assert.deepStrictEqual(result1, [0, 1, 3, 6]);
|
|
95
|
+
|
|
86
96
|
assert.deepStrictEqual(result2, [0, 5, 15]);
|
|
87
97
|
});
|
|
88
98
|
|
|
89
99
|
test('should provide index to reducer', () => {
|
|
90
100
|
const numbers = [10, 20, 30];
|
|
101
|
+
|
|
91
102
|
const mut_indices: number[] = [];
|
|
92
103
|
|
|
93
104
|
scan(
|
|
94
105
|
numbers,
|
|
95
106
|
(acc, curr, index) => {
|
|
96
107
|
mut_indices.push(index);
|
|
108
|
+
|
|
97
109
|
return acc + curr;
|
|
98
110
|
},
|
|
99
111
|
0,
|
|
@@ -104,6 +116,7 @@ describe('Arr transformations', () => {
|
|
|
104
116
|
|
|
105
117
|
test('should work with empty array', () => {
|
|
106
118
|
const empty: readonly number[] = [];
|
|
119
|
+
|
|
107
120
|
const result = scan(empty, (acc, curr) => acc + curr, 42);
|
|
108
121
|
|
|
109
122
|
assert.deepStrictEqual(result, [42]);
|
|
@@ -111,6 +124,7 @@ describe('Arr transformations', () => {
|
|
|
111
124
|
|
|
112
125
|
test('should work with different accumulator and element types', () => {
|
|
113
126
|
const strings = ['a', 'b', 'c'];
|
|
127
|
+
|
|
114
128
|
const result = scan(strings, (acc, curr) => acc + curr.length, 0);
|
|
115
129
|
|
|
116
130
|
expectType<typeof result, readonly [number, ...number[]]>('<=');
|
|
@@ -120,6 +134,7 @@ describe('Arr transformations', () => {
|
|
|
120
134
|
|
|
121
135
|
test('should compute running product', () => {
|
|
122
136
|
const numbers = [2, 3, 4];
|
|
137
|
+
|
|
123
138
|
const runningProduct = scan(numbers, (acc, curr) => acc * curr, 1);
|
|
124
139
|
|
|
125
140
|
assert.deepStrictEqual(runningProduct, [1, 2, 6, 24]);
|
|
@@ -135,6 +150,7 @@ describe('Arr transformations', () => {
|
|
|
135
150
|
|
|
136
151
|
test('should preserve all intermediate values', () => {
|
|
137
152
|
const numbers = [1, 2, 3];
|
|
153
|
+
|
|
138
154
|
const result = scan(numbers, (acc, curr) => acc - curr, 10);
|
|
139
155
|
|
|
140
156
|
// 10 -> 10-1=9 -> 9-2=7 -> 7-3=4
|
|
@@ -145,6 +161,7 @@ describe('Arr transformations', () => {
|
|
|
145
161
|
describe(toReversed, () => {
|
|
146
162
|
{
|
|
147
163
|
const xs = [1, 2, 3] as const;
|
|
164
|
+
|
|
148
165
|
const _nativeResult = xs.toReversed();
|
|
149
166
|
|
|
150
167
|
expectType<typeof _nativeResult, (1 | 2 | 3)[]>('=');
|
|
@@ -160,7 +177,9 @@ describe('Arr transformations', () => {
|
|
|
160
177
|
|
|
161
178
|
test('should work with empty tuple', () => {
|
|
162
179
|
const empty = [] as const;
|
|
180
|
+
|
|
163
181
|
const reversed = toReversed(empty);
|
|
182
|
+
|
|
164
183
|
expectType<typeof reversed, readonly []>('=');
|
|
165
184
|
|
|
166
185
|
assert.deepStrictEqual(reversed, []);
|
|
@@ -168,7 +187,9 @@ describe('Arr transformations', () => {
|
|
|
168
187
|
|
|
169
188
|
test('should work with single element', () => {
|
|
170
189
|
const single = [42] as const;
|
|
190
|
+
|
|
171
191
|
const reversed = toReversed(single);
|
|
192
|
+
|
|
172
193
|
expectType<typeof reversed, readonly [42]>('=');
|
|
173
194
|
|
|
174
195
|
assert.deepStrictEqual(reversed, [42]);
|
|
@@ -176,7 +197,9 @@ describe('Arr transformations', () => {
|
|
|
176
197
|
|
|
177
198
|
test('should preserve mixed types in reverse order', () => {
|
|
178
199
|
const mixed = [1, 'hello', true, null] as const;
|
|
200
|
+
|
|
179
201
|
const reversed = toReversed(mixed);
|
|
202
|
+
|
|
180
203
|
expectType<typeof reversed, readonly [null, true, 'hello', 1]>('=');
|
|
181
204
|
|
|
182
205
|
assert.deepStrictEqual(reversed, [null, true, 'hello', 1]);
|
|
@@ -186,6 +209,7 @@ describe('Arr transformations', () => {
|
|
|
186
209
|
describe(toSorted, () => {
|
|
187
210
|
{
|
|
188
211
|
const xs = [2, 1, 3] as const;
|
|
212
|
+
|
|
189
213
|
const result = toSorted(xs);
|
|
190
214
|
|
|
191
215
|
expectType<typeof result, ArrayOfLength<3, 1 | 2 | 3>>('=');
|
|
@@ -194,8 +218,10 @@ describe('Arr transformations', () => {
|
|
|
194
218
|
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
195
219
|
});
|
|
196
220
|
}
|
|
221
|
+
|
|
197
222
|
{
|
|
198
223
|
const xs = [2, 1, 3] as const;
|
|
224
|
+
|
|
199
225
|
const result = toSorted(xs, (a, b) => a - b);
|
|
200
226
|
|
|
201
227
|
expectType<typeof result, ArrayOfLength<3, 1 | 2 | 3>>('=');
|
|
@@ -204,8 +230,10 @@ describe('Arr transformations', () => {
|
|
|
204
230
|
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
205
231
|
});
|
|
206
232
|
}
|
|
233
|
+
|
|
207
234
|
{
|
|
208
235
|
const xs = [2, 1, 3] as const;
|
|
236
|
+
|
|
209
237
|
const result = toSorted(xs, (a, b) => b - a);
|
|
210
238
|
|
|
211
239
|
expectType<typeof result, ArrayOfLength<3, 1 | 2 | 3>>('=');
|
|
@@ -219,6 +247,7 @@ describe('Arr transformations', () => {
|
|
|
219
247
|
describe(toSortedBy, () => {
|
|
220
248
|
{
|
|
221
249
|
const xs = [{ v: 2 }, { v: 1 }, { v: 3 }] as const;
|
|
250
|
+
|
|
222
251
|
const sorted = toSortedBy(xs, (x) => x.v);
|
|
223
252
|
|
|
224
253
|
expectType<
|
|
@@ -230,8 +259,10 @@ describe('Arr transformations', () => {
|
|
|
230
259
|
assert.deepStrictEqual(sorted, [{ v: 1 }, { v: 2 }, { v: 3 }]);
|
|
231
260
|
});
|
|
232
261
|
}
|
|
262
|
+
|
|
233
263
|
{
|
|
234
264
|
const xs = [{ v: 2 }, { v: 1 }, { v: 3 }] as const;
|
|
265
|
+
|
|
235
266
|
const sorted = toSortedBy(
|
|
236
267
|
xs,
|
|
237
268
|
(x) => x.v,
|
|
@@ -254,16 +285,21 @@ describe('Arr transformations', () => {
|
|
|
254
285
|
{ name: 'Bob', age: 20 },
|
|
255
286
|
{ name: 'Charlie', age: 25 },
|
|
256
287
|
];
|
|
288
|
+
|
|
257
289
|
const result = toSortedBy(people, (person) => person.age);
|
|
258
290
|
|
|
259
291
|
expect(result).toHaveLength(3);
|
|
292
|
+
|
|
260
293
|
expect(result[0]?.name).toBe('Bob');
|
|
294
|
+
|
|
261
295
|
expect(result[1]?.name).toBe('Charlie');
|
|
296
|
+
|
|
262
297
|
expect(result[2]?.name).toBe('Alice');
|
|
263
298
|
});
|
|
264
299
|
|
|
265
300
|
test('should work with string sorting', () => {
|
|
266
301
|
const words = ['banana', 'apple', 'cherry'];
|
|
302
|
+
|
|
267
303
|
const result = toSortedBy(
|
|
268
304
|
words,
|
|
269
305
|
(word: string) => word,
|
|
@@ -275,6 +311,7 @@ describe('Arr transformations', () => {
|
|
|
275
311
|
|
|
276
312
|
test('should work with custom key extraction', () => {
|
|
277
313
|
const items = ['hello', 'hi', 'welcome', 'bye'];
|
|
314
|
+
|
|
278
315
|
const result = toSortedBy(items, (item) => item.length);
|
|
279
316
|
|
|
280
317
|
assert.deepStrictEqual(result, ['hi', 'bye', 'hello', 'welcome']);
|
|
@@ -282,6 +319,7 @@ describe('Arr transformations', () => {
|
|
|
282
319
|
|
|
283
320
|
test('should work with empty array', () => {
|
|
284
321
|
const empty: readonly { value: number }[] = [];
|
|
322
|
+
|
|
285
323
|
const result = toSortedBy(empty, (item) => item.value);
|
|
286
324
|
|
|
287
325
|
assert.deepStrictEqual(result, []);
|
|
@@ -289,6 +327,7 @@ describe('Arr transformations', () => {
|
|
|
289
327
|
|
|
290
328
|
test('toSortedBy should work with empty array', () => {
|
|
291
329
|
const empty: readonly { value: number }[] = [];
|
|
330
|
+
|
|
292
331
|
const result = toSortedBy(empty, (item) => item.value);
|
|
293
332
|
|
|
294
333
|
assert.deepStrictEqual(result, []);
|
|
@@ -298,6 +337,7 @@ describe('Arr transformations', () => {
|
|
|
298
337
|
describe(filter, () => {
|
|
299
338
|
test('should filter array with predicate', () => {
|
|
300
339
|
const numbers = [1, 2, 3, 4, 5];
|
|
340
|
+
|
|
301
341
|
const evens = filter(numbers, (n) => n % 2 === 0);
|
|
302
342
|
|
|
303
343
|
assert.deepStrictEqual(evens, [2, 4]);
|
|
@@ -311,7 +351,9 @@ describe('Arr transformations', () => {
|
|
|
311
351
|
'world',
|
|
312
352
|
123,
|
|
313
353
|
];
|
|
354
|
+
|
|
314
355
|
const strings = filter(mixed, (x): x is string => typeof x === 'string');
|
|
356
|
+
|
|
315
357
|
expectType<typeof strings, readonly string[]>('=');
|
|
316
358
|
|
|
317
359
|
assert.deepStrictEqual(strings, ['hello', 'world']);
|
|
@@ -319,7 +361,9 @@ describe('Arr transformations', () => {
|
|
|
319
361
|
|
|
320
362
|
test('should work with curried version', () => {
|
|
321
363
|
const isPositive = (n: number): boolean => n > 0;
|
|
364
|
+
|
|
322
365
|
const filterPositive = filter(isPositive);
|
|
366
|
+
|
|
323
367
|
const result = filterPositive([-1, 2, -3, 4]);
|
|
324
368
|
|
|
325
369
|
assert.deepStrictEqual(result, [2, 4]);
|
|
@@ -327,8 +371,11 @@ describe('Arr transformations', () => {
|
|
|
327
371
|
|
|
328
372
|
test('should work with curried type guards', () => {
|
|
329
373
|
const isString = (x: unknown): x is string => typeof x === 'string';
|
|
374
|
+
|
|
330
375
|
const filterStrings = filter(isString);
|
|
376
|
+
|
|
331
377
|
const result = filterStrings(['a', 1, 'b', 2]);
|
|
378
|
+
|
|
332
379
|
expectType<typeof result, readonly string[]>('=');
|
|
333
380
|
|
|
334
381
|
assert.deepStrictEqual(result, ['a', 'b']);
|
|
@@ -336,7 +383,9 @@ describe('Arr transformations', () => {
|
|
|
336
383
|
|
|
337
384
|
test('should preserve array type with generic predicate', () => {
|
|
338
385
|
const tuple = [1, 2, 3] as const;
|
|
386
|
+
|
|
339
387
|
const filtered = filter(tuple, (x) => x > 1);
|
|
388
|
+
|
|
340
389
|
expectType<typeof filtered, readonly (1 | 2 | 3)[]>('=');
|
|
341
390
|
|
|
342
391
|
assert.deepStrictEqual(filtered, [2, 3]);
|
|
@@ -344,6 +393,7 @@ describe('Arr transformations', () => {
|
|
|
344
393
|
|
|
345
394
|
test('should work with empty array', () => {
|
|
346
395
|
const empty: number[] = [];
|
|
396
|
+
|
|
347
397
|
const result = filter(empty, (n) => n > 0);
|
|
348
398
|
|
|
349
399
|
assert.deepStrictEqual(result, []);
|
|
@@ -351,6 +401,7 @@ describe('Arr transformations', () => {
|
|
|
351
401
|
|
|
352
402
|
test('should pass index to predicate', () => {
|
|
353
403
|
const numbers = [10, 20, 30, 40];
|
|
404
|
+
|
|
354
405
|
const evenIndexes = filter(numbers, (_, i) => i % 2 === 0);
|
|
355
406
|
|
|
356
407
|
assert.deepStrictEqual(evenIndexes, [10, 30]);
|
|
@@ -359,6 +410,7 @@ describe('Arr transformations', () => {
|
|
|
359
410
|
|
|
360
411
|
describe(filterNot, () => {
|
|
361
412
|
const xs = [1, 2, 3] as const;
|
|
413
|
+
|
|
362
414
|
const filtered = filterNot(xs, (x) => x % 2 === 0);
|
|
363
415
|
|
|
364
416
|
expectType<typeof filtered, readonly (1 | 2 | 3)[]>('=');
|
|
@@ -371,6 +423,7 @@ describe('Arr transformations', () => {
|
|
|
371
423
|
describe(uniq, () => {
|
|
372
424
|
test('should remove duplicate primitives', () => {
|
|
373
425
|
const array = [1, 2, 2, 3, 1, 4, 3];
|
|
426
|
+
|
|
374
427
|
const result = uniq(array);
|
|
375
428
|
|
|
376
429
|
assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
@@ -378,6 +431,7 @@ describe('Arr transformations', () => {
|
|
|
378
431
|
|
|
379
432
|
test('should work with strings', () => {
|
|
380
433
|
const array = ['a', 'b', 'a', 'c', 'b'];
|
|
434
|
+
|
|
381
435
|
const result = uniq(array);
|
|
382
436
|
|
|
383
437
|
assert.deepStrictEqual(result, ['a', 'b', 'c']);
|
|
@@ -385,6 +439,7 @@ describe('Arr transformations', () => {
|
|
|
385
439
|
|
|
386
440
|
test('should work with empty array', () => {
|
|
387
441
|
const array: readonly number[] = [];
|
|
442
|
+
|
|
388
443
|
const result = uniq(array);
|
|
389
444
|
|
|
390
445
|
assert.deepStrictEqual(result, []);
|
|
@@ -392,6 +447,7 @@ describe('Arr transformations', () => {
|
|
|
392
447
|
|
|
393
448
|
test('should preserve order of first occurrence', () => {
|
|
394
449
|
const array = [3, 1, 2, 1, 3, 2];
|
|
450
|
+
|
|
395
451
|
const result = uniq(array);
|
|
396
452
|
|
|
397
453
|
assert.deepStrictEqual(result, [3, 1, 2]);
|
|
@@ -406,27 +462,35 @@ describe('Arr transformations', () => {
|
|
|
406
462
|
{ id: 1, name: 'Alice Duplicate' },
|
|
407
463
|
{ id: 3, name: 'Charlie' },
|
|
408
464
|
];
|
|
465
|
+
|
|
409
466
|
const result = uniqBy(array, (item) => item.id);
|
|
410
467
|
|
|
411
468
|
expect(result).toHaveLength(3);
|
|
412
469
|
|
|
413
470
|
assert.deepStrictEqual(result[0], { id: 1, name: 'Alice' });
|
|
471
|
+
|
|
414
472
|
assert.deepStrictEqual(result[1], { id: 2, name: 'Bob' });
|
|
473
|
+
|
|
415
474
|
assert.deepStrictEqual(result[2], { id: 3, name: 'Charlie' });
|
|
416
475
|
});
|
|
417
476
|
|
|
418
477
|
test('should work with string key function', () => {
|
|
419
478
|
const words = ['hello', 'world', 'hi', 'welcome'];
|
|
479
|
+
|
|
420
480
|
const result = uniqBy(words, (word) => word.length);
|
|
421
481
|
|
|
422
482
|
expect(result).toHaveLength(3);
|
|
483
|
+
|
|
423
484
|
expect(result).toContain('hello'); // length 5
|
|
485
|
+
|
|
424
486
|
expect(result).toContain('hi'); // length 2
|
|
487
|
+
|
|
425
488
|
expect(result).toContain('welcome'); // length 7
|
|
426
489
|
});
|
|
427
490
|
|
|
428
491
|
test('should work with empty array', () => {
|
|
429
492
|
const empty: readonly { id: number }[] = [];
|
|
493
|
+
|
|
430
494
|
const result = uniqBy(empty, (item) => item.id);
|
|
431
495
|
|
|
432
496
|
assert.deepStrictEqual(result, []);
|
|
@@ -440,6 +504,7 @@ describe('Arr transformations', () => {
|
|
|
440
504
|
[3, 4],
|
|
441
505
|
[5, 6],
|
|
442
506
|
];
|
|
507
|
+
|
|
443
508
|
const flattened = flat(nested);
|
|
444
509
|
|
|
445
510
|
assert.deepStrictEqual(flattened, [1, 2, 3, 4, 5, 6]);
|
|
@@ -447,15 +512,19 @@ describe('Arr transformations', () => {
|
|
|
447
512
|
|
|
448
513
|
test('should flatten with specified depth', () => {
|
|
449
514
|
const deepNested = [1, [2, [3, 4]], 5];
|
|
515
|
+
|
|
450
516
|
const flat1 = flat(deepNested, 1);
|
|
517
|
+
|
|
451
518
|
const flat2 = flat(deepNested, 2);
|
|
452
519
|
|
|
453
520
|
assert.deepStrictEqual(flat1, [1, 2, [3, 4], 5]);
|
|
521
|
+
|
|
454
522
|
assert.deepStrictEqual(flat2, [1, 2, 3, 4, 5]);
|
|
455
523
|
});
|
|
456
524
|
|
|
457
525
|
test('should work with curried version', () => {
|
|
458
526
|
const flattenOnce = flat();
|
|
527
|
+
|
|
459
528
|
const result = flattenOnce([
|
|
460
529
|
[1, 2],
|
|
461
530
|
[3, 4],
|
|
@@ -466,6 +535,7 @@ describe('Arr transformations', () => {
|
|
|
466
535
|
|
|
467
536
|
test('should work with empty arrays', () => {
|
|
468
537
|
const withEmpties = [[1], [], [2, 3]];
|
|
538
|
+
|
|
469
539
|
const flattened = flat(withEmpties);
|
|
470
540
|
|
|
471
541
|
assert.deepStrictEqual(flattened, [1, 2, 3]);
|
|
@@ -476,6 +546,7 @@ describe('Arr transformations', () => {
|
|
|
476
546
|
[1, 2],
|
|
477
547
|
[3, 4],
|
|
478
548
|
];
|
|
549
|
+
|
|
479
550
|
const unflattened = flat(nested, 0);
|
|
480
551
|
|
|
481
552
|
assert.deepStrictEqual(unflattened, [
|
|
@@ -486,6 +557,7 @@ describe('Arr transformations', () => {
|
|
|
486
557
|
|
|
487
558
|
test('should work with infinite depth', () => {
|
|
488
559
|
const veryDeep = [1, [2, [3, [4, [5]]]]];
|
|
560
|
+
|
|
489
561
|
const allFlat = flat(veryDeep, SafeUint.MAX_VALUE);
|
|
490
562
|
|
|
491
563
|
assert.deepStrictEqual(allFlat, [1, 2, 3, 4, 5]);
|
|
@@ -495,6 +567,7 @@ describe('Arr transformations', () => {
|
|
|
495
567
|
describe(flatMap, () => {
|
|
496
568
|
test('should map and flatten results', () => {
|
|
497
569
|
const words = ['hello', 'world'];
|
|
570
|
+
|
|
498
571
|
const chars = flatMap(words, (word) => word.split(''));
|
|
499
572
|
|
|
500
573
|
assert.deepStrictEqual(chars, [
|
|
@@ -513,6 +586,7 @@ describe('Arr transformations', () => {
|
|
|
513
586
|
|
|
514
587
|
test('should work with curried version', () => {
|
|
515
588
|
const splitWords = flatMap((word: string) => word.split(''));
|
|
589
|
+
|
|
516
590
|
const result = splitWords(['foo', 'bar']);
|
|
517
591
|
|
|
518
592
|
assert.deepStrictEqual(result, ['f', 'o', 'o', 'b', 'a', 'r']);
|
|
@@ -520,6 +594,7 @@ describe('Arr transformations', () => {
|
|
|
520
594
|
|
|
521
595
|
test('should work with numbers', () => {
|
|
522
596
|
const numbers = [1, 2, 3];
|
|
597
|
+
|
|
523
598
|
const doubled = flatMap(numbers, (n) => [n, n * 2]);
|
|
524
599
|
|
|
525
600
|
assert.deepStrictEqual(doubled, [1, 2, 2, 4, 3, 6]);
|
|
@@ -527,6 +602,7 @@ describe('Arr transformations', () => {
|
|
|
527
602
|
|
|
528
603
|
test('should pass index to mapping function', () => {
|
|
529
604
|
const numbers = [10, 20];
|
|
605
|
+
|
|
530
606
|
const result = flatMap(numbers, (n, i) => [n, i]);
|
|
531
607
|
|
|
532
608
|
assert.deepStrictEqual(result, [10, 0, 20, 1]);
|
|
@@ -534,6 +610,7 @@ describe('Arr transformations', () => {
|
|
|
534
610
|
|
|
535
611
|
test('should work with empty arrays', () => {
|
|
536
612
|
const empty: string[] = [];
|
|
613
|
+
|
|
537
614
|
const result = flatMap(empty, (s) => s.split(''));
|
|
538
615
|
|
|
539
616
|
assert.deepStrictEqual(result, []);
|
|
@@ -541,6 +618,7 @@ describe('Arr transformations', () => {
|
|
|
541
618
|
|
|
542
619
|
test('should handle mapping to empty arrays', () => {
|
|
543
620
|
const numbers = [1, 2, 3];
|
|
621
|
+
|
|
544
622
|
const result = flatMap(numbers, (n) => (n % 2 === 0 ? [n] : []));
|
|
545
623
|
|
|
546
624
|
assert.deepStrictEqual(result, [2]);
|
|
@@ -548,6 +626,7 @@ describe('Arr transformations', () => {
|
|
|
548
626
|
|
|
549
627
|
test('should work with tuples', () => {
|
|
550
628
|
const tuple = [1, 2] as const;
|
|
629
|
+
|
|
551
630
|
const result = flatMap(tuple, (n) => [n, n]);
|
|
552
631
|
|
|
553
632
|
assert.deepStrictEqual(result, [1, 1, 2, 2]);
|
|
@@ -650,6 +729,7 @@ describe('Arr transformations', () => {
|
|
|
650
729
|
|
|
651
730
|
test('should partition array into chunks', () => {
|
|
652
731
|
const numbers = [1, 2, 3, 4, 5, 6];
|
|
732
|
+
|
|
653
733
|
const result = partition(numbers, 2);
|
|
654
734
|
|
|
655
735
|
assert.deepStrictEqual(result, [
|
|
@@ -661,6 +741,7 @@ describe('Arr transformations', () => {
|
|
|
661
741
|
|
|
662
742
|
test('should handle arrays not evenly divisible by chunk size', () => {
|
|
663
743
|
const numbers = [1, 2, 3, 4, 5];
|
|
744
|
+
|
|
664
745
|
const result = partition(numbers, 2);
|
|
665
746
|
|
|
666
747
|
assert.deepStrictEqual(result, [[1, 2], [3, 4], [5]]);
|
|
@@ -668,6 +749,7 @@ describe('Arr transformations', () => {
|
|
|
668
749
|
|
|
669
750
|
test('should work with chunk size < 2 (returns empty)', () => {
|
|
670
751
|
const numbers = [1, 2, 3];
|
|
752
|
+
|
|
671
753
|
const result = partition(numbers, 1);
|
|
672
754
|
|
|
673
755
|
// According to docs, returns empty array if chunkSize < 2
|
|
@@ -676,6 +758,7 @@ describe('Arr transformations', () => {
|
|
|
676
758
|
|
|
677
759
|
test('should work with chunk size larger than array', () => {
|
|
678
760
|
const numbers = [1, 2];
|
|
761
|
+
|
|
679
762
|
const result = partition(numbers, 5);
|
|
680
763
|
|
|
681
764
|
assert.deepStrictEqual(result, [[1, 2]]);
|
|
@@ -683,6 +766,7 @@ describe('Arr transformations', () => {
|
|
|
683
766
|
|
|
684
767
|
test('partition should work with empty array', () => {
|
|
685
768
|
const empty: readonly number[] = [];
|
|
769
|
+
|
|
686
770
|
const result = partition(empty, 2);
|
|
687
771
|
|
|
688
772
|
assert.deepStrictEqual(result, []);
|
|
@@ -691,7 +775,9 @@ describe('Arr transformations', () => {
|
|
|
691
775
|
|
|
692
776
|
describe(concat, () => {
|
|
693
777
|
const xs = [1, 2, 3] as const;
|
|
778
|
+
|
|
694
779
|
const ys = [4, 5] as const;
|
|
780
|
+
|
|
695
781
|
const result = concat(xs, ys);
|
|
696
782
|
|
|
697
783
|
expectType<typeof result, readonly [1, 2, 3, 4, 5]>('=');
|
|
@@ -798,35 +884,43 @@ describe('Arr transformations', () => {
|
|
|
798
884
|
{ type: 'vegetable', name: 'carrot' },
|
|
799
885
|
{ type: 'fruit', name: 'banana' },
|
|
800
886
|
];
|
|
887
|
+
|
|
801
888
|
const grouped = groupBy(array, (item) => item.type);
|
|
802
889
|
|
|
803
890
|
expect(grouped.size).toBe(2);
|
|
804
891
|
|
|
805
892
|
const fruits = grouped.get('fruit');
|
|
893
|
+
|
|
806
894
|
const vegetables = grouped.get('vegetable');
|
|
807
895
|
|
|
808
|
-
|
|
809
|
-
|
|
896
|
+
assert.isTrue(Optional.isSome(fruits));
|
|
897
|
+
|
|
898
|
+
assert.isTrue(Optional.isSome(vegetables));
|
|
810
899
|
|
|
811
900
|
if (Optional.isSome(fruits)) {
|
|
812
901
|
expect(fruits.value).toHaveLength(2);
|
|
902
|
+
|
|
813
903
|
expect(fruits.value[0]?.name).toBe('apple');
|
|
904
|
+
|
|
814
905
|
expect(fruits.value[1]?.name).toBe('banana');
|
|
815
906
|
}
|
|
816
907
|
|
|
817
908
|
if (Optional.isSome(vegetables)) {
|
|
818
909
|
expect(vegetables.value).toHaveLength(1);
|
|
910
|
+
|
|
819
911
|
expect(vegetables.value[0]?.name).toBe('carrot');
|
|
820
912
|
}
|
|
821
913
|
});
|
|
822
914
|
|
|
823
915
|
test('should work with numeric keys', () => {
|
|
824
916
|
const numbers = [1, 2, 3, 4, 5, 6];
|
|
917
|
+
|
|
825
918
|
const grouped = groupBy(numbers, (n) => n % 2);
|
|
826
919
|
|
|
827
920
|
expect(grouped.size).toBe(2);
|
|
828
921
|
|
|
829
922
|
const evens = grouped.get(0);
|
|
923
|
+
|
|
830
924
|
const odds = grouped.get(1);
|
|
831
925
|
|
|
832
926
|
if (Optional.isSome(evens)) {
|
|
@@ -840,6 +934,7 @@ describe('Arr transformations', () => {
|
|
|
840
934
|
|
|
841
935
|
test('should work with empty array', () => {
|
|
842
936
|
const empty: readonly number[] = [];
|
|
937
|
+
|
|
843
938
|
const grouped = groupBy(empty, (n) => n % 2);
|
|
844
939
|
|
|
845
940
|
expect(grouped.size).toBe(0);
|
|
@@ -847,6 +942,7 @@ describe('Arr transformations', () => {
|
|
|
847
942
|
|
|
848
943
|
test('should handle all elements in same group', () => {
|
|
849
944
|
const array = [1, 2, 3, 4];
|
|
945
|
+
|
|
850
946
|
const grouped = groupBy(array, () => 'all');
|
|
851
947
|
|
|
852
948
|
expect(grouped.size).toBe(1);
|
|
@@ -862,7 +958,9 @@ describe('Arr transformations', () => {
|
|
|
862
958
|
describe(zip, () => {
|
|
863
959
|
{
|
|
864
960
|
const xs = [1, 2, 3] as const;
|
|
961
|
+
|
|
865
962
|
const ys = [4, 5, 6] as const;
|
|
963
|
+
|
|
866
964
|
const zipped = zip(xs, ys);
|
|
867
965
|
|
|
868
966
|
expectType<
|
|
@@ -878,9 +976,12 @@ describe('Arr transformations', () => {
|
|
|
878
976
|
]);
|
|
879
977
|
});
|
|
880
978
|
}
|
|
979
|
+
|
|
881
980
|
{
|
|
882
981
|
const xs: readonly number[] = [1, 2, 3];
|
|
982
|
+
|
|
883
983
|
const ys: readonly number[] = [4];
|
|
984
|
+
|
|
884
985
|
const zipped = zip(xs, ys);
|
|
885
986
|
|
|
886
987
|
expectType<typeof zipped, readonly (readonly [number, number])[]>('=');
|
|
@@ -889,9 +990,12 @@ describe('Arr transformations', () => {
|
|
|
889
990
|
assert.deepStrictEqual(zipped, [[1, 4]]);
|
|
890
991
|
});
|
|
891
992
|
}
|
|
993
|
+
|
|
892
994
|
{
|
|
893
995
|
const xs = [1] as const;
|
|
996
|
+
|
|
894
997
|
const ys: readonly number[] = [4, 5, 6];
|
|
998
|
+
|
|
895
999
|
const zipped = zip(xs, ys);
|
|
896
1000
|
|
|
897
1001
|
expectType<typeof zipped, readonly [readonly [1, number]]>('=');
|
|
@@ -943,7 +1047,9 @@ describe('Arr transformations', () => {
|
|
|
943
1047
|
|
|
944
1048
|
test('should zip two arrays', () => {
|
|
945
1049
|
const arr1 = [1, 2, 3];
|
|
1050
|
+
|
|
946
1051
|
const arr2 = ['a', 'b', 'c'];
|
|
1052
|
+
|
|
947
1053
|
const result = zip(arr1, arr2);
|
|
948
1054
|
|
|
949
1055
|
assert.deepStrictEqual(result, [
|
|
@@ -955,7 +1061,9 @@ describe('Arr transformations', () => {
|
|
|
955
1061
|
|
|
956
1062
|
test('should handle arrays of different lengths', () => {
|
|
957
1063
|
const arr1 = [1, 2, 3, 4];
|
|
1064
|
+
|
|
958
1065
|
const arr2 = ['a', 'b'];
|
|
1066
|
+
|
|
959
1067
|
const result = zip(arr1, arr2);
|
|
960
1068
|
|
|
961
1069
|
assert.deepStrictEqual(result, [
|
|
@@ -966,7 +1074,9 @@ describe('Arr transformations', () => {
|
|
|
966
1074
|
|
|
967
1075
|
test('should work with empty arrays', () => {
|
|
968
1076
|
const arr1: readonly number[] = [];
|
|
1077
|
+
|
|
969
1078
|
const arr2: readonly string[] = [];
|
|
1079
|
+
|
|
970
1080
|
const result = zip(arr1, arr2);
|
|
971
1081
|
|
|
972
1082
|
assert.deepStrictEqual(result, []);
|
|
@@ -974,7 +1084,9 @@ describe('Arr transformations', () => {
|
|
|
974
1084
|
|
|
975
1085
|
test('should handle one empty array', () => {
|
|
976
1086
|
const arr1 = [1, 2, 3];
|
|
1087
|
+
|
|
977
1088
|
const arr2: readonly string[] = [];
|
|
1089
|
+
|
|
978
1090
|
const result = zip(arr1, arr2);
|
|
979
1091
|
|
|
980
1092
|
assert.deepStrictEqual(result, []);
|