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
|
@@ -7,38 +7,54 @@ describe('Arr element access', () => {
|
|
|
7
7
|
describe(at, () => {
|
|
8
8
|
test('should handle very large positive indices', () => {
|
|
9
9
|
const array = [1, 2, 3];
|
|
10
|
+
|
|
10
11
|
const result = at(array, asUint32(1000));
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
assert.isTrue(Optional.isNone(result));
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
test('should handle very large negative indices', () => {
|
|
16
17
|
const array = [1, 2, 3];
|
|
18
|
+
|
|
17
19
|
const result = at(array, asInt32(-1000));
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
assert.isTrue(Optional.isNone(result));
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
test('should work with valid indices', () => {
|
|
23
25
|
const array = [10, 20, 30];
|
|
26
|
+
|
|
24
27
|
const result = at(array, 1);
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
assert.isTrue(Optional.isSome(result));
|
|
27
30
|
|
|
28
31
|
if (Optional.isSome(result)) {
|
|
29
32
|
expect(result.value).toBe(20);
|
|
30
33
|
}
|
|
31
34
|
});
|
|
35
|
+
|
|
36
|
+
test('should work with curried version', () => {
|
|
37
|
+
const atIndex2 = at(2);
|
|
38
|
+
|
|
39
|
+
const result = atIndex2([10, 20, 30, 40]);
|
|
40
|
+
|
|
41
|
+
assert.isTrue(Optional.isSome(result));
|
|
42
|
+
|
|
43
|
+
if (Optional.isSome(result)) {
|
|
44
|
+
expect(result.value).toBe(30);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
32
47
|
});
|
|
33
48
|
|
|
34
49
|
describe(head, () => {
|
|
35
50
|
test('case 1', () => {
|
|
36
51
|
const xs = [1, 2, 3] as const;
|
|
52
|
+
|
|
37
53
|
const h = head(xs);
|
|
38
54
|
|
|
39
55
|
expectType<typeof h, Some<1>>('=');
|
|
40
56
|
|
|
41
|
-
|
|
57
|
+
assert.isTrue(Optional.isSome(h));
|
|
42
58
|
|
|
43
59
|
if (Optional.isSome(h)) {
|
|
44
60
|
expect(h.value).toBe(1);
|
|
@@ -47,11 +63,12 @@ describe('Arr element access', () => {
|
|
|
47
63
|
|
|
48
64
|
test('case 2', () => {
|
|
49
65
|
const xs: MutableNonEmptyArray<number> = [1, 2, 3];
|
|
66
|
+
|
|
50
67
|
const h = head(xs);
|
|
51
68
|
|
|
52
69
|
expectType<typeof h, Some<number>>('=');
|
|
53
70
|
|
|
54
|
-
|
|
71
|
+
assert.isTrue(Optional.isSome(h));
|
|
55
72
|
|
|
56
73
|
if (Optional.isSome(h)) {
|
|
57
74
|
expect(h.value).toBe(1);
|
|
@@ -60,11 +77,12 @@ describe('Arr element access', () => {
|
|
|
60
77
|
|
|
61
78
|
test('case 3', () => {
|
|
62
79
|
const mut_xs: number[] = [1, 2, 3];
|
|
80
|
+
|
|
63
81
|
const h = head(mut_xs);
|
|
64
82
|
|
|
65
83
|
expectType<typeof h, Optional<number>>('=');
|
|
66
84
|
|
|
67
|
-
|
|
85
|
+
assert.isTrue(Optional.isSome(h));
|
|
68
86
|
|
|
69
87
|
if (Optional.isSome(h)) {
|
|
70
88
|
expect(h.value).toBe(1);
|
|
@@ -78,19 +96,19 @@ describe('Arr element access', () => {
|
|
|
78
96
|
|
|
79
97
|
expectType<typeof h, None>('=');
|
|
80
98
|
|
|
81
|
-
|
|
99
|
+
assert.isTrue(Optional.isNone(h));
|
|
82
100
|
});
|
|
83
101
|
|
|
84
102
|
test('should return none for empty array', () => {
|
|
85
103
|
const result = head([]);
|
|
86
104
|
|
|
87
|
-
|
|
105
|
+
assert.isTrue(Optional.isNone(result));
|
|
88
106
|
});
|
|
89
107
|
|
|
90
108
|
test('should work with single element array', () => {
|
|
91
109
|
const result = head([42]);
|
|
92
110
|
|
|
93
|
-
|
|
111
|
+
assert.isTrue(Optional.isSome(result));
|
|
94
112
|
|
|
95
113
|
if (Optional.isSome(result)) {
|
|
96
114
|
expect(result.value).toBe(42);
|
|
@@ -101,11 +119,12 @@ describe('Arr element access', () => {
|
|
|
101
119
|
describe(last, () => {
|
|
102
120
|
test('case 1', () => {
|
|
103
121
|
const xs = [1, 2, 3] as const;
|
|
122
|
+
|
|
104
123
|
const l = last(xs);
|
|
105
124
|
|
|
106
125
|
expectType<typeof l, Some<3>>('=');
|
|
107
126
|
|
|
108
|
-
|
|
127
|
+
assert.isTrue(Optional.isSome(l));
|
|
109
128
|
|
|
110
129
|
if (Optional.isSome(l)) {
|
|
111
130
|
expect(l.value).toBe(3);
|
|
@@ -114,11 +133,12 @@ describe('Arr element access', () => {
|
|
|
114
133
|
|
|
115
134
|
test('case 2', () => {
|
|
116
135
|
const xs: MutableNonEmptyArray<number> = [1, 2, 3];
|
|
136
|
+
|
|
117
137
|
const l = last(xs);
|
|
118
138
|
|
|
119
139
|
expectType<typeof l, Some<number>>('=');
|
|
120
140
|
|
|
121
|
-
|
|
141
|
+
assert.isTrue(Optional.isSome(l));
|
|
122
142
|
|
|
123
143
|
if (Optional.isSome(l)) {
|
|
124
144
|
expect(l.value).toBe(3);
|
|
@@ -127,11 +147,12 @@ describe('Arr element access', () => {
|
|
|
127
147
|
|
|
128
148
|
test('case 3', () => {
|
|
129
149
|
const mut_xs: number[] = [1, 2, 3];
|
|
150
|
+
|
|
130
151
|
const l = last(mut_xs);
|
|
131
152
|
|
|
132
153
|
expectType<typeof l, Optional<number>>('=');
|
|
133
154
|
|
|
134
|
-
|
|
155
|
+
assert.isTrue(Optional.isSome(l));
|
|
135
156
|
|
|
136
157
|
if (Optional.isSome(l)) {
|
|
137
158
|
expect(l.value).toBe(3);
|
|
@@ -145,19 +166,19 @@ describe('Arr element access', () => {
|
|
|
145
166
|
|
|
146
167
|
expectType<typeof l, None>('=');
|
|
147
168
|
|
|
148
|
-
|
|
169
|
+
assert.isTrue(Optional.isNone(l));
|
|
149
170
|
});
|
|
150
171
|
|
|
151
172
|
test('should return none for empty array', () => {
|
|
152
173
|
const result = last([]);
|
|
153
174
|
|
|
154
|
-
|
|
175
|
+
assert.isTrue(Optional.isNone(result));
|
|
155
176
|
});
|
|
156
177
|
|
|
157
178
|
test('should work with single element array', () => {
|
|
158
179
|
const result = last([42]);
|
|
159
180
|
|
|
160
|
-
|
|
181
|
+
assert.isTrue(Optional.isSome(result));
|
|
161
182
|
|
|
162
183
|
if (Optional.isSome(result)) {
|
|
163
184
|
expect(result.value).toBe(42);
|
|
@@ -5,6 +5,7 @@ import { entries, indices, values } from './array-utils-iterators.mjs';
|
|
|
5
5
|
describe(entries, () => {
|
|
6
6
|
test('should return array of index-value pairs', () => {
|
|
7
7
|
const fruits = ['apple', 'banana', 'cherry'];
|
|
8
|
+
|
|
8
9
|
const es = Array.from(entries(fruits));
|
|
9
10
|
|
|
10
11
|
assert.deepStrictEqual(es, [
|
|
@@ -16,7 +17,9 @@ describe(entries, () => {
|
|
|
16
17
|
|
|
17
18
|
test('should work with tuples', () => {
|
|
18
19
|
const tuple = [10, 20, 30] as const;
|
|
20
|
+
|
|
19
21
|
const es = Array.from(entries(tuple));
|
|
22
|
+
|
|
20
23
|
expectType<typeof es, (readonly [Uint32, 10 | 20 | 30])[]>('=');
|
|
21
24
|
|
|
22
25
|
assert.deepStrictEqual(es, [
|
|
@@ -28,6 +31,7 @@ describe(entries, () => {
|
|
|
28
31
|
|
|
29
32
|
test('should work with empty array', () => {
|
|
30
33
|
const empty: string[] = [];
|
|
34
|
+
|
|
31
35
|
const es = Array.from(entries(empty));
|
|
32
36
|
|
|
33
37
|
assert.deepStrictEqual(es, []);
|
|
@@ -35,7 +39,9 @@ describe(entries, () => {
|
|
|
35
39
|
|
|
36
40
|
test('should preserve mixed types', () => {
|
|
37
41
|
const mixed = [1, 'hello', true] as const;
|
|
42
|
+
|
|
38
43
|
const es = Array.from(entries(mixed));
|
|
44
|
+
|
|
39
45
|
expectType<typeof es, (readonly [Uint32, 1 | 'hello' | true])[]>('=');
|
|
40
46
|
|
|
41
47
|
assert.deepStrictEqual(es, [
|
|
@@ -49,6 +55,7 @@ describe(entries, () => {
|
|
|
49
55
|
describe(values, () => {
|
|
50
56
|
test('should return copy of array values', () => {
|
|
51
57
|
const numbers = [1, 2, 3];
|
|
58
|
+
|
|
52
59
|
const vs = Array.from(values(numbers));
|
|
53
60
|
|
|
54
61
|
assert.deepStrictEqual(vs, [1, 2, 3]);
|
|
@@ -58,7 +65,9 @@ describe(values, () => {
|
|
|
58
65
|
|
|
59
66
|
test('should work with tuples', () => {
|
|
60
67
|
const tuple = ['a', 'b', 'c'] as const;
|
|
68
|
+
|
|
61
69
|
const vs = Array.from(values(tuple));
|
|
70
|
+
|
|
62
71
|
expectType<typeof vs, ('a' | 'b' | 'c')[]>('=');
|
|
63
72
|
|
|
64
73
|
assert.deepStrictEqual(vs, ['a', 'b', 'c']);
|
|
@@ -66,6 +75,7 @@ describe(values, () => {
|
|
|
66
75
|
|
|
67
76
|
test('should work with empty array', () => {
|
|
68
77
|
const empty: number[] = [];
|
|
78
|
+
|
|
69
79
|
const vs = Array.from(values(empty));
|
|
70
80
|
|
|
71
81
|
assert.deepStrictEqual(vs, []);
|
|
@@ -73,7 +83,9 @@ describe(values, () => {
|
|
|
73
83
|
|
|
74
84
|
test('should preserve mixed types', () => {
|
|
75
85
|
const mixed = [1, 'hello', null] as const;
|
|
86
|
+
|
|
76
87
|
const vs = Array.from(values(mixed));
|
|
88
|
+
|
|
77
89
|
expectType<typeof vs, (1 | 'hello' | null)[]>('=');
|
|
78
90
|
|
|
79
91
|
assert.deepStrictEqual(vs, [1, 'hello', null]);
|
|
@@ -83,6 +95,7 @@ describe(values, () => {
|
|
|
83
95
|
describe(indices, () => {
|
|
84
96
|
test('should return array of indices', () => {
|
|
85
97
|
const fruits = ['apple', 'banana', 'cherry'];
|
|
98
|
+
|
|
86
99
|
const ks = Array.from(indices(fruits));
|
|
87
100
|
|
|
88
101
|
assert.deepStrictEqual(ks, [asUint32(0), asUint32(1), asUint32(2)]);
|
|
@@ -90,7 +103,9 @@ describe(indices, () => {
|
|
|
90
103
|
|
|
91
104
|
test('should work with tuples', () => {
|
|
92
105
|
const tuple = ['a', 'b'] as const;
|
|
106
|
+
|
|
93
107
|
const ks = Array.from(indices(tuple));
|
|
108
|
+
|
|
94
109
|
expectType<typeof ks, Uint32[]>('=');
|
|
95
110
|
|
|
96
111
|
assert.deepStrictEqual(ks, [asUint32(0), asUint32(1)]);
|
|
@@ -98,6 +113,7 @@ describe(indices, () => {
|
|
|
98
113
|
|
|
99
114
|
test('should work with empty array', () => {
|
|
100
115
|
const empty: string[] = [];
|
|
116
|
+
|
|
101
117
|
const ks = Array.from(indices(empty));
|
|
102
118
|
|
|
103
119
|
assert.deepStrictEqual(ks, []);
|
|
@@ -105,6 +121,7 @@ describe(indices, () => {
|
|
|
105
121
|
|
|
106
122
|
test('should work with larger arrays', () => {
|
|
107
123
|
const large = Array.from({ length: 5 }, () => 'x');
|
|
124
|
+
|
|
108
125
|
const ks = Array.from(indices(large));
|
|
109
126
|
|
|
110
127
|
assert.deepStrictEqual(ks, [
|
|
@@ -20,10 +20,13 @@ export function set<const Ar extends readonly unknown[], const V = Ar[number]>(
|
|
|
20
20
|
index: ArgArrayIndex<Ar>,
|
|
21
21
|
newValue: V,
|
|
22
22
|
): IsFixedLengthList<Ar> extends true
|
|
23
|
-
?
|
|
23
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
24
|
+
Readonly<{ [K in keyof Ar]: Ar[K] | V }>
|
|
24
25
|
: Ar extends NonEmptyArray<unknown>
|
|
25
|
-
?
|
|
26
|
-
|
|
26
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
27
|
+
NonEmptyArray<Ar[number] | V>
|
|
28
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
29
|
+
readonly (Ar[number] | V)[];
|
|
27
30
|
|
|
28
31
|
// curried version
|
|
29
32
|
export function set<const V>(
|
|
@@ -32,10 +35,13 @@ export function set<const V>(
|
|
|
32
35
|
): <const Ar extends readonly unknown[]>(
|
|
33
36
|
array: Ar,
|
|
34
37
|
) => IsFixedLengthList<Ar> extends true
|
|
35
|
-
?
|
|
38
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
39
|
+
Readonly<{ [K in keyof Ar]: Ar[K] | V }>
|
|
36
40
|
: Ar extends NonEmptyArray<unknown>
|
|
37
|
-
?
|
|
38
|
-
|
|
41
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
42
|
+
NonEmptyArray<Ar[number] | V>
|
|
43
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
44
|
+
readonly (Ar[number] | V)[];
|
|
39
45
|
|
|
40
46
|
export function set<E, const V = E>(
|
|
41
47
|
...args:
|
|
@@ -45,11 +51,14 @@ export function set<E, const V = E>(
|
|
|
45
51
|
switch (args.length) {
|
|
46
52
|
case 3: {
|
|
47
53
|
const [array, index, newValue] = args;
|
|
54
|
+
|
|
48
55
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
49
56
|
return (array as (E | V)[]).with(index, newValue);
|
|
50
57
|
}
|
|
58
|
+
|
|
51
59
|
case 2: {
|
|
52
60
|
const [index, newValue] = args;
|
|
61
|
+
|
|
53
62
|
return (array) => set(array, index, newValue);
|
|
54
63
|
}
|
|
55
64
|
}
|
|
@@ -64,12 +73,14 @@ export function set<E, const V = E>(
|
|
|
64
73
|
* const temperatures: number[] = [20, 21, 22];
|
|
65
74
|
*
|
|
66
75
|
* const increased = Arr.toUpdated(temperatures, 1, (value) => value + 5);
|
|
76
|
+
*
|
|
67
77
|
* const incrementLast = Arr.toUpdated<number>(
|
|
68
78
|
* 2,
|
|
69
79
|
* (value) => value + 1,
|
|
70
80
|
* )(temperatures);
|
|
71
81
|
*
|
|
72
82
|
* assert.deepStrictEqual(increased, [20, 26, 22]);
|
|
83
|
+
*
|
|
73
84
|
* assert.deepStrictEqual(incrementLast, [20, 21, 23]);
|
|
74
85
|
* ```
|
|
75
86
|
*/
|
|
@@ -81,10 +92,13 @@ export function toUpdated<
|
|
|
81
92
|
index: ArgArrayIndex<Ar>,
|
|
82
93
|
updater: (prev: Ar[number]) => V,
|
|
83
94
|
): IsFixedLengthList<Ar> extends true
|
|
84
|
-
?
|
|
95
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
96
|
+
Readonly<{ [K in keyof Ar]: Ar[K] | V }>
|
|
85
97
|
: Ar extends NonEmptyArray<unknown>
|
|
86
|
-
?
|
|
87
|
-
|
|
98
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
99
|
+
NonEmptyArray<Ar[number] | V>
|
|
100
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
101
|
+
readonly (Ar[number] | V)[];
|
|
88
102
|
|
|
89
103
|
// curried version
|
|
90
104
|
export function toUpdated<E, const V = E>(
|
|
@@ -110,11 +124,14 @@ export function toUpdated<E, V = E>(
|
|
|
110
124
|
switch (args.length) {
|
|
111
125
|
case 3: {
|
|
112
126
|
const [array, index, updater] = args;
|
|
127
|
+
|
|
113
128
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, total-functions/no-unsafe-type-assertion
|
|
114
129
|
return (array as (E | V)[]).with(index, updater(array[index]!));
|
|
115
130
|
}
|
|
131
|
+
|
|
116
132
|
case 2: {
|
|
117
133
|
const [index, updater] = args;
|
|
134
|
+
|
|
118
135
|
return (array) => toUpdated(array, index, updater);
|
|
119
136
|
}
|
|
120
137
|
}
|
|
@@ -129,9 +146,11 @@ export function toUpdated<E, V = E>(
|
|
|
129
146
|
* const numbers = [1, 2, 4] as const;
|
|
130
147
|
*
|
|
131
148
|
* const withThree = Arr.toInserted(numbers, 2, 3);
|
|
149
|
+
*
|
|
132
150
|
* const appendFive = Arr.toInserted(3, 5)(numbers);
|
|
133
151
|
*
|
|
134
152
|
* assert.deepStrictEqual(withThree, [1, 2, 3, 4]);
|
|
153
|
+
*
|
|
135
154
|
* assert.deepStrictEqual(appendFive, [1, 2, 4, 5]);
|
|
136
155
|
* ```
|
|
137
156
|
*/
|
|
@@ -143,8 +162,10 @@ export function toInserted<
|
|
|
143
162
|
index: ArgArrayIndexWithNegative<Ar>,
|
|
144
163
|
newValue: V,
|
|
145
164
|
): IsFixedLengthList<Ar> extends true
|
|
146
|
-
?
|
|
147
|
-
|
|
165
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
166
|
+
ArrayOfLength<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>
|
|
167
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
168
|
+
NonEmptyArray<Ar[number] | V>;
|
|
148
169
|
|
|
149
170
|
// curried version
|
|
150
171
|
export function toInserted<const V>(
|
|
@@ -153,8 +174,10 @@ export function toInserted<const V>(
|
|
|
153
174
|
): <const Ar extends readonly unknown[]>(
|
|
154
175
|
array: Ar,
|
|
155
176
|
) => IsFixedLengthList<Ar> extends true
|
|
156
|
-
?
|
|
157
|
-
|
|
177
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
178
|
+
ArrayOfLength<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>
|
|
179
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
180
|
+
NonEmptyArray<Ar[number] | V>;
|
|
158
181
|
|
|
159
182
|
export function toInserted<E, const V = E>(
|
|
160
183
|
...args:
|
|
@@ -168,6 +191,7 @@ export function toInserted<E, const V = E>(
|
|
|
168
191
|
switch (args.length) {
|
|
169
192
|
case 3: {
|
|
170
193
|
const [array, index, newValue] = args;
|
|
194
|
+
|
|
171
195
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
172
196
|
return (array as readonly (E | V)[]).toSpliced(
|
|
173
197
|
index,
|
|
@@ -175,8 +199,10 @@ export function toInserted<E, const V = E>(
|
|
|
175
199
|
newValue,
|
|
176
200
|
) as unknown as NonEmptyArray<E | V>;
|
|
177
201
|
}
|
|
202
|
+
|
|
178
203
|
case 2: {
|
|
179
204
|
const [index, newValue] = args;
|
|
205
|
+
|
|
180
206
|
return (array) => toInserted(array, index, newValue);
|
|
181
207
|
}
|
|
182
208
|
}
|
|
@@ -193,9 +219,11 @@ type CastToNumber<T> = T extends number ? T : never;
|
|
|
193
219
|
* const letters = ['a', 'b', 'c', 'd'] as const;
|
|
194
220
|
*
|
|
195
221
|
* const withoutSecond = Arr.toRemoved(letters, 1);
|
|
222
|
+
*
|
|
196
223
|
* const withoutFirstCurried = Arr.toRemoved(0)(letters);
|
|
197
224
|
*
|
|
198
225
|
* assert.deepStrictEqual(withoutSecond, ['a', 'c', 'd']);
|
|
226
|
+
*
|
|
199
227
|
* assert.deepStrictEqual(withoutFirstCurried, ['b', 'c', 'd']);
|
|
200
228
|
* ```
|
|
201
229
|
*/
|
|
@@ -216,10 +244,13 @@ export function toRemoved<E>(
|
|
|
216
244
|
switch (args.length) {
|
|
217
245
|
case 2: {
|
|
218
246
|
const [array, index] = args;
|
|
247
|
+
|
|
219
248
|
return array.toSpliced(index, 1);
|
|
220
249
|
}
|
|
250
|
+
|
|
221
251
|
case 1: {
|
|
222
252
|
const [index] = args;
|
|
253
|
+
|
|
223
254
|
return (array) => toRemoved(array, index);
|
|
224
255
|
}
|
|
225
256
|
}
|
|
@@ -234,9 +265,11 @@ export function toRemoved<E>(
|
|
|
234
265
|
* const base = [1, 2] as const;
|
|
235
266
|
*
|
|
236
267
|
* const appended = Arr.toPushed(base, 3);
|
|
268
|
+
*
|
|
237
269
|
* const appendedCurried = Arr.toPushed(4)(base);
|
|
238
270
|
*
|
|
239
271
|
* assert.deepStrictEqual(appended, [1, 2, 3]);
|
|
272
|
+
*
|
|
240
273
|
* assert.deepStrictEqual(appendedCurried, [1, 2, 4]);
|
|
241
274
|
* ```
|
|
242
275
|
*/
|
|
@@ -255,14 +288,17 @@ export function toPushed<const Ar extends readonly unknown[], const V>(
|
|
|
255
288
|
switch (args.length) {
|
|
256
289
|
case 2: {
|
|
257
290
|
const [array, newValue] = args;
|
|
291
|
+
|
|
258
292
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
259
293
|
return array.toSpliced(array.length, 0, newValue) as unknown as readonly [
|
|
260
294
|
...Ar,
|
|
261
295
|
V,
|
|
262
296
|
];
|
|
263
297
|
}
|
|
298
|
+
|
|
264
299
|
case 1: {
|
|
265
300
|
const [newValue] = args;
|
|
301
|
+
|
|
266
302
|
return (array) => toPushed(array, newValue);
|
|
267
303
|
}
|
|
268
304
|
}
|
|
@@ -277,9 +313,11 @@ export function toPushed<const Ar extends readonly unknown[], const V>(
|
|
|
277
313
|
* const base = [2, 3] as const;
|
|
278
314
|
*
|
|
279
315
|
* const prefixed = Arr.toUnshifted(base, 1);
|
|
316
|
+
*
|
|
280
317
|
* const prefixedCurried = Arr.toUnshifted(0)(base);
|
|
281
318
|
*
|
|
282
319
|
* assert.deepStrictEqual(prefixed, [1, 2, 3]);
|
|
320
|
+
*
|
|
283
321
|
* assert.deepStrictEqual(prefixedCurried, [0, 2, 3]);
|
|
284
322
|
* ```
|
|
285
323
|
*/
|
|
@@ -298,11 +336,14 @@ export function toUnshifted<Ar extends readonly unknown[], const V>(
|
|
|
298
336
|
switch (args.length) {
|
|
299
337
|
case 2: {
|
|
300
338
|
const [array, newValue] = args;
|
|
339
|
+
|
|
301
340
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
302
341
|
return array.toSpliced(0, 0, newValue) as unknown as readonly [V, ...Ar];
|
|
303
342
|
}
|
|
343
|
+
|
|
304
344
|
case 1: {
|
|
305
345
|
const [newValue] = args;
|
|
346
|
+
|
|
306
347
|
return (array) => toUnshifted(array, newValue);
|
|
307
348
|
}
|
|
308
349
|
}
|
|
@@ -317,9 +358,11 @@ export function toUnshifted<Ar extends readonly unknown[], const V>(
|
|
|
317
358
|
* const base = [1, 2, 3];
|
|
318
359
|
*
|
|
319
360
|
* const filled = Arr.toFilled(base, 0);
|
|
361
|
+
*
|
|
320
362
|
* const filledCurried = Arr.toFilled('x')(base);
|
|
321
363
|
*
|
|
322
364
|
* assert.deepStrictEqual(filled, [0, 0, 0]);
|
|
365
|
+
*
|
|
323
366
|
* assert.deepStrictEqual(filledCurried, ['x', 'x', 'x']);
|
|
324
367
|
* ```
|
|
325
368
|
*/
|
|
@@ -349,10 +392,13 @@ export function toFilled<E>(
|
|
|
349
392
|
switch (args.length) {
|
|
350
393
|
case 2: {
|
|
351
394
|
const [array, value] = args;
|
|
395
|
+
|
|
352
396
|
return create(asPositiveUint32(array.length), value);
|
|
353
397
|
}
|
|
398
|
+
|
|
354
399
|
case 1: {
|
|
355
400
|
const [value] = args;
|
|
401
|
+
|
|
356
402
|
return (array) => toFilled(array, value);
|
|
357
403
|
}
|
|
358
404
|
}
|
|
@@ -367,9 +413,11 @@ export function toFilled<E>(
|
|
|
367
413
|
* const base = [0, 1, 2, 3, 4];
|
|
368
414
|
*
|
|
369
415
|
* const filledMiddle = Arr.toRangeFilled(base, 9, [1, 4]);
|
|
416
|
+
*
|
|
370
417
|
* const filledPrefix = Arr.toRangeFilled(8, [0, 2])(base);
|
|
371
418
|
*
|
|
372
419
|
* assert.deepStrictEqual(filledMiddle, [0, 9, 9, 9, 4]);
|
|
420
|
+
*
|
|
373
421
|
* assert.deepStrictEqual(filledPrefix, [8, 8, 2, 3, 4]);
|
|
374
422
|
* ```
|
|
375
423
|
*/
|
|
@@ -381,10 +429,13 @@ export function toRangeFilled<const Ar extends readonly unknown[], const V>(
|
|
|
381
429
|
end: ArgArrayIndexWithNegative<Ar>,
|
|
382
430
|
],
|
|
383
431
|
): IsFixedLengthList<Ar> extends true
|
|
384
|
-
?
|
|
432
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
433
|
+
ArrayOfLength<Ar['length'], V | Ar[number]>
|
|
385
434
|
: Ar extends NonEmptyArray<unknown>
|
|
386
|
-
?
|
|
387
|
-
|
|
435
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
436
|
+
NonEmptyArray<V | Ar[number]>
|
|
437
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
438
|
+
readonly (V | Ar[number])[];
|
|
388
439
|
|
|
389
440
|
// curried version
|
|
390
441
|
export function toRangeFilled<const V>(
|
|
@@ -396,10 +447,13 @@ export function toRangeFilled<const V>(
|
|
|
396
447
|
): <const Ar extends readonly unknown[]>(
|
|
397
448
|
array: Ar,
|
|
398
449
|
) => IsFixedLengthList<Ar> extends true
|
|
399
|
-
?
|
|
450
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
451
|
+
ArrayOfLength<Ar['length'], V | Ar[number]>
|
|
400
452
|
: Ar extends NonEmptyArray<unknown>
|
|
401
|
-
?
|
|
402
|
-
|
|
453
|
+
? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
454
|
+
NonEmptyArray<V | Ar[number]>
|
|
455
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
456
|
+
readonly (V | Ar[number])[];
|
|
403
457
|
|
|
404
458
|
export function toRangeFilled<E, const V>(
|
|
405
459
|
...args:
|
|
@@ -422,12 +476,17 @@ export function toRangeFilled<E, const V>(
|
|
|
422
476
|
switch (args.length) {
|
|
423
477
|
case 3: {
|
|
424
478
|
const [array, value, [start, end]] = args;
|
|
479
|
+
|
|
425
480
|
const mut_cp: (E | V)[] = castMutable(copy(array));
|
|
481
|
+
|
|
426
482
|
mut_cp.fill(value, start, end);
|
|
483
|
+
|
|
427
484
|
return mut_cp;
|
|
428
485
|
}
|
|
486
|
+
|
|
429
487
|
case 2: {
|
|
430
488
|
const [value, fillRange] = args;
|
|
489
|
+
|
|
431
490
|
return (array) => toRangeFilled(array, value, fillRange);
|
|
432
491
|
}
|
|
433
492
|
}
|