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
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
describe('Arr modifications', () => {
|
|
15
15
|
describe(toUpdated, () => {
|
|
16
16
|
const xs = [1, 2, 3] as const;
|
|
17
|
+
|
|
17
18
|
const result = toUpdated(xs, 1, (x) => x + 2);
|
|
18
19
|
|
|
19
20
|
expectType<typeof result, ArrayOfLength<3, number>>('=');
|
|
@@ -21,6 +22,14 @@ describe('Arr modifications', () => {
|
|
|
21
22
|
test('case 1', () => {
|
|
22
23
|
assert.deepStrictEqual(result, [1, 4, 3]);
|
|
23
24
|
});
|
|
25
|
+
|
|
26
|
+
test('should work with curried version', () => {
|
|
27
|
+
const updater = toUpdated(1, (x: number) => x * 2);
|
|
28
|
+
|
|
29
|
+
const r = updater([10, 20, 30]);
|
|
30
|
+
|
|
31
|
+
assert.deepStrictEqual(r, [10, 40, 30]);
|
|
32
|
+
});
|
|
24
33
|
});
|
|
25
34
|
|
|
26
35
|
describe(toInserted, () => {
|
|
@@ -53,11 +62,20 @@ describe('Arr modifications', () => {
|
|
|
53
62
|
|
|
54
63
|
assert.deepStrictEqual(result, ['a', 'b', 'c', 5]);
|
|
55
64
|
});
|
|
65
|
+
|
|
66
|
+
test('should work with curried version', () => {
|
|
67
|
+
const inserter = toInserted(2, 99);
|
|
68
|
+
|
|
69
|
+
const result = inserter([1, 2, 3]);
|
|
70
|
+
|
|
71
|
+
assert.deepStrictEqual(result, [1, 2, 99, 3]);
|
|
72
|
+
});
|
|
56
73
|
});
|
|
57
74
|
|
|
58
75
|
describe(toRemoved, () => {
|
|
59
76
|
test('case 1', () => {
|
|
60
77
|
const xs = [1, 2, 3] as const;
|
|
78
|
+
|
|
61
79
|
const result = toRemoved(xs, 1);
|
|
62
80
|
|
|
63
81
|
expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
|
|
@@ -67,6 +85,7 @@ describe('Arr modifications', () => {
|
|
|
67
85
|
|
|
68
86
|
test('case 2 (remove head)', () => {
|
|
69
87
|
const xs = [1, 2, 3] as const;
|
|
88
|
+
|
|
70
89
|
const result = toRemoved(xs, 0);
|
|
71
90
|
|
|
72
91
|
expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
|
|
@@ -76,6 +95,7 @@ describe('Arr modifications', () => {
|
|
|
76
95
|
|
|
77
96
|
test('case 3 (remove tail)', () => {
|
|
78
97
|
const xs = [1, 2, 3] as const;
|
|
98
|
+
|
|
79
99
|
const result = toRemoved(xs, 2);
|
|
80
100
|
|
|
81
101
|
expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
|
|
@@ -85,17 +105,27 @@ describe('Arr modifications', () => {
|
|
|
85
105
|
|
|
86
106
|
test('case 4 (number[])', () => {
|
|
87
107
|
const xs: number[] = [1, 2, 3];
|
|
108
|
+
|
|
88
109
|
const result = toRemoved(xs, 5);
|
|
89
110
|
|
|
90
111
|
expectType<typeof result, readonly number[]>('=');
|
|
91
112
|
|
|
92
113
|
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
93
114
|
});
|
|
115
|
+
|
|
116
|
+
test('should work with curried version', () => {
|
|
117
|
+
const removeFirst = toRemoved(0);
|
|
118
|
+
|
|
119
|
+
const result = removeFirst([10, 20, 30]);
|
|
120
|
+
|
|
121
|
+
assert.deepStrictEqual(result, [20, 30]);
|
|
122
|
+
});
|
|
94
123
|
});
|
|
95
124
|
|
|
96
125
|
describe(toPushed, () => {
|
|
97
126
|
test('case 1', () => {
|
|
98
127
|
const xs = [1, 2, 3] as const;
|
|
128
|
+
|
|
99
129
|
const result = toPushed(xs, 4 as const);
|
|
100
130
|
|
|
101
131
|
expectType<typeof result, readonly [1, 2, 3, 4]>('=');
|
|
@@ -105,12 +135,21 @@ describe('Arr modifications', () => {
|
|
|
105
135
|
|
|
106
136
|
test('case 2', () => {
|
|
107
137
|
const xs: number[] = [1, 2, 3];
|
|
138
|
+
|
|
108
139
|
const result = toPushed(xs, 4 as const);
|
|
109
140
|
|
|
110
141
|
expectType<typeof result, readonly [...number[], 4]>('=');
|
|
111
142
|
|
|
112
143
|
assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
113
144
|
});
|
|
145
|
+
|
|
146
|
+
test('should work with curried version', () => {
|
|
147
|
+
const pushFive = toPushed(5);
|
|
148
|
+
|
|
149
|
+
const result = pushFive([1, 2, 3]);
|
|
150
|
+
|
|
151
|
+
assert.deepStrictEqual(result, [1, 2, 3, 5]);
|
|
152
|
+
});
|
|
114
153
|
});
|
|
115
154
|
|
|
116
155
|
describe(toUnshifted, () => {
|
|
@@ -133,11 +172,20 @@ describe('Arr modifications', () => {
|
|
|
133
172
|
|
|
134
173
|
assert.deepStrictEqual(result, [4, 1, 2, 3]);
|
|
135
174
|
});
|
|
175
|
+
|
|
176
|
+
test('should work with curried version', () => {
|
|
177
|
+
const unshiftZero = toUnshifted(0);
|
|
178
|
+
|
|
179
|
+
const result = unshiftZero([1, 2, 3]);
|
|
180
|
+
|
|
181
|
+
assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
182
|
+
});
|
|
136
183
|
});
|
|
137
184
|
|
|
138
185
|
describe(toFilled, () => {
|
|
139
186
|
test('should fill entire array with value', () => {
|
|
140
187
|
const arr = [1, 2, 3, 4, 5];
|
|
188
|
+
|
|
141
189
|
const result = toFilled(arr, 0);
|
|
142
190
|
|
|
143
191
|
assert.deepStrictEqual(result, [0, 0, 0, 0, 0]);
|
|
@@ -145,7 +193,9 @@ describe('Arr modifications', () => {
|
|
|
145
193
|
|
|
146
194
|
test('should work with curried version', () => {
|
|
147
195
|
const fillWithZero = toFilled(0);
|
|
196
|
+
|
|
148
197
|
const arr = [1, 2, 3];
|
|
198
|
+
|
|
149
199
|
const result = fillWithZero(arr);
|
|
150
200
|
|
|
151
201
|
assert.deepStrictEqual(result, [0, 0, 0]);
|
|
@@ -155,6 +205,7 @@ describe('Arr modifications', () => {
|
|
|
155
205
|
describe(toRangeFilled, () => {
|
|
156
206
|
test('should fill array with range', () => {
|
|
157
207
|
const arr = [1, 2, 3, 4, 5];
|
|
208
|
+
|
|
158
209
|
const result = toRangeFilled(arr, 0, [1, 4]);
|
|
159
210
|
|
|
160
211
|
assert.deepStrictEqual(result, [1, 0, 0, 0, 5]);
|
|
@@ -162,6 +213,7 @@ describe('Arr modifications', () => {
|
|
|
162
213
|
|
|
163
214
|
test('should fill with range starting from 0', () => {
|
|
164
215
|
const arr = [1, 2, 3, 4, 5];
|
|
216
|
+
|
|
165
217
|
const result = toRangeFilled(arr, 9, [0, 3]);
|
|
166
218
|
|
|
167
219
|
assert.deepStrictEqual(result, [9, 9, 9, 4, 5]);
|
|
@@ -169,6 +221,7 @@ describe('Arr modifications', () => {
|
|
|
169
221
|
|
|
170
222
|
test('should handle empty range', () => {
|
|
171
223
|
const arr = [1, 2, 3];
|
|
224
|
+
|
|
172
225
|
const result = toRangeFilled(arr, 0, [2, 2]);
|
|
173
226
|
|
|
174
227
|
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
@@ -176,6 +229,7 @@ describe('Arr modifications', () => {
|
|
|
176
229
|
|
|
177
230
|
test('should clamp range to array bounds', () => {
|
|
178
231
|
const arr = [1, 2, 3];
|
|
232
|
+
|
|
179
233
|
const result = toRangeFilled(arr, 0, [1, 10]);
|
|
180
234
|
|
|
181
235
|
assert.deepStrictEqual(result, [1, 0, 0]);
|
|
@@ -183,11 +237,20 @@ describe('Arr modifications', () => {
|
|
|
183
237
|
|
|
184
238
|
test('should handle negative start (clamped to 0)', () => {
|
|
185
239
|
const arr = [1, 2, 3];
|
|
240
|
+
|
|
186
241
|
const result = toRangeFilled(arr, 9, [-5, 2]);
|
|
187
242
|
|
|
188
243
|
assert.deepStrictEqual(result, [9, 9, 3]);
|
|
189
244
|
});
|
|
190
245
|
|
|
246
|
+
test('should work with curried version', () => {
|
|
247
|
+
const fillMiddle = toRangeFilled(7, [1, 3]);
|
|
248
|
+
|
|
249
|
+
const result = fillMiddle([1, 2, 3, 4]);
|
|
250
|
+
|
|
251
|
+
assert.deepStrictEqual(result, [1, 7, 7, 4]);
|
|
252
|
+
});
|
|
253
|
+
|
|
191
254
|
test('A non-integer starting value should result in a type error', () => {
|
|
192
255
|
const arr = [1, 2, 3];
|
|
193
256
|
|
|
@@ -214,7 +277,9 @@ describe('Arr modifications', () => {
|
|
|
214
277
|
|
|
215
278
|
test('should work with different value types', () => {
|
|
216
279
|
const nums = [1, 2, 3] as const;
|
|
280
|
+
|
|
217
281
|
const withString = set(nums, 1, 'two');
|
|
282
|
+
|
|
218
283
|
expectType<typeof withString, readonly [1 | 'two', 2 | 'two', 3 | 'two']>(
|
|
219
284
|
'=',
|
|
220
285
|
);
|
|
@@ -224,6 +289,7 @@ describe('Arr modifications', () => {
|
|
|
224
289
|
|
|
225
290
|
test('should work at index 0', () => {
|
|
226
291
|
const tuple = ['a', 'b', 'c'] as const;
|
|
292
|
+
|
|
227
293
|
const updated = set(tuple, 0, 'A');
|
|
228
294
|
|
|
229
295
|
assert.deepStrictEqual(updated, ['A', 'b', 'c']);
|
|
@@ -231,9 +297,18 @@ describe('Arr modifications', () => {
|
|
|
231
297
|
|
|
232
298
|
test('should work at last index', () => {
|
|
233
299
|
const tuple = ['a', 'b', 'c'] as const;
|
|
300
|
+
|
|
234
301
|
const updated = set(tuple, 2, 'C');
|
|
235
302
|
|
|
236
303
|
assert.deepStrictEqual(updated, ['a', 'b', 'C']);
|
|
237
304
|
});
|
|
305
|
+
|
|
306
|
+
test('should work with curried version', () => {
|
|
307
|
+
const setIndex1To99 = set(1, 99);
|
|
308
|
+
|
|
309
|
+
const r = setIndex1To99([10, 20, 30]);
|
|
310
|
+
|
|
311
|
+
assert.deepStrictEqual(r, [10, 99, 30]);
|
|
312
|
+
});
|
|
238
313
|
});
|
|
239
314
|
});
|
|
@@ -8,20 +8,25 @@ import { filterNot, partition } from './array-utils-transformation.mjs';
|
|
|
8
8
|
|
|
9
9
|
describe('Array overloaded functions - type error validation', () => {
|
|
10
10
|
const testArray = [1, 2, 3, 4, 5] as const;
|
|
11
|
+
|
|
11
12
|
const predicate = (x: number): boolean => x > 3;
|
|
12
13
|
|
|
13
14
|
describe('findIndex type safety', () => {
|
|
14
15
|
test('findIndex with correct arguments should work', () => {
|
|
15
16
|
// These should work fine
|
|
16
17
|
const _result1 = findIndex(testArray, predicate);
|
|
18
|
+
|
|
17
19
|
const _result2 = findIndex(predicate);
|
|
20
|
+
|
|
18
21
|
const _result3 = findIndex(predicate)(testArray);
|
|
19
22
|
|
|
20
23
|
expectType<typeof _result1, 0 | 1 | 2 | 3 | 4 | -1>('=');
|
|
24
|
+
|
|
21
25
|
expectType<
|
|
22
26
|
typeof _result2,
|
|
23
27
|
(array: readonly number[]) => SizeType.Arr | -1
|
|
24
28
|
>('=');
|
|
29
|
+
|
|
25
30
|
expectType<typeof _result3, SizeType.Arr | -1>('=');
|
|
26
31
|
});
|
|
27
32
|
|
|
@@ -41,14 +46,18 @@ describe('Array overloaded functions - type error validation', () => {
|
|
|
41
46
|
test('filterNot with correct arguments should work', () => {
|
|
42
47
|
// These should work fine
|
|
43
48
|
const _result1 = filterNot(testArray, predicate);
|
|
49
|
+
|
|
44
50
|
const _result2 = filterNot(predicate);
|
|
51
|
+
|
|
45
52
|
const _result3 = filterNot(predicate)(testArray);
|
|
46
53
|
|
|
47
54
|
expectType<typeof _result1, readonly number[]>('<=');
|
|
55
|
+
|
|
48
56
|
expectType<
|
|
49
57
|
typeof _result2,
|
|
50
58
|
(array: readonly number[]) => readonly number[]
|
|
51
59
|
>('<=');
|
|
60
|
+
|
|
52
61
|
expectType<typeof _result3, readonly number[]>('<=');
|
|
53
62
|
});
|
|
54
63
|
|
|
@@ -67,14 +76,18 @@ describe('Array overloaded functions - type error validation', () => {
|
|
|
67
76
|
test('partition with correct arguments should work', () => {
|
|
68
77
|
// These should work fine
|
|
69
78
|
const _result1 = partition(testArray, 2);
|
|
79
|
+
|
|
70
80
|
const _result2 = partition(2);
|
|
81
|
+
|
|
71
82
|
const _result3 = partition(2)(testArray);
|
|
72
83
|
|
|
73
84
|
expectType<typeof _result1, readonly (readonly number[])[]>('<=');
|
|
85
|
+
|
|
74
86
|
expectType<
|
|
75
87
|
typeof _result2,
|
|
76
88
|
<A>(array: readonly A[]) => readonly (readonly A[])[]
|
|
77
89
|
>('<=');
|
|
90
|
+
|
|
78
91
|
expectType<typeof _result3, readonly (readonly number[])[]>('<=');
|
|
79
92
|
});
|
|
80
93
|
|
|
@@ -93,9 +106,11 @@ describe('Array overloaded functions - type error validation', () => {
|
|
|
93
106
|
test('range with correct arguments should work', () => {
|
|
94
107
|
// These should work fine
|
|
95
108
|
const _result1 = range(1, 5);
|
|
109
|
+
|
|
96
110
|
const _result2 = range(1, 5, 1);
|
|
97
111
|
|
|
98
112
|
expectType<typeof _result1, readonly [1, 2, 3, 4]>('=');
|
|
113
|
+
|
|
99
114
|
expectType<typeof _result2, readonly [1, 2, 3, 4]>('=');
|
|
100
115
|
});
|
|
101
116
|
|
|
@@ -112,12 +127,15 @@ describe('Array overloaded functions - type error validation', () => {
|
|
|
112
127
|
test('spread with correct tuple types should work', () => {
|
|
113
128
|
// Correct usage with spread
|
|
114
129
|
const correctArgs1 = [testArray, predicate] as const;
|
|
130
|
+
|
|
115
131
|
const correctArgs2 = [predicate] as const;
|
|
116
132
|
|
|
117
133
|
const _result1 = findIndex(...correctArgs1);
|
|
134
|
+
|
|
118
135
|
const _result2 = findIndex(...correctArgs2);
|
|
119
136
|
|
|
120
137
|
expectType<typeof _result1, 0 | 1 | 2 | 3 | 4 | -1>('<=');
|
|
138
|
+
|
|
121
139
|
expectType<
|
|
122
140
|
typeof _result2,
|
|
123
141
|
(array: readonly number[]) => SizeType.Arr | -1
|
|
@@ -141,6 +159,7 @@ describe('Array overloaded functions - type error validation', () => {
|
|
|
141
159
|
test('composition should preserve type safety', () => {
|
|
142
160
|
// This should work
|
|
143
161
|
const findPositive = findIndex((x: number) => x > 0);
|
|
162
|
+
|
|
144
163
|
const filterNegative = filterNot((x: number) => x < 0);
|
|
145
164
|
|
|
146
165
|
const _composedResult = pipe(testArray)
|
|
@@ -13,14 +13,19 @@ import { isNonEmpty } from './array-utils-validation.mjs';
|
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
15
|
* const values = [5, 3, 9] as const;
|
|
16
|
+
*
|
|
16
17
|
* const empty: readonly number[] = [];
|
|
17
18
|
*
|
|
18
19
|
* const smallest = Arr.min(values);
|
|
20
|
+
*
|
|
19
21
|
* const none = Arr.min(empty);
|
|
22
|
+
*
|
|
20
23
|
* const custom = Arr.min(values, (a, b) => b - a);
|
|
21
24
|
*
|
|
22
25
|
* assert.deepStrictEqual(smallest, Optional.some(3));
|
|
26
|
+
*
|
|
23
27
|
* assert.deepStrictEqual(none, Optional.none);
|
|
28
|
+
*
|
|
24
29
|
* assert.deepStrictEqual(custom, Optional.some(9));
|
|
25
30
|
* ```
|
|
26
31
|
*/
|
|
@@ -62,9 +67,11 @@ export function min<E extends number>(
|
|
|
62
67
|
* const values = [5, 3, 9];
|
|
63
68
|
*
|
|
64
69
|
* const largest = Arr.max(values);
|
|
70
|
+
*
|
|
65
71
|
* const reversed = Arr.max(values, (a, b) => b - a);
|
|
66
72
|
*
|
|
67
73
|
* assert.deepStrictEqual(largest, Optional.some(9));
|
|
74
|
+
*
|
|
68
75
|
* assert.deepStrictEqual(reversed, Optional.some(3));
|
|
69
76
|
* ```
|
|
70
77
|
*/
|
|
@@ -84,6 +91,7 @@ export function max<E extends number>(
|
|
|
84
91
|
comparator?: (x: E, y: E) => number,
|
|
85
92
|
): Optional<E> {
|
|
86
93
|
const cmp = comparator ?? ((x, y) => Num.from(x) - Num.from(y));
|
|
94
|
+
|
|
87
95
|
// Find max by finding min with an inverted comparator
|
|
88
96
|
return min(array, (x, y) => -cmp(x, y));
|
|
89
97
|
}
|
|
@@ -101,6 +109,7 @@ export function max<E extends number>(
|
|
|
101
109
|
* ] as const;
|
|
102
110
|
*
|
|
103
111
|
* const leastVisits = Arr.minBy(users, (user) => user.visits);
|
|
112
|
+
*
|
|
104
113
|
* const custom = Arr.minBy(
|
|
105
114
|
* users,
|
|
106
115
|
* (user) => user.visits,
|
|
@@ -108,6 +117,7 @@ export function max<E extends number>(
|
|
|
108
117
|
* );
|
|
109
118
|
*
|
|
110
119
|
* assert.deepStrictEqual(leastVisits, Optional.some({ id: 2, visits: 3 }));
|
|
120
|
+
*
|
|
111
121
|
* assert.deepStrictEqual(custom, Optional.some({ id: 1, visits: 10 }));
|
|
112
122
|
* ```
|
|
113
123
|
*/
|
|
@@ -148,6 +158,7 @@ export function minBy<E, V>(
|
|
|
148
158
|
* ];
|
|
149
159
|
*
|
|
150
160
|
* const mostStars = Arr.maxBy(projects, (project) => project.stars);
|
|
161
|
+
*
|
|
151
162
|
* const smallestStars = Arr.maxBy(
|
|
152
163
|
* projects,
|
|
153
164
|
* (project) => project.stars,
|
|
@@ -155,6 +166,7 @@ export function minBy<E, V>(
|
|
|
155
166
|
* );
|
|
156
167
|
*
|
|
157
168
|
* assert.deepStrictEqual(mostStars, Optional.some({ id: 'b', stars: 30 }));
|
|
169
|
+
*
|
|
158
170
|
* assert.deepStrictEqual(smallestStars, Optional.some({ id: 'a', stars: 10 }));
|
|
159
171
|
* ```
|
|
160
172
|
*/
|
|
@@ -191,10 +203,12 @@ export function maxBy<E, V>(
|
|
|
191
203
|
* const words = ['Ada', 'Grace', 'Linus'] as const;
|
|
192
204
|
*
|
|
193
205
|
* const longWords = Arr.count(words, (word) => word.length > 4);
|
|
206
|
+
*
|
|
194
207
|
* const withCurried = Arr.count<string>((word) => word.includes('a'))(words);
|
|
195
208
|
*
|
|
196
|
-
* assert(longWords === 2);
|
|
197
|
-
*
|
|
209
|
+
* assert.isTrue(longWords === 2);
|
|
210
|
+
*
|
|
211
|
+
* assert.isTrue(withCurried === 2);
|
|
198
212
|
* ```
|
|
199
213
|
*/
|
|
200
214
|
export function count<const Ar extends readonly unknown[]>(
|
|
@@ -217,14 +231,17 @@ export function count<E>(
|
|
|
217
231
|
switch (args.length) {
|
|
218
232
|
case 2: {
|
|
219
233
|
const [array, predicate] = args;
|
|
234
|
+
|
|
220
235
|
return array.reduce<Uint32>(
|
|
221
236
|
(acc, curr, index) =>
|
|
222
237
|
predicate(curr, asUint32(index)) ? Uint32.add(acc, 1) : acc,
|
|
223
238
|
asUint32(0),
|
|
224
239
|
);
|
|
225
240
|
}
|
|
241
|
+
|
|
226
242
|
case 1: {
|
|
227
243
|
const [predicate] = args;
|
|
244
|
+
|
|
228
245
|
return (array) => count(array, predicate);
|
|
229
246
|
}
|
|
230
247
|
}
|
|
@@ -241,7 +258,9 @@ export function count<E>(
|
|
|
241
258
|
* const counts = Arr.countBy(words, (word) => word[0]);
|
|
242
259
|
*
|
|
243
260
|
* assert.deepStrictEqual(counts.get('A'), Optional.some(2));
|
|
261
|
+
*
|
|
244
262
|
* assert.deepStrictEqual(counts.get('G'), Optional.some(1));
|
|
263
|
+
*
|
|
245
264
|
* assert.deepStrictEqual(counts.get('B'), Optional.some(1));
|
|
246
265
|
* ```
|
|
247
266
|
*/
|
|
@@ -268,10 +287,12 @@ export function countBy<E, G extends MapSetKeyType>(
|
|
|
268
287
|
switch (args.length) {
|
|
269
288
|
case 2: {
|
|
270
289
|
const [array, grouper] = args;
|
|
290
|
+
|
|
271
291
|
const mut_groups = new Map<G, SizeType.Arr>();
|
|
272
292
|
|
|
273
293
|
for (const [index, e] of array.entries()) {
|
|
274
294
|
const key = grouper(e, asUint32(index));
|
|
295
|
+
|
|
275
296
|
const curr = mut_groups.get(key) ?? 0;
|
|
276
297
|
|
|
277
298
|
mut_groups.set(key, asUint32(curr + 1));
|
|
@@ -279,8 +300,10 @@ export function countBy<E, G extends MapSetKeyType>(
|
|
|
279
300
|
|
|
280
301
|
return IMap.create(mut_groups);
|
|
281
302
|
}
|
|
303
|
+
|
|
282
304
|
case 1: {
|
|
283
305
|
const [grouper] = args;
|
|
306
|
+
|
|
284
307
|
return (array) => countBy(array, grouper);
|
|
285
308
|
}
|
|
286
309
|
}
|
|
@@ -295,13 +318,15 @@ export function countBy<E, G extends MapSetKeyType>(
|
|
|
295
318
|
* const words = ['Ada', 'Lovelace'];
|
|
296
319
|
*
|
|
297
320
|
* const totalLength = Arr.foldl(words, (acc, word) => acc + word.length, 0);
|
|
321
|
+
*
|
|
298
322
|
* const concat = Arr.foldl<string | number, string>(
|
|
299
323
|
* (acc, value) => `${acc}-${value}`,
|
|
300
324
|
* 'items',
|
|
301
325
|
* )(words);
|
|
302
326
|
*
|
|
303
|
-
* assert(totalLength === 11);
|
|
304
|
-
*
|
|
327
|
+
* assert.isTrue(totalLength === 11);
|
|
328
|
+
*
|
|
329
|
+
* assert.isTrue(concat === 'items-Ada-Lovelace');
|
|
305
330
|
* ```
|
|
306
331
|
*/
|
|
307
332
|
export function foldl<const Ar extends readonly unknown[], P>(
|
|
@@ -346,13 +371,16 @@ export function foldl<E, P>(
|
|
|
346
371
|
switch (args.length) {
|
|
347
372
|
case 3: {
|
|
348
373
|
const [array, callbackfn, initialValue] = args;
|
|
374
|
+
|
|
349
375
|
return array.reduce(
|
|
350
376
|
(prev, curr, index) => callbackfn(prev, curr, asUint32(index)),
|
|
351
377
|
initialValue,
|
|
352
378
|
);
|
|
353
379
|
}
|
|
380
|
+
|
|
354
381
|
case 2: {
|
|
355
382
|
const [callbackfn, initialValue] = args;
|
|
383
|
+
|
|
356
384
|
return (array) => foldl(array, callbackfn, initialValue);
|
|
357
385
|
}
|
|
358
386
|
}
|
|
@@ -367,13 +395,15 @@ export function foldl<E, P>(
|
|
|
367
395
|
* const numbers = [1, 2, 3];
|
|
368
396
|
*
|
|
369
397
|
* const subtractRight = Arr.foldr(numbers, (acc, value) => acc - value, 0);
|
|
398
|
+
*
|
|
370
399
|
* const joinFromRight = Arr.foldr<number, string>(
|
|
371
400
|
* (acc, value) => `${acc}${value}`,
|
|
372
401
|
* '',
|
|
373
402
|
* )(numbers);
|
|
374
403
|
*
|
|
375
|
-
* assert(subtractRight === -6);
|
|
376
|
-
*
|
|
404
|
+
* assert.isTrue(subtractRight === -6);
|
|
405
|
+
*
|
|
406
|
+
* assert.isTrue(joinFromRight === '321');
|
|
377
407
|
* ```
|
|
378
408
|
*/
|
|
379
409
|
export function foldr<const Ar extends readonly unknown[], P>(
|
|
@@ -418,13 +448,16 @@ export function foldr<E, P>(
|
|
|
418
448
|
switch (args.length) {
|
|
419
449
|
case 3: {
|
|
420
450
|
const [array, callbackfn, initialValue] = args;
|
|
451
|
+
|
|
421
452
|
return array.reduceRight(
|
|
422
453
|
(prev, curr, index) => callbackfn(prev, curr, asUint32(index)),
|
|
423
454
|
initialValue,
|
|
424
455
|
);
|
|
425
456
|
}
|
|
457
|
+
|
|
426
458
|
case 2: {
|
|
427
459
|
const [callbackfn, initialValue] = args;
|
|
460
|
+
|
|
428
461
|
return (array) => foldr(array, callbackfn, initialValue);
|
|
429
462
|
}
|
|
430
463
|
}
|
|
@@ -437,13 +470,16 @@ export function foldr<E, P>(
|
|
|
437
470
|
*
|
|
438
471
|
* ```ts
|
|
439
472
|
* const numbers = [1, 2, 3, 4] as const;
|
|
473
|
+
*
|
|
440
474
|
* const negatives = [3, -2, 5] as const;
|
|
441
475
|
*
|
|
442
476
|
* const total = Arr.sum(numbers);
|
|
477
|
+
*
|
|
443
478
|
* const totalNegatives = Arr.sum(negatives);
|
|
444
479
|
*
|
|
445
|
-
* assert(total === 10);
|
|
446
|
-
*
|
|
480
|
+
* assert.isTrue(total === 10);
|
|
481
|
+
*
|
|
482
|
+
* assert.isTrue(totalNegatives === 6);
|
|
447
483
|
* ```
|
|
448
484
|
*/
|
|
449
485
|
export function sum(array: readonly []): 0;
|
|
@@ -469,50 +505,59 @@ export function sum(array: readonly number[]): number {
|
|
|
469
505
|
* const numbers = [1, 2, 3] as const;
|
|
470
506
|
*
|
|
471
507
|
* const defaultSeparator = Arr.join(numbers);
|
|
508
|
+
*
|
|
472
509
|
* const hyphenSeparated = Arr.join(numbers, '-');
|
|
473
510
|
*
|
|
474
511
|
* assert.deepStrictEqual(defaultSeparator, Result.ok('1,2,3'));
|
|
512
|
+
*
|
|
475
513
|
* assert.deepStrictEqual(hyphenSeparated, Result.ok('1-2-3'));
|
|
476
514
|
* ```
|
|
477
515
|
*/
|
|
478
|
-
export function join
|
|
479
|
-
array: readonly
|
|
516
|
+
export function join(
|
|
517
|
+
array: readonly unknown[],
|
|
480
518
|
separator?: string,
|
|
481
519
|
): Result<string, Error>;
|
|
482
520
|
|
|
483
521
|
export function join(
|
|
484
522
|
separator?: string,
|
|
485
|
-
):
|
|
523
|
+
): (array: readonly unknown[]) => Result<string, Error>;
|
|
486
524
|
|
|
487
|
-
export function join
|
|
525
|
+
export function join(
|
|
488
526
|
...args:
|
|
489
|
-
| readonly [array: readonly
|
|
527
|
+
| readonly [array: readonly unknown[], separator?: string]
|
|
490
528
|
| readonly [separator?: string]
|
|
491
|
-
):
|
|
529
|
+
):
|
|
530
|
+
| Result<string, Error>
|
|
531
|
+
| ((array: readonly unknown[]) => Result<string, Error>) {
|
|
492
532
|
switch (args.length) {
|
|
493
533
|
case 0:
|
|
494
534
|
return (array) => joinImpl(array, undefined);
|
|
495
535
|
|
|
496
536
|
case 1: {
|
|
497
537
|
const [arg] = args;
|
|
538
|
+
|
|
498
539
|
if (isString(arg) || isUndefined(arg)) {
|
|
499
540
|
return (array) => joinImpl(array, arg);
|
|
500
541
|
}
|
|
542
|
+
|
|
501
543
|
return joinImpl(arg, undefined);
|
|
502
544
|
}
|
|
545
|
+
|
|
503
546
|
case 2: {
|
|
504
547
|
const [array, separator] = args;
|
|
548
|
+
|
|
505
549
|
return joinImpl(array, separator);
|
|
506
550
|
}
|
|
507
551
|
}
|
|
508
552
|
}
|
|
509
553
|
|
|
510
|
-
const joinImpl =
|
|
511
|
-
array: readonly
|
|
554
|
+
const joinImpl = (
|
|
555
|
+
array: readonly unknown[],
|
|
512
556
|
separator: string | undefined,
|
|
513
557
|
): Result<string, Error> => {
|
|
514
558
|
try {
|
|
515
559
|
const result = array.join(separator);
|
|
560
|
+
|
|
516
561
|
return Result.ok(result);
|
|
517
562
|
} catch (error) {
|
|
518
563
|
return Result.err(
|