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
|
@@ -5,23 +5,31 @@ import { pipe } from './pipe.mjs';
|
|
|
5
5
|
describe('Optional test', () => {
|
|
6
6
|
describe('isOptional', () => {
|
|
7
7
|
test('should return true for Some values', () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
assert.isTrue(Optional.isOptional(Optional.some(42)));
|
|
9
|
+
|
|
10
|
+
assert.isTrue(Optional.isOptional(Optional.some('hello')));
|
|
11
|
+
|
|
12
|
+
assert.isTrue(Optional.isOptional(Optional.some(null)));
|
|
13
|
+
|
|
14
|
+
assert.isTrue(Optional.isOptional(Optional.some(undefined)));
|
|
12
15
|
});
|
|
13
16
|
|
|
14
17
|
test('should return true for None value', () => {
|
|
15
|
-
|
|
18
|
+
assert.isTrue(Optional.isOptional(Optional.none));
|
|
16
19
|
});
|
|
17
20
|
|
|
18
21
|
test('should return false for non-Optional values', () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
assert.isFalse(Optional.isOptional(42));
|
|
23
|
+
|
|
24
|
+
assert.isFalse(Optional.isOptional('hello'));
|
|
25
|
+
|
|
26
|
+
assert.isFalse(Optional.isOptional(null));
|
|
27
|
+
|
|
28
|
+
assert.isFalse(Optional.isOptional(undefined));
|
|
29
|
+
|
|
30
|
+
assert.isFalse(Optional.isOptional({}));
|
|
31
|
+
|
|
32
|
+
assert.isFalse(Optional.isOptional({ type: 'fake', value: 42 }));
|
|
25
33
|
});
|
|
26
34
|
});
|
|
27
35
|
|
|
@@ -29,17 +37,19 @@ describe('Optional test', () => {
|
|
|
29
37
|
test('should create a Some variant with the provided value', () => {
|
|
30
38
|
const someNumber = Optional.some(42);
|
|
31
39
|
|
|
32
|
-
|
|
40
|
+
assert.isTrue(Optional.isSome(someNumber));
|
|
41
|
+
|
|
33
42
|
expect(Optional.unwrap(someNumber)).toBe(42);
|
|
34
43
|
|
|
35
44
|
const someString = Optional.some('hello');
|
|
36
45
|
|
|
37
|
-
|
|
46
|
+
assert.isTrue(Optional.isSome(someString));
|
|
47
|
+
|
|
38
48
|
expect(Optional.unwrap(someString)).toBe('hello');
|
|
39
49
|
|
|
40
50
|
const someObject = Optional.some({ name: 'Alice', age: 30 });
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
assert.isTrue(Optional.isSome(someObject));
|
|
43
53
|
|
|
44
54
|
assert.deepStrictEqual(Optional.unwrap(someObject), {
|
|
45
55
|
name: 'Alice',
|
|
@@ -56,8 +66,10 @@ describe('Optional test', () => {
|
|
|
56
66
|
|
|
57
67
|
describe('none', () => {
|
|
58
68
|
test('should be a singleton None value', () => {
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
assert.isTrue(Optional.isNone(Optional.none));
|
|
70
|
+
|
|
71
|
+
assert.isFalse(Optional.isSome(Optional.none));
|
|
72
|
+
|
|
61
73
|
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
62
74
|
expect(Optional.unwrapOr(Optional.none, undefined)).toBeUndefined();
|
|
63
75
|
});
|
|
@@ -71,15 +83,17 @@ describe('Optional test', () => {
|
|
|
71
83
|
test('should correctly identify Some values', () => {
|
|
72
84
|
const some = Optional.some(42);
|
|
73
85
|
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
assert.isTrue(Optional.isSome(some));
|
|
87
|
+
|
|
88
|
+
assert.isFalse(Optional.isNone(some));
|
|
76
89
|
});
|
|
77
90
|
|
|
78
91
|
test('should correctly identify None values', () => {
|
|
79
92
|
const none = Optional.none;
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
assert.isFalse(Optional.isSome(none));
|
|
95
|
+
|
|
96
|
+
assert.isTrue(Optional.isNone(none));
|
|
83
97
|
});
|
|
84
98
|
|
|
85
99
|
test('should act as type guards', () => {
|
|
@@ -98,9 +112,10 @@ describe('Optional test', () => {
|
|
|
98
112
|
describe('map', () => {
|
|
99
113
|
test('should map over Some values', () => {
|
|
100
114
|
const some = Optional.some(5);
|
|
115
|
+
|
|
101
116
|
const mapped = Optional.map(some, (x) => x * 2);
|
|
102
117
|
|
|
103
|
-
|
|
118
|
+
assert.isTrue(Optional.isSome(mapped));
|
|
104
119
|
|
|
105
120
|
if (Optional.isSome(mapped)) {
|
|
106
121
|
expect(Optional.unwrap(mapped)).toBe(10);
|
|
@@ -109,9 +124,10 @@ describe('Optional test', () => {
|
|
|
109
124
|
|
|
110
125
|
test('should return None for None values', () => {
|
|
111
126
|
const none = Optional.none;
|
|
127
|
+
|
|
112
128
|
const mapped = Optional.map(none, (x: never) => x * 2);
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
assert.isTrue(Optional.isNone(mapped));
|
|
115
131
|
});
|
|
116
132
|
|
|
117
133
|
test('should support chaining', () => {
|
|
@@ -137,27 +153,30 @@ describe('Optional test', () => {
|
|
|
137
153
|
const doubler = Optional.map((x: number) => x * 2);
|
|
138
154
|
|
|
139
155
|
const some = Optional.some(5);
|
|
156
|
+
|
|
140
157
|
const mapped = doubler(some);
|
|
141
158
|
|
|
142
|
-
|
|
159
|
+
assert.isTrue(Optional.isSome(mapped));
|
|
143
160
|
|
|
144
161
|
if (Optional.isSome(mapped)) {
|
|
145
162
|
expect(Optional.unwrap(mapped)).toBe(10);
|
|
146
163
|
}
|
|
147
164
|
|
|
148
165
|
const none = Optional.none;
|
|
166
|
+
|
|
149
167
|
const mappedNone = doubler(none);
|
|
150
168
|
|
|
151
|
-
|
|
169
|
+
assert.isTrue(Optional.isNone(mappedNone));
|
|
152
170
|
});
|
|
153
171
|
|
|
154
172
|
test('should work with pipe when curried', () => {
|
|
155
173
|
const doubler = Optional.map((x: number) => x * 2);
|
|
174
|
+
|
|
156
175
|
const toStringFn = Optional.map((x: number) => x.toString());
|
|
157
176
|
|
|
158
177
|
const result = pipe(Optional.some(5)).map(doubler).map(toStringFn).value;
|
|
159
178
|
|
|
160
|
-
|
|
179
|
+
assert.isTrue(Optional.isSome(result));
|
|
161
180
|
|
|
162
181
|
if (Optional.isSome(result)) {
|
|
163
182
|
expect(Optional.unwrap(result)).toBe('10');
|
|
@@ -168,7 +187,9 @@ describe('Optional test', () => {
|
|
|
168
187
|
describe('unwrap', () => {
|
|
169
188
|
test('should return the value for Some', () => {
|
|
170
189
|
expect(Optional.unwrap(Optional.some(42))).toBe(42);
|
|
190
|
+
|
|
171
191
|
expect(Optional.unwrap(Optional.some('hello'))).toBe('hello');
|
|
192
|
+
|
|
172
193
|
expect(Optional.unwrap(Optional.some(null))).toBeNull();
|
|
173
194
|
});
|
|
174
195
|
|
|
@@ -192,6 +213,7 @@ describe('Optional test', () => {
|
|
|
192
213
|
describe('unwrapThrow', () => {
|
|
193
214
|
test('should return the value for Some', () => {
|
|
194
215
|
expect(Optional.unwrapThrow(Optional.some(42))).toBe(42);
|
|
216
|
+
|
|
195
217
|
expect(Optional.unwrapThrow(Optional.some('hello'))).toBe('hello');
|
|
196
218
|
});
|
|
197
219
|
|
|
@@ -211,6 +233,7 @@ describe('Optional test', () => {
|
|
|
211
233
|
describe('unwrapOr', () => {
|
|
212
234
|
test('should return the value for Some', () => {
|
|
213
235
|
expect(Optional.unwrapOr(Optional.some(42), 0)).toBe(42);
|
|
236
|
+
|
|
214
237
|
expect(Optional.unwrapOr(Optional.some('hello'), 'default')).toBe(
|
|
215
238
|
'hello',
|
|
216
239
|
);
|
|
@@ -218,6 +241,7 @@ describe('Optional test', () => {
|
|
|
218
241
|
|
|
219
242
|
test('should return the default value for None', () => {
|
|
220
243
|
expect(Optional.unwrapOr(Optional.none, 0)).toBe(0);
|
|
244
|
+
|
|
221
245
|
expect(Optional.unwrapOr(Optional.none, 'default')).toBe('default');
|
|
222
246
|
});
|
|
223
247
|
|
|
@@ -239,11 +263,13 @@ describe('Optional test', () => {
|
|
|
239
263
|
const unwrapWithDefault = Optional.unwrapOr(42);
|
|
240
264
|
|
|
241
265
|
const someValue = Optional.some(100);
|
|
266
|
+
|
|
242
267
|
const result = unwrapWithDefault(someValue);
|
|
243
268
|
|
|
244
269
|
expect(result).toBe(100);
|
|
245
270
|
|
|
246
271
|
const noneValue = Optional.none;
|
|
272
|
+
|
|
247
273
|
const defaultResult = unwrapWithDefault(noneValue);
|
|
248
274
|
|
|
249
275
|
expect(defaultResult).toBe(42);
|
|
@@ -281,9 +307,11 @@ describe('Optional test', () => {
|
|
|
281
307
|
const expectValidId = Optional.expectToBe<string>('ID is required');
|
|
282
308
|
|
|
283
309
|
const id1 = Optional.some('user-123');
|
|
310
|
+
|
|
284
311
|
const id2 = Optional.none;
|
|
285
312
|
|
|
286
313
|
expect(expectValidId(id1)).toBe('user-123');
|
|
314
|
+
|
|
287
315
|
expect(() => expectValidId(id2)).toThrow('ID is required');
|
|
288
316
|
});
|
|
289
317
|
|
|
@@ -291,6 +319,7 @@ describe('Optional test', () => {
|
|
|
291
319
|
const getValue = Optional.expectToBe('Value must exist');
|
|
292
320
|
|
|
293
321
|
const someValue = Optional.some('important data');
|
|
322
|
+
|
|
294
323
|
const result = getValue(someValue);
|
|
295
324
|
|
|
296
325
|
expect(result).toBe('important data');
|
|
@@ -318,10 +347,13 @@ describe('Optional test', () => {
|
|
|
318
347
|
describe('type utilities', () => {
|
|
319
348
|
test('should correctly unwrap types', () => {
|
|
320
349
|
type SomeNumber = Some<number>;
|
|
350
|
+
|
|
321
351
|
type UnwrappedNumber = Optional.Unwrap<SomeNumber>;
|
|
352
|
+
|
|
322
353
|
expectType<UnwrappedNumber, number>('=');
|
|
323
354
|
|
|
324
355
|
type UnwrappedNone = Optional.Unwrap<None>;
|
|
356
|
+
|
|
325
357
|
expectType<UnwrappedNone, never>('=');
|
|
326
358
|
});
|
|
327
359
|
|
|
@@ -329,9 +361,11 @@ describe('Optional test', () => {
|
|
|
329
361
|
type MaybeNumber = Optional<number>;
|
|
330
362
|
|
|
331
363
|
type OnlySome = Optional.NarrowToSome<MaybeNumber>;
|
|
364
|
+
|
|
332
365
|
expectType<OnlySome, Some<number>>('=');
|
|
333
366
|
|
|
334
367
|
type OnlyNone = Optional.NarrowToNone<MaybeNumber>;
|
|
368
|
+
|
|
335
369
|
expectType<OnlyNone, None>('=');
|
|
336
370
|
});
|
|
337
371
|
});
|
|
@@ -340,17 +374,19 @@ describe('Optional test', () => {
|
|
|
340
374
|
test('should chain operations that return Optional', () => {
|
|
341
375
|
const parseNumber = (s: string): Optional<number> => {
|
|
342
376
|
const n = Number(s);
|
|
377
|
+
|
|
343
378
|
return Number.isNaN(n) ? Optional.none : Optional.some(n);
|
|
344
379
|
};
|
|
345
380
|
|
|
346
381
|
const result = Optional.flatMap(Optional.some('42'), parseNumber);
|
|
382
|
+
|
|
347
383
|
if (Optional.isSome(result)) {
|
|
348
384
|
expect(Optional.unwrap(result)).toBe(42);
|
|
349
385
|
}
|
|
350
386
|
|
|
351
387
|
const invalid = Optional.flatMap(Optional.some('abc'), parseNumber);
|
|
352
388
|
|
|
353
|
-
|
|
389
|
+
assert.isTrue(Optional.isNone(invalid));
|
|
354
390
|
});
|
|
355
391
|
|
|
356
392
|
test('should return None if input is None', () => {
|
|
@@ -358,12 +394,13 @@ describe('Optional test', () => {
|
|
|
358
394
|
Optional.some(42),
|
|
359
395
|
);
|
|
360
396
|
|
|
361
|
-
|
|
397
|
+
assert.isTrue(Optional.isNone(result));
|
|
362
398
|
});
|
|
363
399
|
|
|
364
400
|
test('should support chaining multiple flatMaps', () => {
|
|
365
401
|
const parseNumber = (s: string): Optional<number> => {
|
|
366
402
|
const n = Number(s);
|
|
403
|
+
|
|
367
404
|
return Number.isNaN(n) ? Optional.none : Optional.some(n);
|
|
368
405
|
};
|
|
369
406
|
|
|
@@ -376,7 +413,9 @@ describe('Optional test', () => {
|
|
|
376
413
|
Optional.some(n / divisor);
|
|
377
414
|
|
|
378
415
|
const intermediate = Optional.flatMap(Optional.some('100'), parseNumber);
|
|
416
|
+
|
|
379
417
|
const result = Optional.flatMap(intermediate, divideBy(2));
|
|
418
|
+
|
|
380
419
|
if (Optional.isSome(result)) {
|
|
381
420
|
expect(Optional.unwrap(result)).toBe(50);
|
|
382
421
|
}
|
|
@@ -385,6 +424,7 @@ describe('Optional test', () => {
|
|
|
385
424
|
test('should support curried form', () => {
|
|
386
425
|
const parseNumber = (s: string): Optional<number> => {
|
|
387
426
|
const n = Number(s);
|
|
427
|
+
|
|
388
428
|
return Number.isNaN(n) ? Optional.none : Optional.some(n);
|
|
389
429
|
};
|
|
390
430
|
|
|
@@ -392,7 +432,7 @@ describe('Optional test', () => {
|
|
|
392
432
|
|
|
393
433
|
const result = parser(Optional.some('42'));
|
|
394
434
|
|
|
395
|
-
|
|
435
|
+
assert.isTrue(Optional.isSome(result));
|
|
396
436
|
|
|
397
437
|
if (Optional.isSome(result)) {
|
|
398
438
|
expect(Optional.unwrap(result)).toBe(42);
|
|
@@ -400,16 +440,17 @@ describe('Optional test', () => {
|
|
|
400
440
|
|
|
401
441
|
const invalid = parser(Optional.some('abc'));
|
|
402
442
|
|
|
403
|
-
|
|
443
|
+
assert.isTrue(Optional.isNone(invalid));
|
|
404
444
|
|
|
405
445
|
const noneResult = parser(Optional.none);
|
|
406
446
|
|
|
407
|
-
|
|
447
|
+
assert.isTrue(Optional.isNone(noneResult));
|
|
408
448
|
});
|
|
409
449
|
|
|
410
450
|
test('should work with pipe when curried', () => {
|
|
411
451
|
const parseNumber = (s: string): Optional<number> => {
|
|
412
452
|
const n = Number(s);
|
|
453
|
+
|
|
413
454
|
return Number.isNaN(n) ? Optional.none : Optional.some(n);
|
|
414
455
|
};
|
|
415
456
|
|
|
@@ -417,11 +458,12 @@ describe('Optional test', () => {
|
|
|
417
458
|
n > 0 ? Optional.some(n * 2) : Optional.none;
|
|
418
459
|
|
|
419
460
|
const parser = Optional.flatMap(parseNumber);
|
|
461
|
+
|
|
420
462
|
const doubler = Optional.flatMap(doubleIfPositive);
|
|
421
463
|
|
|
422
464
|
const result = pipe(Optional.some('42')).map(parser).map(doubler).value;
|
|
423
465
|
|
|
424
|
-
|
|
466
|
+
assert.isTrue(Optional.isSome(result));
|
|
425
467
|
|
|
426
468
|
if (Optional.isSome(result)) {
|
|
427
469
|
expect(Optional.unwrap(result)).toBe(84);
|
|
@@ -432,7 +474,9 @@ describe('Optional test', () => {
|
|
|
432
474
|
describe('filter', () => {
|
|
433
475
|
test('should keep Some values that match predicate', () => {
|
|
434
476
|
const someEven = Optional.some(4);
|
|
477
|
+
|
|
435
478
|
const filtered = Optional.filter(someEven, (x) => x % 2 === 0);
|
|
479
|
+
|
|
436
480
|
if (Optional.isSome(filtered)) {
|
|
437
481
|
expect(Optional.unwrap(filtered)).toBe(4);
|
|
438
482
|
}
|
|
@@ -440,48 +484,52 @@ describe('Optional test', () => {
|
|
|
440
484
|
|
|
441
485
|
test('should return None for Some values that do not match predicate', () => {
|
|
442
486
|
const someOdd = Optional.some(5);
|
|
487
|
+
|
|
443
488
|
const filtered = Optional.filter(someOdd, (x) => x % 2 === 0);
|
|
444
489
|
|
|
445
|
-
|
|
490
|
+
assert.isTrue(Optional.isNone(filtered));
|
|
446
491
|
});
|
|
447
492
|
|
|
448
493
|
test('should return None if input is None', () => {
|
|
449
494
|
const filtered = Optional.filter(Optional.none, (_: never) => true);
|
|
450
495
|
|
|
451
|
-
|
|
496
|
+
assert.isTrue(Optional.isNone(filtered));
|
|
452
497
|
});
|
|
453
498
|
|
|
454
499
|
test('should support curried form', () => {
|
|
455
500
|
const evenFilter = Optional.filter((x: number) => x % 2 === 0);
|
|
456
501
|
|
|
457
502
|
const someEven = Optional.some(4);
|
|
503
|
+
|
|
458
504
|
const filtered = evenFilter(someEven);
|
|
459
505
|
|
|
460
|
-
|
|
506
|
+
assert.isTrue(Optional.isSome(filtered));
|
|
461
507
|
|
|
462
508
|
if (Optional.isSome(filtered)) {
|
|
463
509
|
expect(Optional.unwrap(filtered)).toBe(4);
|
|
464
510
|
}
|
|
465
511
|
|
|
466
512
|
const someOdd = Optional.some(5);
|
|
513
|
+
|
|
467
514
|
const filteredOdd = evenFilter(someOdd);
|
|
468
515
|
|
|
469
|
-
|
|
516
|
+
assert.isTrue(Optional.isNone(filteredOdd));
|
|
470
517
|
|
|
471
518
|
const noneResult = evenFilter(Optional.none);
|
|
472
519
|
|
|
473
|
-
|
|
520
|
+
assert.isTrue(Optional.isNone(noneResult));
|
|
474
521
|
});
|
|
475
522
|
|
|
476
523
|
test('should work with pipe when curried', () => {
|
|
477
524
|
const evenFilter = Optional.filter((x: number) => x % 2 === 0);
|
|
525
|
+
|
|
478
526
|
const positiveFilter = Optional.filter((x: number) => x > 0);
|
|
479
527
|
|
|
480
528
|
const result = pipe(Optional.some(4))
|
|
481
529
|
.map(evenFilter)
|
|
482
530
|
.map(positiveFilter).value;
|
|
483
531
|
|
|
484
|
-
|
|
532
|
+
assert.isTrue(Optional.isSome(result));
|
|
485
533
|
|
|
486
534
|
if (Optional.isSome(result)) {
|
|
487
535
|
expect(Optional.unwrap(result)).toBe(4);
|
|
@@ -489,15 +537,18 @@ describe('Optional test', () => {
|
|
|
489
537
|
|
|
490
538
|
const filtered = pipe(Optional.some(3)).map(evenFilter).value;
|
|
491
539
|
|
|
492
|
-
|
|
540
|
+
assert.isTrue(Optional.isNone(filtered));
|
|
493
541
|
});
|
|
494
542
|
});
|
|
495
543
|
|
|
496
544
|
describe('orElse', () => {
|
|
497
545
|
test('should return the first Optional if it is Some', () => {
|
|
498
546
|
const primary = Optional.some(42);
|
|
547
|
+
|
|
499
548
|
const fallback = Optional.some(100);
|
|
549
|
+
|
|
500
550
|
const result = Optional.orElse(primary, fallback);
|
|
551
|
+
|
|
501
552
|
if (Optional.isSome(result)) {
|
|
502
553
|
expect(Optional.unwrap(result)).toBe(42);
|
|
503
554
|
}
|
|
@@ -505,8 +556,11 @@ describe('Optional test', () => {
|
|
|
505
556
|
|
|
506
557
|
test('should return the alternative if the first is None', () => {
|
|
507
558
|
const primary = Optional.none;
|
|
559
|
+
|
|
508
560
|
const fallback = Optional.some('default');
|
|
561
|
+
|
|
509
562
|
const result = Optional.orElse(primary, fallback);
|
|
563
|
+
|
|
510
564
|
if (Optional.isSome(result)) {
|
|
511
565
|
expect(Optional.unwrap(result)).toBe('default');
|
|
512
566
|
}
|
|
@@ -515,25 +569,27 @@ describe('Optional test', () => {
|
|
|
515
569
|
test('should return None if both are None', () => {
|
|
516
570
|
const result = Optional.orElse(Optional.none, Optional.none);
|
|
517
571
|
|
|
518
|
-
|
|
572
|
+
assert.isTrue(Optional.isNone(result));
|
|
519
573
|
});
|
|
520
574
|
|
|
521
575
|
test('should support curried form', () => {
|
|
522
576
|
const fallbackTo = Optional.orElse(Optional.some('fallback'));
|
|
523
577
|
|
|
524
578
|
const someValue = Optional.some('primary');
|
|
579
|
+
|
|
525
580
|
const result = fallbackTo(someValue);
|
|
526
581
|
|
|
527
|
-
|
|
582
|
+
assert.isTrue(Optional.isSome(result));
|
|
528
583
|
|
|
529
584
|
if (Optional.isSome(result)) {
|
|
530
585
|
expect(Optional.unwrap(result)).toBe('primary');
|
|
531
586
|
}
|
|
532
587
|
|
|
533
588
|
const noneValue = Optional.none;
|
|
589
|
+
|
|
534
590
|
const fallbackResult = fallbackTo(noneValue);
|
|
535
591
|
|
|
536
|
-
|
|
592
|
+
assert.isTrue(Optional.isSome(fallbackResult));
|
|
537
593
|
|
|
538
594
|
if (Optional.isSome(fallbackResult)) {
|
|
539
595
|
expect(Optional.unwrap(fallbackResult)).toBe('fallback');
|
|
@@ -545,7 +601,7 @@ describe('Optional test', () => {
|
|
|
545
601
|
|
|
546
602
|
const someResult = pipe(Optional.some('original')).map(fallbackTo).value;
|
|
547
603
|
|
|
548
|
-
|
|
604
|
+
assert.isTrue(Optional.isSome(someResult));
|
|
549
605
|
|
|
550
606
|
if (Optional.isSome(someResult)) {
|
|
551
607
|
expect(Optional.unwrap(someResult)).toBe('original');
|
|
@@ -553,7 +609,7 @@ describe('Optional test', () => {
|
|
|
553
609
|
|
|
554
610
|
const noneResult = pipe(Optional.none).map(fallbackTo).value;
|
|
555
611
|
|
|
556
|
-
|
|
612
|
+
assert.isTrue(Optional.isSome(noneResult));
|
|
557
613
|
|
|
558
614
|
if (Optional.isSome(noneResult)) {
|
|
559
615
|
expect(Optional.unwrap(noneResult)).toBe('backup');
|
|
@@ -564,8 +620,11 @@ describe('Optional test', () => {
|
|
|
564
620
|
describe('zip', () => {
|
|
565
621
|
test('should combine two Some values into a tuple', () => {
|
|
566
622
|
const a = Optional.some(1);
|
|
623
|
+
|
|
567
624
|
const b = Optional.some('hello');
|
|
625
|
+
|
|
568
626
|
const zipped = Optional.zip(a, b);
|
|
627
|
+
|
|
569
628
|
if (Optional.isSome(zipped)) {
|
|
570
629
|
assert.deepStrictEqual(Optional.unwrap(zipped), [1, 'hello']);
|
|
571
630
|
}
|
|
@@ -573,53 +632,61 @@ describe('Optional test', () => {
|
|
|
573
632
|
|
|
574
633
|
test('should return None if first is None', () => {
|
|
575
634
|
const a = Optional.none;
|
|
635
|
+
|
|
576
636
|
const b = Optional.some('hello');
|
|
637
|
+
|
|
577
638
|
const zipped = Optional.zip(a, b);
|
|
578
639
|
|
|
579
|
-
|
|
640
|
+
assert.isTrue(Optional.isNone(zipped));
|
|
580
641
|
});
|
|
581
642
|
|
|
582
643
|
test('should return None if second is None', () => {
|
|
583
644
|
const a = Optional.some(1);
|
|
645
|
+
|
|
584
646
|
const b = Optional.none;
|
|
647
|
+
|
|
585
648
|
const zipped = Optional.zip(a, b);
|
|
586
649
|
|
|
587
|
-
|
|
650
|
+
assert.isTrue(Optional.isNone(zipped));
|
|
588
651
|
});
|
|
589
652
|
|
|
590
653
|
test('should return None if both are None', () => {
|
|
591
654
|
const zipped = Optional.zip(Optional.none, Optional.none);
|
|
592
655
|
|
|
593
|
-
|
|
656
|
+
assert.isTrue(Optional.isNone(zipped));
|
|
594
657
|
});
|
|
595
658
|
});
|
|
596
659
|
|
|
597
660
|
describe('fromNullable', () => {
|
|
598
661
|
test('should convert non-null values to Some', () => {
|
|
599
662
|
const helloOpt = Optional.fromNullable('hello');
|
|
663
|
+
|
|
600
664
|
if (Optional.isSome(helloOpt))
|
|
601
665
|
expect(Optional.unwrap(helloOpt)).toBe('hello');
|
|
602
666
|
|
|
603
667
|
const numOpt = Optional.fromNullable(42);
|
|
668
|
+
|
|
604
669
|
if (Optional.isSome(numOpt)) expect(Optional.unwrap(numOpt)).toBe(42);
|
|
605
670
|
|
|
606
671
|
const zeroOpt = Optional.fromNullable(0);
|
|
672
|
+
|
|
607
673
|
if (Optional.isSome(zeroOpt)) expect(Optional.unwrap(zeroOpt)).toBe(0);
|
|
608
674
|
|
|
609
675
|
const emptyOpt = Optional.fromNullable('');
|
|
676
|
+
|
|
610
677
|
if (Optional.isSome(emptyOpt)) expect(Optional.unwrap(emptyOpt)).toBe('');
|
|
611
678
|
|
|
612
679
|
const falseOpt = Optional.fromNullable(false);
|
|
613
|
-
|
|
614
|
-
|
|
680
|
+
|
|
681
|
+
if (Optional.isSome(falseOpt)) assert.isFalse(Optional.unwrap(falseOpt));
|
|
615
682
|
});
|
|
616
683
|
|
|
617
684
|
test('should convert null to None', () => {
|
|
618
|
-
|
|
685
|
+
assert.isTrue(Optional.isNone(Optional.fromNullable(null)));
|
|
619
686
|
});
|
|
620
687
|
|
|
621
688
|
test('should convert undefined to None', () => {
|
|
622
|
-
|
|
689
|
+
assert.isTrue(Optional.isNone(Optional.fromNullable(undefined)));
|
|
623
690
|
});
|
|
624
691
|
|
|
625
692
|
test('should work with union types', () => {
|
|
@@ -632,7 +699,9 @@ describe('Optional test', () => {
|
|
|
632
699
|
describe('toNullable', () => {
|
|
633
700
|
test('should convert Some to its value', () => {
|
|
634
701
|
expect(Optional.toNullable(Optional.some(42))).toBe(42);
|
|
702
|
+
|
|
635
703
|
expect(Optional.toNullable(Optional.some('hello'))).toBe('hello');
|
|
704
|
+
|
|
636
705
|
expect(Optional.toNullable(Optional.some(null))).toBeNull();
|
|
637
706
|
});
|
|
638
707
|
|
|
@@ -652,7 +721,8 @@ describe('Optional test', () => {
|
|
|
652
721
|
test('should handle undefined as a Some value', () => {
|
|
653
722
|
const someUndefined = Optional.some(undefined);
|
|
654
723
|
|
|
655
|
-
|
|
724
|
+
assert.isTrue(Optional.isSome(someUndefined));
|
|
725
|
+
|
|
656
726
|
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
657
727
|
expect(Optional.unwrap(someUndefined)).toBeUndefined();
|
|
658
728
|
|
|
@@ -663,18 +733,20 @@ describe('Optional test', () => {
|
|
|
663
733
|
test('should handle null as a Some value', () => {
|
|
664
734
|
const someNull = Optional.some(null);
|
|
665
735
|
|
|
666
|
-
|
|
736
|
+
assert.isTrue(Optional.isSome(someNull));
|
|
737
|
+
|
|
667
738
|
expect(Optional.unwrap(someNull)).toBeNull();
|
|
668
739
|
});
|
|
669
740
|
|
|
670
741
|
test('should handle nested Optionals', () => {
|
|
671
742
|
const nested = Optional.some(Optional.some(42));
|
|
672
743
|
|
|
673
|
-
|
|
744
|
+
assert.isTrue(Optional.isSome(nested));
|
|
674
745
|
|
|
675
746
|
const inner = Optional.unwrap(nested);
|
|
676
747
|
|
|
677
|
-
|
|
748
|
+
assert.isTrue(Optional.isOptional(inner));
|
|
749
|
+
|
|
678
750
|
expect(Optional.unwrap(inner)).toBe(42);
|
|
679
751
|
});
|
|
680
752
|
});
|
package/src/functional/pipe.mts
CHANGED
|
@@ -89,7 +89,7 @@ type PipeBase<A> = Readonly<{
|
|
|
89
89
|
* value.toUpperCase(),
|
|
90
90
|
* );
|
|
91
91
|
*
|
|
92
|
-
* assert(empty.value === undefined);
|
|
92
|
+
* assert.isTrue(empty.value === undefined);
|
|
93
93
|
* ```
|
|
94
94
|
*
|
|
95
95
|
* @template B The type of the transformed value.
|
|
@@ -127,7 +127,7 @@ type PipeWithMapOptional<A extends UnknownOptional> = MergeIntersection<
|
|
|
127
127
|
* (value) => value * 2,
|
|
128
128
|
* );
|
|
129
129
|
*
|
|
130
|
-
* assert.
|
|
130
|
+
* assert.isTrue(Optional.isNone(empty.value));
|
|
131
131
|
* ```
|
|
132
132
|
*
|
|
133
133
|
* @template B The type of the transformed inner value.
|
|
@@ -61,23 +61,26 @@ describe(pipe, () => {
|
|
|
61
61
|
|
|
62
62
|
test('mapOptional with Some value', () => {
|
|
63
63
|
const optional = Optional.some(42);
|
|
64
|
+
|
|
64
65
|
const result = pipe(optional).mapOptional((x) => x * 2).value;
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
assert.isTrue(Optional.isSome(result));
|
|
67
68
|
|
|
68
69
|
if (Optional.isSome(result)) {
|
|
69
70
|
expect(result.value).toBe(84);
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
|
|
73
|
+
expectType<typeof result, Some<number>>('=');
|
|
72
74
|
});
|
|
73
75
|
|
|
74
76
|
test('mapOptional with None value', () => {
|
|
75
77
|
const optional: Optional<number> = Optional.none;
|
|
78
|
+
|
|
76
79
|
const result = pipe(optional).mapOptional((x) => x * 2).value;
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
assert.isTrue(Optional.isNone(result));
|
|
79
82
|
|
|
80
|
-
expectType<typeof result,
|
|
83
|
+
expectType<typeof result, None>('=');
|
|
81
84
|
});
|
|
82
85
|
|
|
83
86
|
test('chaining multiple operations', () => {
|
|
@@ -10,20 +10,22 @@ import { ErrTypeTagName } from './tag.mjs';
|
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
12
|
* const success = Result.ok({ id: 1 });
|
|
13
|
+
*
|
|
13
14
|
* const failure = Result.err(new Error('missing data'));
|
|
14
15
|
*
|
|
15
16
|
* assert.deepStrictEqual(success, {
|
|
16
17
|
* $$tag: 'ts-data-forge::Result.ok',
|
|
17
18
|
* value: { id: 1 },
|
|
18
19
|
* });
|
|
19
|
-
*
|
|
20
|
+
*
|
|
21
|
+
* assert.isTrue(Result.isErr(failure));
|
|
20
22
|
* ```
|
|
21
23
|
*
|
|
22
24
|
* @template E The type of the error value.
|
|
23
25
|
* @param value The error value.
|
|
24
26
|
* @returns A `Result.Err<E>` containing the value.
|
|
25
27
|
*/
|
|
26
|
-
export const err = <E,>(value: E): Err<E> => ({
|
|
28
|
+
export const err = <const E,>(value: E): Err<E> => ({
|
|
27
29
|
$$tag: ErrTypeTagName,
|
|
28
30
|
value,
|
|
29
31
|
});
|