ts-data-forge 3.3.1 → 4.1.0
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/dist/array/impl/array-utils-element-access.d.mts +3 -4
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +8 -8
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +8 -9
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +9 -7
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +0 -1
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +6 -6
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +2 -4
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/collections/imap-mapped.d.mts +0 -1
- package/dist/collections/imap-mapped.d.mts.map +1 -1
- package/dist/collections/imap-mapped.mjs +7 -6
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +0 -1
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +11 -9
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/queue.d.mts +0 -1
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +4 -4
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts +0 -1
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +4 -4
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.d.mts +1 -0
- package/dist/entry-point.d.mts.map +1 -1
- package/dist/entry-point.mjs +8 -4
- package/dist/entry-point.mjs.map +1 -1
- package/dist/functional/index.d.mts +3 -2
- package/dist/functional/index.d.mts.map +1 -1
- package/dist/functional/index.mjs +6 -2
- package/dist/functional/index.mjs.map +1 -1
- package/dist/functional/optional/impl/index.d.mts +18 -0
- package/dist/functional/optional/impl/index.d.mts.map +1 -0
- package/dist/functional/optional/impl/index.mjs +17 -0
- package/dist/functional/optional/impl/index.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts +29 -0
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-expect-to-be.mjs +25 -0
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-filter.d.mts +29 -0
- package/dist/functional/optional/impl/optional-filter.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-filter.mjs +28 -0
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-flat-map.d.mts +33 -0
- package/dist/functional/optional/impl/optional-flat-map.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-flat-map.mjs +21 -0
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-from-nullable.d.mts +24 -0
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-from-nullable.mjs +29 -0
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-is-none.d.mts +22 -0
- package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-is-none.mjs +25 -0
- package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-is-optional.d.mts +18 -0
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-is-optional.mjs +27 -0
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-is-some.d.mts +22 -0
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-is-some.mjs +25 -0
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-map.d.mts +31 -0
- package/dist/functional/optional/impl/optional-map.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-map.mjs +25 -0
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-none.d.mts +16 -0
- package/dist/functional/optional/impl/optional-none.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-none.mjs +20 -0
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-or-else.d.mts +35 -0
- package/dist/functional/optional/impl/optional-or-else.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-or-else.mjs +19 -0
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-some.d.mts +19 -0
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-some.mjs +26 -0
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +27 -0
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-to-nullable.mjs +31 -0
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +33 -0
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-or.mjs +19 -0
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +29 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +38 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap.d.mts +28 -0
- package/dist/functional/optional/impl/optional-unwrap.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap.mjs +11 -0
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-zip.d.mts +31 -0
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-zip.mjs +39 -0
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -0
- package/dist/functional/optional/impl/tag.d.mts +5 -0
- package/dist/functional/optional/impl/tag.d.mts.map +1 -0
- package/dist/functional/optional/impl/tag.mjs +7 -0
- package/dist/functional/optional/impl/tag.mjs.map +1 -0
- package/dist/functional/optional/impl/types.d.mts +22 -0
- package/dist/functional/optional/impl/types.d.mts.map +1 -0
- package/dist/functional/optional/impl/types.mjs +2 -0
- package/dist/functional/optional/impl/types.mjs.map +1 -0
- package/dist/functional/optional/index.d.mts +2 -0
- package/dist/functional/optional/index.d.mts.map +1 -0
- package/dist/functional/optional/index.mjs +3 -0
- package/dist/functional/optional/index.mjs.map +1 -0
- package/dist/functional/pipe.d.mts +4 -4
- package/dist/functional/pipe.d.mts.map +1 -1
- package/dist/functional/pipe.mjs +4 -3
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result/impl/index.d.mts +24 -0
- package/dist/functional/result/impl/index.d.mts.map +1 -0
- package/dist/functional/result/impl/index.mjs +23 -0
- package/dist/functional/result/impl/index.mjs.map +1 -0
- package/dist/functional/result/impl/result-err.d.mts +25 -0
- package/dist/functional/result/impl/result-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-err.mjs +32 -0
- package/dist/functional/result/impl/result-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-expect-to-be.d.mts +27 -0
- package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -0
- package/dist/functional/result/impl/result-expect-to-be.mjs +26 -0
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -0
- package/dist/functional/result/impl/result-flat-map.d.mts +39 -0
- package/dist/functional/result/impl/result-flat-map.d.mts.map +1 -0
- package/dist/functional/result/impl/result-flat-map.mjs +24 -0
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -0
- package/dist/functional/result/impl/result-fold.d.mts +45 -0
- package/dist/functional/result/impl/result-fold.d.mts.map +1 -0
- package/dist/functional/result/impl/result-fold.mjs +26 -0
- package/dist/functional/result/impl/result-fold.mjs.map +1 -0
- package/dist/functional/result/impl/result-from-promise.d.mts +32 -0
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -0
- package/dist/functional/result/impl/result-from-promise.mjs +32 -0
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -0
- package/dist/functional/result/impl/result-from-throwable.d.mts +29 -0
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -0
- package/dist/functional/result/impl/result-from-throwable.mjs +46 -0
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -0
- package/dist/functional/result/impl/result-is-err.d.mts +20 -0
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-is-err.mjs +23 -0
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-is-ok.d.mts +20 -0
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -0
- package/dist/functional/result/impl/result-is-ok.mjs +23 -0
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -0
- package/dist/functional/result/impl/result-is-result.d.mts +17 -0
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -0
- package/dist/functional/result/impl/result-is-result.mjs +26 -0
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -0
- package/dist/functional/result/impl/result-map-err.d.mts +33 -0
- package/dist/functional/result/impl/result-map-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-map-err.mjs +25 -0
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-map.d.mts +34 -0
- package/dist/functional/result/impl/result-map.d.mts.map +1 -0
- package/dist/functional/result/impl/result-map.mjs +25 -0
- package/dist/functional/result/impl/result-map.mjs.map +1 -0
- package/dist/functional/result/impl/result-ok.d.mts +25 -0
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -0
- package/dist/functional/result/impl/result-ok.mjs +32 -0
- package/dist/functional/result/impl/result-ok.mjs.map +1 -0
- package/dist/functional/result/impl/result-or-else.d.mts +32 -0
- package/dist/functional/result/impl/result-or-else.d.mts.map +1 -0
- package/dist/functional/result/impl/result-or-else.mjs +20 -0
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -0
- package/dist/functional/result/impl/result-swap.d.mts +20 -0
- package/dist/functional/result/impl/result-swap.d.mts.map +1 -0
- package/dist/functional/result/impl/result-swap.mjs +28 -0
- package/dist/functional/result/impl/result-swap.mjs.map +1 -0
- package/dist/functional/result/impl/result-to-optional.d.mts +28 -0
- package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -0
- package/dist/functional/result/impl/result-to-optional.mjs +34 -0
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts +29 -0
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-or.mjs +20 -0
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +30 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +47 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err.d.mts +31 -0
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err.mjs +36 -0
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +29 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs +20 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok.d.mts +23 -0
- package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok.mjs +11 -0
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-throw.d.mts +30 -0
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-throw.mjs +41 -0
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -0
- package/dist/functional/result/impl/result-zip.d.mts +29 -0
- package/dist/functional/result/impl/result-zip.d.mts.map +1 -0
- package/dist/functional/result/impl/result-zip.mjs +38 -0
- package/dist/functional/result/impl/result-zip.mjs.map +1 -0
- package/dist/functional/result/impl/tag.d.mts +5 -0
- package/dist/functional/result/impl/tag.d.mts.map +1 -0
- package/dist/functional/result/impl/tag.mjs +7 -0
- package/dist/functional/result/impl/tag.mjs.map +1 -0
- package/dist/functional/result/impl/types.d.mts +29 -0
- package/dist/functional/result/impl/types.d.mts.map +1 -0
- package/dist/functional/result/impl/types.mjs +2 -0
- package/dist/functional/result/impl/types.mjs.map +1 -0
- package/dist/functional/result/index.d.mts +2 -0
- package/dist/functional/result/index.d.mts.map +1 -0
- package/dist/functional/result/index.mjs +3 -0
- package/dist/functional/result/index.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/index.d.mts +29 -0
- package/dist/functional/ternary-result/impl/index.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/index.mjs +28 -0
- package/dist/functional/ternary-result/impl/index.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/tag.d.mts +7 -0
- package/dist/functional/ternary-result/impl/tag.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/tag.mjs +9 -0
- package/dist/functional/ternary-result/impl/tag.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +14 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +41 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +27 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +20 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +33 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts +20 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +35 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +16 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +19 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +16 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +25 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +13 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +19 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +32 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +48 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/types.d.mts +25 -0
- package/dist/functional/ternary-result/impl/types.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/types.mjs +2 -0
- package/dist/functional/ternary-result/impl/types.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/variant-name.d.mts +3 -0
- package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/variant-name.mjs +16 -0
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -0
- package/dist/functional/ternary-result/index.d.mts +2 -0
- package/dist/functional/ternary-result/index.d.mts.map +1 -0
- package/dist/functional/ternary-result/index.mjs +3 -0
- package/dist/functional/ternary-result/index.mjs.map +1 -0
- package/dist/globals.d.mts +136 -0
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +1 -1
- package/dist/json/json.d.mts +0 -1
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +8 -8
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +1 -1
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.mjs +1 -1
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.mjs +1 -1
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.mjs +1 -1
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +1 -1
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +1 -1
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +1 -1
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +1 -1
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +1 -1
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +1 -1
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +1 -1
- 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/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.mjs +1 -1
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.mjs +1 -1
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.mjs +1 -1
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.mjs +1 -1
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.mjs +1 -1
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/refined-number-utils.mjs +0 -2
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/promise/promise.d.mts +0 -1
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +2 -3
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +27 -21
- package/src/array/impl/array-utils-element-access.mts +6 -6
- package/src/array/impl/array-utils-element-access.test.mts +6 -6
- package/src/array/impl/array-utils-reducing-value.mts +8 -24
- package/src/array/impl/array-utils-reducing-value.test.mts +8 -8
- package/src/array/impl/array-utils-slice-clamped.test.mts +1 -1
- package/src/entry-point.mts +1 -0
- package/src/functional/index.mts +3 -2
- package/src/functional/optional/impl/index.mts +17 -0
- package/src/functional/optional/impl/optional-expect-to-be.mts +65 -0
- package/src/functional/optional/impl/optional-filter.mts +71 -0
- package/src/functional/optional/impl/optional-flat-map.mts +67 -0
- package/src/functional/optional/impl/optional-from-nullable.mts +28 -0
- package/src/functional/optional/impl/optional-is-none.mts +25 -0
- package/src/functional/optional/impl/optional-is-optional.mts +27 -0
- package/src/functional/optional/impl/optional-is-some.mts +25 -0
- package/src/functional/optional/impl/optional-map.mts +69 -0
- package/src/functional/optional/impl/optional-none.mts +17 -0
- package/src/functional/optional/impl/optional-or-else.mts +73 -0
- package/src/functional/optional/impl/optional-some.mts +23 -0
- package/src/functional/optional/impl/optional-to-nullable.mts +31 -0
- package/src/functional/optional/impl/optional-unwrap-or.mts +64 -0
- package/src/functional/optional/impl/optional-unwrap-throw.mts +39 -0
- package/src/functional/optional/impl/optional-unwrap.mts +41 -0
- package/src/functional/optional/impl/optional-zip.mts +40 -0
- package/src/functional/optional/impl/tag.mts +6 -0
- package/src/functional/optional/impl/types.mts +28 -0
- package/src/functional/optional/index.mts +1 -0
- package/src/functional/optional.test.mts +7 -8
- package/src/functional/pipe.mts +5 -5
- package/src/functional/pipe.test.mts +1 -1
- package/src/functional/result/impl/index.mts +23 -0
- package/src/functional/result/impl/result-err.mts +29 -0
- package/src/functional/result/impl/result-expect-to-be.mts +63 -0
- package/src/functional/result/impl/result-flat-map.mts +79 -0
- package/src/functional/result/impl/result-fold.mts +95 -0
- package/src/functional/result/impl/result-from-promise.mts +39 -0
- package/src/functional/result/impl/result-from-throwable.mts +42 -0
- package/src/functional/result/impl/result-is-err.mts +23 -0
- package/src/functional/result/impl/result-is-ok.mts +23 -0
- package/src/functional/result/impl/result-is-result.mts +23 -0
- package/src/functional/result/impl/result-map-err.mts +72 -0
- package/src/functional/result/impl/result-map.mts +73 -0
- package/src/functional/result/impl/result-ok.mts +29 -0
- package/src/functional/result/impl/result-or-else.mts +63 -0
- package/src/functional/result/impl/result-swap.mts +28 -0
- package/src/functional/result/impl/result-to-optional.mts +34 -0
- package/src/functional/result/impl/result-unwrap-err-or.mts +60 -0
- package/src/functional/result/impl/result-unwrap-err-throw.mts +53 -0
- package/src/functional/result/impl/result-unwrap-err.mts +36 -0
- package/src/functional/result/impl/result-unwrap-ok-or.mts +60 -0
- package/src/functional/result/impl/result-unwrap-ok.mts +35 -0
- package/src/functional/result/impl/result-unwrap-throw.mts +43 -0
- package/src/functional/result/impl/result-zip.mts +39 -0
- package/src/functional/result/impl/tag.mts +6 -0
- package/src/functional/result/impl/types.mts +35 -0
- package/src/functional/result/index.mts +1 -0
- package/src/functional/result.test.mts +5 -4
- package/src/functional/ternary-result/impl/index.mts +28 -0
- package/src/functional/ternary-result/impl/tag.mts +11 -0
- package/src/functional/ternary-result/impl/ternary-result-err.mts +18 -0
- package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +53 -0
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +95 -0
- package/src/functional/ternary-result/impl/ternary-result-fold.mts +93 -0
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +27 -0
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +31 -0
- package/src/functional/ternary-result/impl/ternary-result-is-err.mts +23 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +24 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +27 -0
- package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +24 -0
- package/src/functional/ternary-result/impl/ternary-result-map-err.mts +64 -0
- package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +66 -0
- package/src/functional/ternary-result/impl/ternary-result-map.mts +81 -0
- package/src/functional/ternary-result/impl/ternary-result-ok.mts +20 -0
- package/src/functional/ternary-result/impl/ternary-result-or-else.mts +66 -0
- package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +25 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +40 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +22 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +32 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +42 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +38 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +22 -0
- package/src/functional/ternary-result/impl/ternary-result-warn.mts +23 -0
- package/src/functional/ternary-result/impl/ternary-result-zip.mts +53 -0
- package/src/functional/ternary-result/impl/types.mts +39 -0
- package/src/functional/ternary-result/impl/variant-name.mts +17 -0
- package/src/functional/ternary-result/index.mts +1 -0
- package/src/functional/ternary-result.test.mts +198 -0
- package/src/globals.d.mts +136 -0
- package/src/guard/is-non-empty-string.test.mts +1 -1
- package/src/guard/is-non-null-object.test.mts +3 -3
- package/src/guard/is-primitive.test.mts +3 -3
- package/src/guard/is-type.test.mts +3 -3
- package/src/index.mts +0 -1
- package/src/number/branded-types/finite-number.mts +7 -7
- package/src/number/branded-types/int.mts +7 -7
- package/src/number/branded-types/int16.mts +9 -9
- package/src/number/branded-types/int32.mts +9 -9
- package/src/number/branded-types/non-negative-finite-number.mts +8 -8
- package/src/number/branded-types/non-negative-int16.mts +9 -9
- package/src/number/branded-types/non-negative-int32.mts +9 -9
- package/src/number/branded-types/non-zero-finite-number.mts +7 -7
- package/src/number/branded-types/non-zero-int.mts +7 -7
- package/src/number/branded-types/non-zero-int16.mts +9 -9
- package/src/number/branded-types/non-zero-int32.mts +9 -9
- package/src/number/branded-types/non-zero-safe-int.mts +9 -9
- package/src/number/branded-types/non-zero-uint16.mts +9 -9
- package/src/number/branded-types/non-zero-uint32.mts +9 -9
- package/src/number/branded-types/positive-finite-number.mts +8 -8
- package/src/number/branded-types/positive-int.mts +8 -8
- package/src/number/branded-types/positive-int16.mts +9 -9
- package/src/number/branded-types/positive-int32.mts +9 -9
- package/src/number/branded-types/positive-safe-int.mts +9 -9
- package/src/number/branded-types/positive-uint16.mts +9 -9
- package/src/number/branded-types/positive-uint32.mts +9 -9
- package/src/number/branded-types/safe-int.mts +9 -9
- package/src/number/branded-types/safe-uint.mts +9 -9
- package/src/number/branded-types/uint.mts +8 -8
- package/src/number/branded-types/uint16.mts +9 -9
- package/src/number/branded-types/uint32.mts +9 -9
- package/src/number/enum/int8.mts +3 -3
- package/src/number/enum/int8.test.mts +9 -9
- package/src/number/enum/uint8.mts +3 -3
- package/src/number/enum/uint8.test.mts +8 -8
- package/dist/functional/optional.d.mts +0 -482
- package/dist/functional/optional.d.mts.map +0 -1
- package/dist/functional/optional.mjs +0 -328
- package/dist/functional/optional.mjs.map +0 -1
- package/dist/functional/result.d.mts +0 -712
- package/dist/functional/result.d.mts.map +0 -1
- package/dist/functional/result.mjs +0 -539
- package/dist/functional/result.mjs.map +0 -1
- package/src/functional/optional.mts +0 -713
- package/src/functional/result.mts +0 -1087
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { unknownToString } from '../../../others/unknown-to-string.mjs';
|
|
2
|
+
import { match } from '../../match.mjs';
|
|
3
|
+
import { isErr } from './result-is-err.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Unwraps a `Result`, returning the error value. Throws an error if the
|
|
7
|
+
* `Result` is `Result.Ok`.
|
|
8
|
+
*
|
|
9
|
+
* This function is used when you expect a Result to be an error and want to
|
|
10
|
+
* extract the error value. If the Result is unexpectedly Ok, it will throw an
|
|
11
|
+
* error with information about the unexpected success value.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const errResult = Result.err(new Error('broken'));
|
|
17
|
+
* const okResult = Result.ok('value');
|
|
18
|
+
*
|
|
19
|
+
* assert(Result.unwrapErrThrow(errResult).message === 'broken');
|
|
20
|
+
* assert.throws(() => Result.unwrapErrThrow(okResult), /Expected Err/u);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
24
|
+
* @param result The `Result` to unwrap.
|
|
25
|
+
* @param toStr An optional function to convert the success value to a string
|
|
26
|
+
* for the error message when the Result is unexpectedly Ok. Defaults to
|
|
27
|
+
* `String`.
|
|
28
|
+
* @returns The error value if `Result.Err`.
|
|
29
|
+
* @throws {Error} Error with message "Expected Err but got Ok: {value}" if
|
|
30
|
+
* the `Result` is `Result.Ok`.
|
|
31
|
+
*/
|
|
32
|
+
const unwrapErrThrow = (result, toStr = unknownToString) => {
|
|
33
|
+
if (isErr(result)) {
|
|
34
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
35
|
+
return result.value;
|
|
36
|
+
}
|
|
37
|
+
const variant = match(result.$$tag, {
|
|
38
|
+
'ts-data-forge::Result.ok': 'Ok',
|
|
39
|
+
'ts-data-forge::Result.err': 'Err',
|
|
40
|
+
});
|
|
41
|
+
throw new Error(`Expected Err but got ${variant}: ${toStr(
|
|
42
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
43
|
+
result.value)}`);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { unwrapErrThrow };
|
|
47
|
+
//# sourceMappingURL=result-unwrap-err-throw.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-err-throw.mjs","sources":["../../../../src/functional/result/impl/result-unwrap-err-throw.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACI,MAAM,cAAc,GAAG,CAC5B,MAAS,EACT,KAAA,GAAoC,eAAe,KACnC;AAChB,IAAA,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;;QAEjB,OAAO,MAAM,CAAC,KAAqB;IACrC;AAEA,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;AAClC,QAAA,0BAA0B,EAAE,IAAI;AAChC,QAAA,2BAA2B,EAAE,KAAK;AACnC,KAAA,CAAC;AAEF,IAAA,MAAM,IAAI,KAAK,CACb,CAAA,qBAAA,EAAwB,OAAO,KAAK,KAAK;;AAEvC,IAAA,MAAM,CAAC,KAAoB,CAC5B,CAAA,CAAE,CACJ;AACH;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type UnwrapErr } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps a `Result`, returning the error value or `undefined` if it is
|
|
4
|
+
* `Result.Ok`.
|
|
5
|
+
*
|
|
6
|
+
* This provides a safe way to extract error values from Results without
|
|
7
|
+
* throwing exceptions. Useful for error handling patterns where you want to
|
|
8
|
+
* check for specific error conditions.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const okResult = Result.ok('data');
|
|
14
|
+
* const errResult = Result.err('problem');
|
|
15
|
+
*
|
|
16
|
+
* // Result.unwrapErr returns undefined for Ok results
|
|
17
|
+
*
|
|
18
|
+
* // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
19
|
+
* assert(Result.unwrapErr(okResult) === undefined);
|
|
20
|
+
*
|
|
21
|
+
* // Result.unwrapErr returns the error value for Err results
|
|
22
|
+
*
|
|
23
|
+
* assert(Result.unwrapErr(errResult) === 'problem');
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
27
|
+
* @param result The `Result` to unwrap.
|
|
28
|
+
* @returns The error value if `Result.Err`, otherwise `undefined`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const unwrapErr: <R extends UnknownResult>(result: R) => UnwrapErr<R> | undefined;
|
|
31
|
+
//# sourceMappingURL=result-unwrap-err.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-err.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,aAAa,EAC/C,QAAQ,CAAC,KACR,SAAS,CAAC,CAAC,CAAC,GAAG,SAE0C,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isErr } from './result-is-err.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unwraps a `Result`, returning the error value or `undefined` if it is
|
|
5
|
+
* `Result.Ok`.
|
|
6
|
+
*
|
|
7
|
+
* This provides a safe way to extract error values from Results without
|
|
8
|
+
* throwing exceptions. Useful for error handling patterns where you want to
|
|
9
|
+
* check for specific error conditions.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const okResult = Result.ok('data');
|
|
15
|
+
* const errResult = Result.err('problem');
|
|
16
|
+
*
|
|
17
|
+
* // Result.unwrapErr returns undefined for Ok results
|
|
18
|
+
*
|
|
19
|
+
* // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
20
|
+
* assert(Result.unwrapErr(okResult) === undefined);
|
|
21
|
+
*
|
|
22
|
+
* // Result.unwrapErr returns the error value for Err results
|
|
23
|
+
*
|
|
24
|
+
* assert(Result.unwrapErr(errResult) === 'problem');
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
28
|
+
* @param result The `Result` to unwrap.
|
|
29
|
+
* @returns The error value if `Result.Err`, otherwise `undefined`.
|
|
30
|
+
*/
|
|
31
|
+
const unwrapErr = (result) =>
|
|
32
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
33
|
+
isErr(result) ? result.value : undefined;
|
|
34
|
+
|
|
35
|
+
export { unwrapErr };
|
|
36
|
+
//# sourceMappingURL=result-unwrap-err.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-err.mjs","sources":["../../../../src/functional/result/impl/result-unwrap-err.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,MAAM,SAAS,GAAG,CACvB,MAAS;AAET;AACA,KAAK,CAAC,MAAM,CAAC,GAAI,MAAM,CAAC,KAAsB,GAAG;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type UnwrapOk } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps a `Result`, returning the success value or a default value if it is
|
|
4
|
+
* `Result.Err`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const okValue = Result.ok(10);
|
|
10
|
+
* const errValue = Result.err('fail');
|
|
11
|
+
*
|
|
12
|
+
* assert(Result.unwrapOkOr(okValue, 0) === 10);
|
|
13
|
+
* assert(Result.unwrapOkOr(errValue, 0) === 0);
|
|
14
|
+
*
|
|
15
|
+
* const unwrapWithDefault = Result.unwrapOkOr(5);
|
|
16
|
+
*
|
|
17
|
+
* assert(unwrapWithDefault(Result.ok(3)) === 3);
|
|
18
|
+
* assert(unwrapWithDefault(Result.err('no data')) === 5);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
22
|
+
* @template D The type of the default value.
|
|
23
|
+
* @param result The `Result` to unwrap.
|
|
24
|
+
* @param defaultValue The value to return if `result` is `Result.Err`.
|
|
25
|
+
* @returns The success value if `Result.Ok`, otherwise `defaultValue`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function unwrapOkOr<R extends UnknownResult, D>(result: R, defaultValue: D): D | UnwrapOk<R>;
|
|
28
|
+
export declare function unwrapOkOr<S, D>(defaultValue: D): <E>(result: Result<S, E>) => D | S;
|
|
29
|
+
//# sourceMappingURL=result-unwrap-ok-or.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-ok-or.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-ok-or.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC,EACnD,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,CAAC,GACd,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGnB,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC7B,YAAY,EAAE,CAAC,GACd,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { unwrapOk } from './result-unwrap-ok.mjs';
|
|
2
|
+
|
|
3
|
+
function unwrapOkOr(...args) {
|
|
4
|
+
switch (args.length) {
|
|
5
|
+
case 2: {
|
|
6
|
+
// Direct version: first argument is result
|
|
7
|
+
const [result, defaultValue] = args;
|
|
8
|
+
return unwrapOkOrImpl(result, defaultValue);
|
|
9
|
+
}
|
|
10
|
+
case 1: {
|
|
11
|
+
// Curried version
|
|
12
|
+
const [defaultValue] = args;
|
|
13
|
+
return (result) => unwrapOkOrImpl(result, defaultValue);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const unwrapOkOrImpl = (result, defaultValue) => unwrapOk(result) ?? defaultValue;
|
|
18
|
+
|
|
19
|
+
export { unwrapOkOr };
|
|
20
|
+
//# sourceMappingURL=result-unwrap-ok-or.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-ok-or.mjs","sources":["../../../../src/functional/result/impl/result-unwrap-ok-or.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAsCM,SAAU,UAAU,CACxB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;AACnC,YAAA,OAAO,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC;QAC7C;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI;YAC3B,OAAO,CAAC,MAAS,KAAK,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC;QAC5D;;AAEJ;AAEA,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,YAAe,KACK,QAAQ,CAAC,MAAM,CAAC,IAAI,YAAY;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type UnwrapOk } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Safely unwraps the success value, returning `undefined` for failures.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const okResult = Result.ok(42);
|
|
9
|
+
* const errResult = Result.err('oops');
|
|
10
|
+
*
|
|
11
|
+
* // Result.unwrapOk returns the value for Ok results
|
|
12
|
+
*
|
|
13
|
+
* assert(Result.unwrapOk(okResult) === 42);
|
|
14
|
+
*
|
|
15
|
+
* // Result.unwrapOk returns undefined for Err results
|
|
16
|
+
*
|
|
17
|
+
* // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
18
|
+
* assert(Result.unwrapOk(errResult) === undefined);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function unwrapOk<R extends Ok<unknown>>(result: R): UnwrapOk<R>;
|
|
22
|
+
export declare function unwrapOk<R extends UnknownResult>(result: R): UnwrapOk<R> | undefined;
|
|
23
|
+
//# sourceMappingURL=result-unwrap-ok.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-ok.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-ok.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AACxE,wBAAgB,QAAQ,CAAC,CAAC,SAAS,aAAa,EAC9C,MAAM,EAAE,CAAC,GACR,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isOk } from './result-is-ok.mjs';
|
|
2
|
+
|
|
3
|
+
function unwrapOk(result) {
|
|
4
|
+
return isOk(result)
|
|
5
|
+
? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
6
|
+
result.value
|
|
7
|
+
: undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { unwrapOk };
|
|
11
|
+
//# sourceMappingURL=result-unwrap-ok.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-ok.mjs","sources":["../../../../src/functional/result/impl/result-unwrap-ok.mts"],"sourcesContent":[null],"names":[],"mappings":";;AA2BM,SAAU,QAAQ,CACtB,MAAS,EAAA;IAET,OAAO,IAAI,CAAC,MAAM;AAChB;AACG,YAAA,MAAM,CAAC;UACR,SAAS;AACf;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type UnwrapErr, type UnwrapOk } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps a `Result`, returning the success value. Throws an error if the
|
|
4
|
+
* `Result` is `Result.Err`.
|
|
5
|
+
*
|
|
6
|
+
* This is useful when you're confident that a Result should contain a success
|
|
7
|
+
* value and want to treat errors as exceptional conditions. The error message
|
|
8
|
+
* will be constructed from the error value using the provided string
|
|
9
|
+
* conversion function.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const okResult = Result.ok('data');
|
|
15
|
+
* const errResult = Result.err(new Error('fail'));
|
|
16
|
+
*
|
|
17
|
+
* assert(Result.unwrapThrow(okResult) === 'data');
|
|
18
|
+
* assert.throws(() => Result.unwrapThrow(errResult), /fail/u);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
22
|
+
* @param result The `Result` to unwrap.
|
|
23
|
+
* @param toStr An optional function to convert the error value to a string
|
|
24
|
+
* for the error message. Defaults to `String`.
|
|
25
|
+
* @returns The success value if `Result.Ok`.
|
|
26
|
+
* @throws {Error} Error with the stringified error value if the `Result` is
|
|
27
|
+
* `Result.Err`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const unwrapThrow: <R extends UnknownResult>(result: R, toStr?: (e: UnwrapErr<R>) => string) => UnwrapOk<R>;
|
|
30
|
+
//# sourceMappingURL=result-unwrap-throw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-throw.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-throw.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,aAAa,EACjD,QAAQ,CAAC,EACT,QAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,MAAwB,KACnD,QAAQ,CAAC,CAAC,CAQZ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { unknownToString } from '../../../others/unknown-to-string.mjs';
|
|
2
|
+
import { isErr } from './result-is-err.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unwraps a `Result`, returning the success value. Throws an error if the
|
|
6
|
+
* `Result` is `Result.Err`.
|
|
7
|
+
*
|
|
8
|
+
* This is useful when you're confident that a Result should contain a success
|
|
9
|
+
* value and want to treat errors as exceptional conditions. The error message
|
|
10
|
+
* will be constructed from the error value using the provided string
|
|
11
|
+
* conversion function.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const okResult = Result.ok('data');
|
|
17
|
+
* const errResult = Result.err(new Error('fail'));
|
|
18
|
+
*
|
|
19
|
+
* assert(Result.unwrapThrow(okResult) === 'data');
|
|
20
|
+
* assert.throws(() => Result.unwrapThrow(errResult), /fail/u);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
24
|
+
* @param result The `Result` to unwrap.
|
|
25
|
+
* @param toStr An optional function to convert the error value to a string
|
|
26
|
+
* for the error message. Defaults to `String`.
|
|
27
|
+
* @returns The success value if `Result.Ok`.
|
|
28
|
+
* @throws {Error} Error with the stringified error value if the `Result` is
|
|
29
|
+
* `Result.Err`.
|
|
30
|
+
*/
|
|
31
|
+
const unwrapThrow = (result, toStr = unknownToString) => {
|
|
32
|
+
if (isErr(result)) {
|
|
33
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
34
|
+
throw new Error(toStr(result.value));
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
37
|
+
return result.value;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { unwrapThrow };
|
|
41
|
+
//# sourceMappingURL=result-unwrap-throw.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-unwrap-throw.mjs","sources":["../../../../src/functional/result/impl/result-unwrap-throw.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACI,MAAM,WAAW,GAAG,CACzB,MAAS,EACT,KAAA,GAAqC,eAAe,KACrC;AACf,IAAA,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;;QAEjB,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC;IACtD;;IAGA,OAAO,MAAM,CAAC,KAAoB;AACpC;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines two `Result` values into a single `Result` containing a tuple. If
|
|
3
|
+
* either `Result` is `Err`, returns the first `Err` encountered.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const first = Result.ok('left');
|
|
9
|
+
* const second = Result.ok(1);
|
|
10
|
+
*
|
|
11
|
+
* const expected: readonly [string, number] = ['left', 1];
|
|
12
|
+
*
|
|
13
|
+
* assert.deepStrictEqual(Result.zip(first, second), Result.ok(expected));
|
|
14
|
+
* assert.deepStrictEqual(
|
|
15
|
+
* Result.zip(first, Result.err('error')),
|
|
16
|
+
* Result.err('error'),
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @template S1 The success type of the first `Result`.
|
|
21
|
+
* @template E1 The error type of the first `Result`.
|
|
22
|
+
* @template S2 The success type of the second `Result`.
|
|
23
|
+
* @template E2 The error type of the second `Result`.
|
|
24
|
+
* @param resultA The first `Result`.
|
|
25
|
+
* @param resultB The second `Result`.
|
|
26
|
+
* @returns A `Result` containing a tuple of both values, or the first `Err`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const zip: <S1, E1, S2, E2>(resultA: Result<S1, E1>, resultB: Result<S2, E2>) => Result<readonly [S1, S2], E1 | E2>;
|
|
29
|
+
//# sourceMappingURL=result-zip.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-zip.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-zip.mts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,GAAG,GAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAChC,SAAS,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,EACvB,SAAS,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,KACtB,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAKvB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isOk } from './result-is-ok.mjs';
|
|
2
|
+
import { ok } from './result-ok.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Combines two `Result` values into a single `Result` containing a tuple. If
|
|
6
|
+
* either `Result` is `Err`, returns the first `Err` encountered.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const first = Result.ok('left');
|
|
12
|
+
* const second = Result.ok(1);
|
|
13
|
+
*
|
|
14
|
+
* const expected: readonly [string, number] = ['left', 1];
|
|
15
|
+
*
|
|
16
|
+
* assert.deepStrictEqual(Result.zip(first, second), Result.ok(expected));
|
|
17
|
+
* assert.deepStrictEqual(
|
|
18
|
+
* Result.zip(first, Result.err('error')),
|
|
19
|
+
* Result.err('error'),
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @template S1 The success type of the first `Result`.
|
|
24
|
+
* @template E1 The error type of the first `Result`.
|
|
25
|
+
* @template S2 The success type of the second `Result`.
|
|
26
|
+
* @template E2 The error type of the second `Result`.
|
|
27
|
+
* @param resultA The first `Result`.
|
|
28
|
+
* @param resultB The second `Result`.
|
|
29
|
+
* @returns A `Result` containing a tuple of both values, or the first `Err`.
|
|
30
|
+
*/
|
|
31
|
+
const zip = (resultA, resultB) => isOk(resultA)
|
|
32
|
+
? isOk(resultB)
|
|
33
|
+
? ok([resultA.value, resultB.value])
|
|
34
|
+
: resultB
|
|
35
|
+
: resultA;
|
|
36
|
+
|
|
37
|
+
export { zip };
|
|
38
|
+
//# sourceMappingURL=result-zip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-zip.mjs","sources":["../../../../src/functional/result/impl/result-zip.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACI,MAAM,GAAG,GAAG,CACjB,OAAuB,EACvB,OAAuB,KAEvB,IAAI,CAAC,OAAO;AACV,MAAE,IAAI,CAAC,OAAO;AACZ,UAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAU;AAC5C,UAAE;MACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/tag.mts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,CAA8B,CAAC;AAE9E,iDAAiD;AACjD,eAAO,MAAM,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CACpB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @internal Tag identifying the Ok variant. */
|
|
2
|
+
const OkTypeTagName = 'ts-data-forge::Result.ok';
|
|
3
|
+
/** @internal Tag identifying the Err variant. */
|
|
4
|
+
const ErrTypeTagName = 'ts-data-forge::Result.err';
|
|
5
|
+
|
|
6
|
+
export { ErrTypeTagName, OkTypeTagName };
|
|
7
|
+
//# sourceMappingURL=tag.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.mjs","sources":["../../../../src/functional/result/impl/tag.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACO,MAAM,aAAa,GAAyB;AAEnD;AACO,MAAM,cAAc,GACzB;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the success value type `S` from a `Result.Ok<S>`. If the `Result`
|
|
3
|
+
* is `Result.Err<E>`, resolves to `never`.
|
|
4
|
+
*
|
|
5
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
6
|
+
*/
|
|
7
|
+
export type UnwrapOk<R extends UnknownResult> = R extends Ok<infer S> ? S : never;
|
|
8
|
+
/**
|
|
9
|
+
* Extracts the error value type `E` from a `Result.Err<E>`. If the `Result`
|
|
10
|
+
* is `Result.Ok<S>`, resolves to `never`.
|
|
11
|
+
*
|
|
12
|
+
* @template R The `UnknownResult` type to unwrap.
|
|
13
|
+
*/
|
|
14
|
+
export type UnwrapErr<R extends UnknownResult> = R extends Err<infer E> ? E : never;
|
|
15
|
+
/**
|
|
16
|
+
* Narrows a `UnknownResult` type to `Result.Ok<S>` if it is an `Ok`. If the
|
|
17
|
+
* `Result` is `Result.Err<E>`, resolves to `never`.
|
|
18
|
+
*
|
|
19
|
+
* @template R The `UnknownResult` type to narrow.
|
|
20
|
+
*/
|
|
21
|
+
export type NarrowToOk<R extends UnknownResult> = R extends Ok<unknown> ? R : never;
|
|
22
|
+
/**
|
|
23
|
+
* Narrows a `UnknownResult` type to `Result.Err<E>` if it is an `Err`. If the
|
|
24
|
+
* `Result` is `Result.Ok<S>`, resolves to `never`.
|
|
25
|
+
*
|
|
26
|
+
* @template R The `UnknownResult` type to narrow.
|
|
27
|
+
*/
|
|
28
|
+
export type NarrowToErr<R extends UnknownResult> = R extends Err<unknown> ? R : never;
|
|
29
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/types.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,aAAa,IAC1C,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,aAAa,IAC3C,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAErC;;;;;GAKG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,aAAa,IAC5C,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,aAAa,IAC7C,CAAC,SAAS,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/functional/result/index.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from './ternary-result-err.mjs';
|
|
2
|
+
export * from './ternary-result-expect-to-be.mjs';
|
|
3
|
+
export * from './ternary-result-flat-map.mjs';
|
|
4
|
+
export * from './ternary-result-fold.mjs';
|
|
5
|
+
export * from './ternary-result-from-promise.mjs';
|
|
6
|
+
export * from './ternary-result-from-throwable.mjs';
|
|
7
|
+
export * from './ternary-result-is-err.mjs';
|
|
8
|
+
export * from './ternary-result-is-ok.mjs';
|
|
9
|
+
export * from './ternary-result-is-ternary-result.mjs';
|
|
10
|
+
export * from './ternary-result-is-warn.mjs';
|
|
11
|
+
export * from './ternary-result-map-err.mjs';
|
|
12
|
+
export * from './ternary-result-map-warn.mjs';
|
|
13
|
+
export * from './ternary-result-map.mjs';
|
|
14
|
+
export * from './ternary-result-ok.mjs';
|
|
15
|
+
export * from './ternary-result-or-else.mjs';
|
|
16
|
+
export * from './ternary-result-to-optional.mjs';
|
|
17
|
+
export * from './ternary-result-unwrap-err-or.mjs';
|
|
18
|
+
export * from './ternary-result-unwrap-err-throw.mjs';
|
|
19
|
+
export * from './ternary-result-unwrap-err.mjs';
|
|
20
|
+
export * from './ternary-result-unwrap-ok-or.mjs';
|
|
21
|
+
export * from './ternary-result-unwrap-ok.mjs';
|
|
22
|
+
export * from './ternary-result-unwrap-throw.mjs';
|
|
23
|
+
export * from './ternary-result-unwrap-warn-or.mjs';
|
|
24
|
+
export * from './ternary-result-unwrap-warn-throw.mjs';
|
|
25
|
+
export * from './ternary-result-unwrap-warn.mjs';
|
|
26
|
+
export * from './ternary-result-warn.mjs';
|
|
27
|
+
export * from './ternary-result-zip.mjs';
|
|
28
|
+
export * from './types.mjs';
|
|
29
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { err } from './ternary-result-err.mjs';
|
|
2
|
+
export { expectToBe } from './ternary-result-expect-to-be.mjs';
|
|
3
|
+
export { flatMap } from './ternary-result-flat-map.mjs';
|
|
4
|
+
export { fold } from './ternary-result-fold.mjs';
|
|
5
|
+
export { fromPromise } from './ternary-result-from-promise.mjs';
|
|
6
|
+
export { fromThrowable } from './ternary-result-from-throwable.mjs';
|
|
7
|
+
export { isErr } from './ternary-result-is-err.mjs';
|
|
8
|
+
export { isOk } from './ternary-result-is-ok.mjs';
|
|
9
|
+
export { isTernaryResult } from './ternary-result-is-ternary-result.mjs';
|
|
10
|
+
export { isWarn } from './ternary-result-is-warn.mjs';
|
|
11
|
+
export { mapErr } from './ternary-result-map-err.mjs';
|
|
12
|
+
export { mapWarn } from './ternary-result-map-warn.mjs';
|
|
13
|
+
export { map } from './ternary-result-map.mjs';
|
|
14
|
+
export { ok } from './ternary-result-ok.mjs';
|
|
15
|
+
export { orElse } from './ternary-result-or-else.mjs';
|
|
16
|
+
export { toOptional } from './ternary-result-to-optional.mjs';
|
|
17
|
+
export { unwrapErrOr } from './ternary-result-unwrap-err-or.mjs';
|
|
18
|
+
export { unwrapErrThrow } from './ternary-result-unwrap-err-throw.mjs';
|
|
19
|
+
export { unwrapErr } from './ternary-result-unwrap-err.mjs';
|
|
20
|
+
export { unwrapOkOr } from './ternary-result-unwrap-ok-or.mjs';
|
|
21
|
+
export { unwrapOk } from './ternary-result-unwrap-ok.mjs';
|
|
22
|
+
export { unwrapThrow } from './ternary-result-unwrap-throw.mjs';
|
|
23
|
+
export { unwrapWarnOr } from './ternary-result-unwrap-warn-or.mjs';
|
|
24
|
+
export { unwrapWarnThrow } from './ternary-result-unwrap-warn-throw.mjs';
|
|
25
|
+
export { unwrapWarn } from './ternary-result-unwrap-warn.mjs';
|
|
26
|
+
export { warn } from './ternary-result-warn.mjs';
|
|
27
|
+
export { zip } from './ternary-result-zip.mjs';
|
|
28
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @internal Tag identifying the Ok variant. */
|
|
2
|
+
export declare const OkTypeTagName: TernaryOk<unknown>['$$tag'];
|
|
3
|
+
/** @internal Tag identifying the Warn variant. */
|
|
4
|
+
export declare const WarnTypeTagName: TernaryWarn<unknown, unknown>['$$tag'];
|
|
5
|
+
/** @internal Tag identifying the Err variant. */
|
|
6
|
+
export declare const ErrTypeTagName: TernaryErr<unknown>['$$tag'];
|
|
7
|
+
//# sourceMappingURL=tag.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/tag.mts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAC1B,CAAC;AAE7B,kDAAkD;AAClD,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,OAAO,CACrC,CAAC;AAE/B,iDAAiD;AACjD,eAAO,MAAM,cAAc,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAC3B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @internal Tag identifying the Ok variant. */
|
|
2
|
+
const OkTypeTagName = 'ts-data-forge::Result.ok';
|
|
3
|
+
/** @internal Tag identifying the Warn variant. */
|
|
4
|
+
const WarnTypeTagName = 'ts-data-forge::Result.warn';
|
|
5
|
+
/** @internal Tag identifying the Err variant. */
|
|
6
|
+
const ErrTypeTagName = 'ts-data-forge::Result.err';
|
|
7
|
+
|
|
8
|
+
export { ErrTypeTagName, OkTypeTagName, WarnTypeTagName };
|
|
9
|
+
//# sourceMappingURL=tag.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.mjs","sources":["../../../../src/functional/ternary-result/impl/tag.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACO,MAAM,aAAa,GACxB;AAEF;AACO,MAAM,eAAe,GAC1B;AAEF;AACO,MAAM,cAAc,GACzB;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a `TernaryResult.Err` containing the provided error value.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const failure = TernaryResult.err(new Error('missing data'));
|
|
8
|
+
*
|
|
9
|
+
* assert.strictEqual(failure.$$tag, 'ts-data-forge::Result.err');
|
|
10
|
+
* assert.ok(TernaryResult.isErr(failure));
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const err: <E>(value: E) => TernaryErr<E>;
|
|
14
|
+
//# sourceMappingURL=ternary-result-err.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-err.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,EAAG,OAAO,CAAC,KAAG,UAAU,CAAC,CAAC,CAG7C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ErrTypeTagName } from './tag.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a `TernaryResult.Err` containing the provided error value.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const failure = TernaryResult.err(new Error('missing data'));
|
|
10
|
+
*
|
|
11
|
+
* assert.strictEqual(failure.$$tag, 'ts-data-forge::Result.err');
|
|
12
|
+
* assert.ok(TernaryResult.isErr(failure));
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
const err = (value) => ({
|
|
16
|
+
$$tag: ErrTypeTagName,
|
|
17
|
+
value,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { err };
|
|
21
|
+
//# sourceMappingURL=ternary-result-err.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-err.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-err.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;;;;AAWG;MACU,GAAG,GAAG,CAAK,KAAQ,MAAqB;AACnD,IAAA,KAAK,EAAE,cAAc;IACrB,KAAK;AACN,CAAA;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type UnwrapOk } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps the Ok value or throws with the provided message.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const okValue = TernaryResult.ok('ready');
|
|
9
|
+
*
|
|
10
|
+
* assert.strictEqual(TernaryResult.expectToBe(okValue, 'missing'), 'ready');
|
|
11
|
+
* const expectResult = TernaryResult.expectToBe<string>('needs value');
|
|
12
|
+
*
|
|
13
|
+
* assert.throws(() => expectResult(TernaryResult.err('oops')), /needs value/u);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function expectToBe<R extends UnknownTernaryResult>(result: R, message: string): UnwrapOk<R>;
|
|
17
|
+
export declare function expectToBe<S>(message: string): <W, E>(result: TernaryResult<S, E, W>) => S;
|
|
18
|
+
//# sourceMappingURL=ternary-result-expect-to-be.d.mts.map
|