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 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-expect-to-be.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,oBAAoB,EACvD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGf,wBAAgB,UAAU,CAAC,CAAC,EAC1B,OAAO,EAAE,MAAM,GACd,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isOk } from './ternary-result-is-ok.mjs';
|
|
2
|
+
import { unwrapOk } from './ternary-result-unwrap-ok.mjs';
|
|
3
|
+
|
|
4
|
+
function expectToBe(...args) {
|
|
5
|
+
switch (args.length) {
|
|
6
|
+
case 2: {
|
|
7
|
+
const [result, message] = args;
|
|
8
|
+
return expectImpl(result, message);
|
|
9
|
+
}
|
|
10
|
+
case 1: {
|
|
11
|
+
const [message] = args;
|
|
12
|
+
return (result) => expectImpl(result, message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const expectImpl = (result, message) => {
|
|
17
|
+
if (isOk(result)) {
|
|
18
|
+
return unwrapOk(result);
|
|
19
|
+
}
|
|
20
|
+
throw new Error(message);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { expectToBe };
|
|
24
|
+
//# sourceMappingURL=ternary-result-expect-to-be.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-expect-to-be.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AA4BM,SAAU,UAAU,CACxB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;AAC9B,YAAA,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;QACpC;QACA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YACtB,OAAO,CAAC,MAAS,KAAK,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;QACnD;;AAEJ;AAEA,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,OAAe,KACA;AACf,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;AAChB,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Applies a function returning a `TernaryResult` to the Ok variant.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const parse = (value: string): TernaryResult<number, string, string> =>
|
|
9
|
+
* Number.isNaN(Number(value))
|
|
10
|
+
* ? TernaryResult.err('NaN')
|
|
11
|
+
* : TernaryResult.ok(Number(value));
|
|
12
|
+
*
|
|
13
|
+
* const doubled = TernaryResult.flatMap(TernaryResult.ok('3'), (text) =>
|
|
14
|
+
* TernaryResult.map(parse(text), (num) => num * 2),
|
|
15
|
+
* );
|
|
16
|
+
* const warnPassthrough = TernaryResult.flatMap(
|
|
17
|
+
* TernaryResult.warn('3', 'retry'),
|
|
18
|
+
* parse,
|
|
19
|
+
* );
|
|
20
|
+
* const errPassthrough = TernaryResult.flatMap(TernaryResult.err('oops'), parse);
|
|
21
|
+
*
|
|
22
|
+
* assert.deepStrictEqual(doubled, TernaryResult.ok(6));
|
|
23
|
+
* assert.deepStrictEqual(warnPassthrough, TernaryResult.warn(3, 'retry'));
|
|
24
|
+
* assert.deepStrictEqual(errPassthrough, TernaryResult.err('oops'));
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function flatMap<R extends UnknownTernaryResult, S2, W2, E2>(result: R, flatMapFn: (value: UnwrapOk<R>) => TernaryResult<S2, E2, W2>): TernaryResult<S2, E2 | UnwrapErr<R>, W2 | UnwrapWarn<R>>;
|
|
28
|
+
export declare function flatMap<S, S2, W2, E2>(flatMapFn: (value: S) => TernaryResult<S2, E2, W2>): <W, E>(result: TernaryResult<S, E, W>) => TernaryResult<S2, E | E2, W | W2>;
|
|
29
|
+
//# sourceMappingURL=ternary-result-flat-map.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-flat-map.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-flat-map.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,oBAAoB,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAChE,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAC3D,aAAa,CAAC,EAAE,EAAE,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAG5D,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EACnC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GACjD,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isOk } from './ternary-result-is-ok.mjs';
|
|
2
|
+
import { isWarn } from './ternary-result-is-warn.mjs';
|
|
3
|
+
import { warn } from './ternary-result-warn.mjs';
|
|
4
|
+
|
|
5
|
+
function flatMap(...args) {
|
|
6
|
+
switch (args.length) {
|
|
7
|
+
case 2: {
|
|
8
|
+
const [result, flatMapFn] = args;
|
|
9
|
+
return flatMapImpl(result, flatMapFn);
|
|
10
|
+
}
|
|
11
|
+
case 1: {
|
|
12
|
+
const [flatMapFn] = args;
|
|
13
|
+
return (result) => flatMapImpl(result, flatMapFn);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const flatMapImpl = (result, flatMapFn) => {
|
|
18
|
+
if (isOk(result)) {
|
|
19
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
20
|
+
return flatMapFn(result.value);
|
|
21
|
+
}
|
|
22
|
+
if (isWarn(result)) {
|
|
23
|
+
const next = flatMapFn(
|
|
24
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
25
|
+
result.value);
|
|
26
|
+
if (isOk(next)) {
|
|
27
|
+
return warn(next.value,
|
|
28
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
29
|
+
result.warning);
|
|
30
|
+
}
|
|
31
|
+
if (isWarn(next)) {
|
|
32
|
+
return warn(next.value, next.warning);
|
|
33
|
+
}
|
|
34
|
+
return next;
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { flatMap };
|
|
41
|
+
//# sourceMappingURL=ternary-result-flat-map.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-flat-map.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-flat-map.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAwCM,SAAU,OAAO,CACrB,GAAG,IAKwE,EAAA;AAI3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;AAChC,YAAA,OAAO,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC;QACvC;QACA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI;YACxB,OAAO,CAAC,MAAS,KAAK,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC;QACtD;;AAEJ;AAEA,MAAM,WAAW,GAAG,CAClB,MAAS,EACT,SAA4D,KACA;AAC5D,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;;AAEhB,QAAA,OAAO,SAAS,CAAC,MAAM,CAAC,KAAoB,CAAC;IAC/C;AAEA,IAAA,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;QAClB,MAAM,IAAI,GAAG,SAAS;;QAEpB,MAAM,CAAC,KAAoB,CAC5B;AAED,QAAA,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE;AACd,YAAA,OAAO,IAAI,CACT,IAAI,CAAC,KAAK;;YAEV,MAAM,CAAC,OAAwB,CAChC;QACH;AAEA,QAAA,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE;YAChB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAoC,CAAC;QACpE;AAEA,QAAA,OAAO,IAAI;IACb;;AAGA,IAAA,OAAO,MAAuC;AAChD,CAAC;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Applies the provided mapper based on the current variant.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const okFold = TernaryResult.fold(
|
|
9
|
+
* TernaryResult.ok(2),
|
|
10
|
+
* (value) => value * 2,
|
|
11
|
+
* (warn: string) => warn.length,
|
|
12
|
+
* (error: string) => error.toUpperCase(),
|
|
13
|
+
* );
|
|
14
|
+
* const warnFold = TernaryResult.fold(
|
|
15
|
+
* TernaryResult.warn(2, 'spike'),
|
|
16
|
+
* (value: number) => value,
|
|
17
|
+
* (warn: string) => warn.toUpperCase(),
|
|
18
|
+
* (error: string) => error,
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* assert.deepStrictEqual(okFold, TernaryResult.ok(4));
|
|
22
|
+
* assert.deepStrictEqual(warnFold, TernaryResult.warn(2, 'SPIKE'));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function fold<R extends UnknownTernaryResult, S2, W2, E2>(result: R, mapOk: (value: UnwrapOk<R>) => S2, mapWarn: (value: UnwrapWarn<R>) => W2, mapErr: (error: UnwrapErr<R>) => E2): TernaryResult<S2, E2, W2>;
|
|
26
|
+
export declare function fold<S, W, E, S2, W2, E2>(mapOk: (value: S) => S2, mapWarn: (value: W) => W2, mapErr: (error: E) => E2): (result: TernaryResult<S, E, W>) => TernaryResult<S2, E2, W2>;
|
|
27
|
+
//# sourceMappingURL=ternary-result-fold.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-fold.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-fold.mts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,oBAAoB,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAC7D,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,EACjC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,EACrC,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,GAClC,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAG7B,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EACtC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EACvB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EACzB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GACvB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { err } from './ternary-result-err.mjs';
|
|
2
|
+
import { isOk } from './ternary-result-is-ok.mjs';
|
|
3
|
+
import { isWarn } from './ternary-result-is-warn.mjs';
|
|
4
|
+
import { ok } from './ternary-result-ok.mjs';
|
|
5
|
+
import { warn } from './ternary-result-warn.mjs';
|
|
6
|
+
|
|
7
|
+
function fold(...args) {
|
|
8
|
+
switch (args.length) {
|
|
9
|
+
case 4: {
|
|
10
|
+
const [result, mapOk, mapWarn, mapErr] = args;
|
|
11
|
+
return foldImpl(result, mapOk, mapWarn, mapErr);
|
|
12
|
+
}
|
|
13
|
+
case 3: {
|
|
14
|
+
const [mapOk, mapWarn, mapErr] = args;
|
|
15
|
+
return (result) => foldImpl(result, mapOk, mapWarn, mapErr);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const foldImpl = (result, mapOk, mapWarnFn, mapErrFn) => {
|
|
20
|
+
if (isOk(result)) {
|
|
21
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
22
|
+
return ok(mapOk(result.value));
|
|
23
|
+
}
|
|
24
|
+
if (isWarn(result)) {
|
|
25
|
+
return warn(
|
|
26
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
27
|
+
mapOk(result.value),
|
|
28
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
29
|
+
mapWarnFn(result.warning));
|
|
30
|
+
}
|
|
31
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
32
|
+
return err(mapErrFn(result.value));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { fold };
|
|
36
|
+
//# sourceMappingURL=ternary-result-fold.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-fold.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-fold.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AA4CM,SAAU,IAAI,CAClB,GAAG,IAWE,EAAA;AAEL,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;YACN,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,IAAI;YAC7C,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC;QACjD;QACA,KAAK,CAAC,EAAE;YACN,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,IAAI;AACrC,YAAA,OAAO,CAAC,MAAS,KAAK,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC;QAChE;;AAEJ;AAEA,MAAM,QAAQ,GAAG,CACf,MAAS,EACT,KAAiC,EACjC,SAAyC,EACzC,QAAqC,KACR;AAC7B,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;;QAEhB,OAAO,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAoB,CAAC,CAAC;IAC/C;AAEA,IAAA,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;AAClB,QAAA,OAAO,IAAI;;AAET,QAAA,KAAK,CAAC,MAAM,CAAC,KAAoB,CAAC;;AAElC,QAAA,SAAS,CAAC,MAAM,CAAC,OAAwB,CAAC,CAC3C;IACH;;IAGA,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC;AACpD,CAAC;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @internal Utility type extracting the resolved value from a Promise. */
|
|
2
|
+
type UnwrapPromise<P extends Promise<unknown>> = P extends Promise<infer V> ? V : never;
|
|
3
|
+
/**
|
|
4
|
+
* Converts a Promise into a Promise that resolves to a `TernaryResult`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const resolved = await TernaryResult.fromPromise(Promise.resolve('ok'));
|
|
10
|
+
* const rejected = await TernaryResult.fromPromise(
|
|
11
|
+
* Promise.reject(new Error('fail')),
|
|
12
|
+
* );
|
|
13
|
+
*
|
|
14
|
+
* assert.deepStrictEqual(resolved, TernaryResult.ok('ok'));
|
|
15
|
+
* assert.ok(TernaryResult.isErr(rejected));
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const fromPromise: <P extends Promise<unknown>>(promise: P) => Promise<TernaryResult<UnwrapPromise<P>, unknown, never>>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=ternary-result-from-promise.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-from-promise.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-from-promise.mts"],"names":[],"mappings":"AAGA,2EAA2E;AAC3E,KAAK,aAAa,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,IAC3C,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,EACpD,SAAS,CAAC,KACT,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAEoB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { err } from './ternary-result-err.mjs';
|
|
2
|
+
import { ok } from './ternary-result-ok.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a Promise into a Promise that resolves to a `TernaryResult`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const resolved = await TernaryResult.fromPromise(Promise.resolve('ok'));
|
|
11
|
+
* const rejected = await TernaryResult.fromPromise(
|
|
12
|
+
* Promise.reject(new Error('fail')),
|
|
13
|
+
* );
|
|
14
|
+
*
|
|
15
|
+
* assert.deepStrictEqual(resolved, TernaryResult.ok('ok'));
|
|
16
|
+
* assert.ok(TernaryResult.isErr(rejected));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
const fromPromise = (promise) =>
|
|
20
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
21
|
+
promise.then((value) => ok(value)).catch(err);
|
|
22
|
+
|
|
23
|
+
export { fromPromise };
|
|
24
|
+
//# sourceMappingURL=ternary-result-from-promise.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-from-promise.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-from-promise.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;AAcG;AACI,MAAM,WAAW,GAAG,CACzB,OAAU;AAEV;AACA,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,KAAK,CAAgC,CAAC,CAAC,KAAK,CAAC,GAAG;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a potentially-throwing function in a `TernaryResult`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const success = TernaryResult.fromThrowable(() => 1 + 1);
|
|
8
|
+
* const failure = TernaryResult.fromThrowable(() => {
|
|
9
|
+
* throw new Error('boom');
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* assert.deepStrictEqual(success, TernaryResult.ok(2));
|
|
13
|
+
* assert.ok(TernaryResult.isErr(failure));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const fromThrowable: <T>(fn: () => T) => TernaryResult<T, Error, never>;
|
|
17
|
+
//# sourceMappingURL=ternary-result-from-throwable.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-from-throwable.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-from-throwable.mts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAC7B,IAAI,MAAM,CAAC,KACV,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAS/B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { unknownToString } from '../../../others/unknown-to-string.mjs';
|
|
2
|
+
import { err } from './ternary-result-err.mjs';
|
|
3
|
+
import { ok } from './ternary-result-ok.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a potentially-throwing function in a `TernaryResult`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const success = TernaryResult.fromThrowable(() => 1 + 1);
|
|
12
|
+
* const failure = TernaryResult.fromThrowable(() => {
|
|
13
|
+
* throw new Error('boom');
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* assert.deepStrictEqual(success, TernaryResult.ok(2));
|
|
17
|
+
* assert.ok(TernaryResult.isErr(failure));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
const fromThrowable = (fn) => {
|
|
21
|
+
try {
|
|
22
|
+
return ok(fn());
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (Error.isError(error)) {
|
|
26
|
+
return err(error);
|
|
27
|
+
}
|
|
28
|
+
return err(new Error(unknownToString(error)));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { fromThrowable };
|
|
33
|
+
//# sourceMappingURL=ternary-result-from-throwable.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-from-throwable.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-from-throwable.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;AAcG;AACI,MAAM,aAAa,GAAG,CAC3B,EAAW,KACuB;AAClC,IAAA,IAAI;AACF,QAAA,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;IACjB;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,YAAA,OAAO,GAAG,CAAC,KAAK,CAAC;QACnB;QACA,OAAO,GAAG,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C;AACF;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type NarrowToErr } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for the Err variant.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const maybeErr = TernaryResult.err('boom') as TernaryResult<
|
|
9
|
+
* number,
|
|
10
|
+
* string,
|
|
11
|
+
* string
|
|
12
|
+
* >;
|
|
13
|
+
*
|
|
14
|
+
* if (TernaryResult.isErr(maybeErr)) {
|
|
15
|
+
* assert.strictEqual(maybeErr.value, 'boom');
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const isErr: <R extends UnknownTernaryResult>(result: R) => result is NarrowToErr<R>;
|
|
20
|
+
//# sourceMappingURL=ternary-result-is-err.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-err.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,oBAAoB,EAClD,QAAQ,CAAC,KACR,MAAM,IAAI,WAAW,CAAC,CAAC,CAAoC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ErrTypeTagName } from './tag.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type guard for the Err variant.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const maybeErr = TernaryResult.err('boom') as TernaryResult<
|
|
10
|
+
* number,
|
|
11
|
+
* string,
|
|
12
|
+
* string
|
|
13
|
+
* >;
|
|
14
|
+
*
|
|
15
|
+
* if (TernaryResult.isErr(maybeErr)) {
|
|
16
|
+
* assert.strictEqual(maybeErr.value, 'boom');
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
const isErr = (result) => result.$$tag === ErrTypeTagName;
|
|
21
|
+
|
|
22
|
+
export { isErr };
|
|
23
|
+
//# sourceMappingURL=ternary-result-is-err.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-err.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-err.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,KAAK,GAAG,CACnB,MAAS,KACoB,MAAM,CAAC,KAAK,KAAK;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type NarrowToOk } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for the Ok variant.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const maybeNumber = TernaryResult.ok(42) as TernaryResult<
|
|
9
|
+
* number,
|
|
10
|
+
* string,
|
|
11
|
+
* string
|
|
12
|
+
* >;
|
|
13
|
+
*
|
|
14
|
+
* if (TernaryResult.isOk(maybeNumber)) {
|
|
15
|
+
* const value: number = maybeNumber.value;
|
|
16
|
+
* assert.strictEqual(value, 42);
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const isOk: <R extends UnknownTernaryResult>(result: R) => result is NarrowToOk<R>;
|
|
21
|
+
//# sourceMappingURL=ternary-result-is-ok.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-ok.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-ok.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,oBAAoB,EACjD,QAAQ,CAAC,KACR,MAAM,IAAI,UAAU,CAAC,CAAC,CAAmC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OkTypeTagName } from './tag.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type guard for the Ok variant.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const maybeNumber = TernaryResult.ok(42) as TernaryResult<
|
|
10
|
+
* number,
|
|
11
|
+
* string,
|
|
12
|
+
* string
|
|
13
|
+
* >;
|
|
14
|
+
*
|
|
15
|
+
* if (TernaryResult.isOk(maybeNumber)) {
|
|
16
|
+
* const value: number = maybeNumber.value;
|
|
17
|
+
* assert.strictEqual(value, 42);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const isOk = (result) => result.$$tag === OkTypeTagName;
|
|
22
|
+
|
|
23
|
+
export { isOk };
|
|
24
|
+
//# sourceMappingURL=ternary-result-is-ok.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-ok.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-ok.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;AAiBG;AACI,MAAM,IAAI,GAAG,CAClB,MAAS,KACmB,MAAM,CAAC,KAAK,KAAK;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the provided value is a {@link TernaryResult}.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const okValue = TernaryResult.ok('done');
|
|
8
|
+
* const warnValue = TernaryResult.warn('done', 'retry later');
|
|
9
|
+
* const notResult = { $$tag: 'ts-data-forge::Result.ok' };
|
|
10
|
+
*
|
|
11
|
+
* assert.ok(TernaryResult.isTernaryResult(okValue));
|
|
12
|
+
* assert.ok(TernaryResult.isTernaryResult(warnValue));
|
|
13
|
+
* assert.ok(!TernaryResult.isTernaryResult(notResult));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const isTernaryResult: (maybeResult: unknown) => maybeResult is UnknownTernaryResult;
|
|
17
|
+
//# sourceMappingURL=ternary-result-is-ternary-result.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-ternary-result.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAC1B,aAAa,OAAO,KACnB,WAAW,IAAI,oBAMuB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { hasKey } from '../../../guard/has-key.mjs';
|
|
2
|
+
import { isRecord } from '../../../guard/is-record.mjs';
|
|
3
|
+
import { WarnTypeTagName, OkTypeTagName, ErrTypeTagName } from './tag.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks whether the provided value is a {@link TernaryResult}.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const okValue = TernaryResult.ok('done');
|
|
12
|
+
* const warnValue = TernaryResult.warn('done', 'retry later');
|
|
13
|
+
* const notResult = { $$tag: 'ts-data-forge::Result.ok' };
|
|
14
|
+
*
|
|
15
|
+
* assert.ok(TernaryResult.isTernaryResult(okValue));
|
|
16
|
+
* assert.ok(TernaryResult.isTernaryResult(warnValue));
|
|
17
|
+
* assert.ok(!TernaryResult.isTernaryResult(notResult));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
const isTernaryResult = (maybeResult) => isRecord(maybeResult) &&
|
|
21
|
+
hasKey(maybeResult, '$$tag') &&
|
|
22
|
+
hasKey(maybeResult, 'value') &&
|
|
23
|
+
((maybeResult.$$tag === WarnTypeTagName && hasKey(maybeResult, 'warning')) ||
|
|
24
|
+
maybeResult.$$tag === OkTypeTagName ||
|
|
25
|
+
maybeResult.$$tag === ErrTypeTagName);
|
|
26
|
+
|
|
27
|
+
export { isTernaryResult };
|
|
28
|
+
//# sourceMappingURL=ternary-result-is-ternary-result.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-ternary-result.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAGA;;;;;;;;;;;;;;AAcG;AACI,MAAM,eAAe,GAAG,CAC7B,WAAoB,KAEpB,QAAQ,CAAC,WAAW,CAAC;AACrB,IAAA,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC;AAC5B,IAAA,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC;AAC5B,KAAC,CAAC,WAAW,CAAC,KAAK,KAAK,eAAe,IAAI,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC;QACvE,WAAW,CAAC,KAAK,KAAK,aAAa;AACnC,QAAA,WAAW,CAAC,KAAK,KAAK,cAAc;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type NarrowToWarn } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for the Warn variant.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const maybeWarn = TernaryResult.warn('value', 'check logs') as TernaryResult<
|
|
9
|
+
* string,
|
|
10
|
+
* string,
|
|
11
|
+
* string
|
|
12
|
+
* >;
|
|
13
|
+
*
|
|
14
|
+
* if (TernaryResult.isWarn(maybeWarn)) {
|
|
15
|
+
* assert.strictEqual(maybeWarn.value, 'value');
|
|
16
|
+
* assert.strictEqual(maybeWarn.warning, 'check logs');
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const isWarn: <R extends UnknownTernaryResult>(result: R) => result is NarrowToWarn<R>;
|
|
21
|
+
//# sourceMappingURL=ternary-result-is-warn.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-warn.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-warn.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,oBAAoB,EACnD,QAAQ,CAAC,KACR,MAAM,IAAI,YAAY,CAAC,CAAC,CAAqC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WarnTypeTagName } from './tag.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type guard for the Warn variant.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const maybeWarn = TernaryResult.warn('value', 'check logs') as TernaryResult<
|
|
10
|
+
* string,
|
|
11
|
+
* string,
|
|
12
|
+
* string
|
|
13
|
+
* >;
|
|
14
|
+
*
|
|
15
|
+
* if (TernaryResult.isWarn(maybeWarn)) {
|
|
16
|
+
* assert.strictEqual(maybeWarn.value, 'value');
|
|
17
|
+
* assert.strictEqual(maybeWarn.warning, 'check logs');
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const isWarn = (result) => result.$$tag === WarnTypeTagName;
|
|
22
|
+
|
|
23
|
+
export { isWarn };
|
|
24
|
+
//# sourceMappingURL=ternary-result-is-warn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-is-warn.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-is-warn.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;AAiBG;AACI,MAAM,MAAM,GAAG,CACpB,MAAS,KACqB,MAAM,CAAC,KAAK,KAAK;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Maps the Err variant while leaving Ok/Warn untouched.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const errValue = TernaryResult.err('boom');
|
|
9
|
+
* const mappedErr = TernaryResult.mapErr(errValue, (error) =>
|
|
10
|
+
* error.toUpperCase(),
|
|
11
|
+
* );
|
|
12
|
+
* const warnPassthrough = TernaryResult.mapErr(
|
|
13
|
+
* TernaryResult.warn(2, 'slow'),
|
|
14
|
+
* (error: string) => `${error}!`,
|
|
15
|
+
* );
|
|
16
|
+
*
|
|
17
|
+
* assert.deepStrictEqual(mappedErr, TernaryResult.err('BOOM'));
|
|
18
|
+
* assert.deepStrictEqual(warnPassthrough, TernaryResult.warn(2, 'slow'));
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function mapErr<R extends UnknownTernaryResult, E2>(result: R, mapFn: (error: UnwrapErr<R>) => E2): TernaryResult<UnwrapOk<R>, E2, UnwrapWarn<R>>;
|
|
22
|
+
export declare function mapErr<E, E2>(mapFn: (error: E) => E2): <S, W>(result: TernaryResult<S, E, W>) => TernaryResult<S, E2, W>;
|
|
23
|
+
//# sourceMappingURL=ternary-result-map-err.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-map-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-map-err.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,oBAAoB,EAAE,EAAE,EACvD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,GACjC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAGjD,wBAAgB,MAAM,CAAC,CAAC,EAAE,EAAE,EAC1B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GACtB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { err } from './ternary-result-err.mjs';
|
|
2
|
+
import { isErr } from './ternary-result-is-err.mjs';
|
|
3
|
+
|
|
4
|
+
function mapErr(...args) {
|
|
5
|
+
switch (args.length) {
|
|
6
|
+
case 2: {
|
|
7
|
+
const [result, mapFn] = args;
|
|
8
|
+
return mapErrImpl(result, mapFn);
|
|
9
|
+
}
|
|
10
|
+
case 1: {
|
|
11
|
+
const [mapFn] = args;
|
|
12
|
+
return (result) => mapErrImpl(result, mapFn);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const mapErrImpl = (result, mapFn) => {
|
|
17
|
+
if (isErr(result)) {
|
|
18
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
19
|
+
return err(mapFn(result.value));
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { mapErr };
|
|
26
|
+
//# sourceMappingURL=ternary-result-map-err.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-map-err.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-map-err.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAiCM,SAAU,MAAM,CACpB,GAAG,IAE8C,EAAA;AAIjD,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI;AAC5B,YAAA,OAAO,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC;QAClC;QACA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;YACpB,OAAO,CAAC,MAAS,KAAK,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC;QACjD;;AAEJ;AAEA,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,KAAkC,KACe;AACjD,IAAA,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;;QAEjB,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC;IACjD;;AAGA,IAAA,OAAO,MAAuD;AAChE,CAAC;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Maps the Warn variant while leaving Ok/Err untouched.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const warnValue = TernaryResult.warn(2, 'slow');
|
|
9
|
+
* const mappedWarn = TernaryResult.mapWarn(warnValue, (warning) => `${warning}!`);
|
|
10
|
+
* const okPassthrough = TernaryResult.mapWarn(
|
|
11
|
+
* TernaryResult.ok(3),
|
|
12
|
+
* (value: number) => value * 2,
|
|
13
|
+
* );
|
|
14
|
+
*
|
|
15
|
+
* assert.deepStrictEqual(mappedWarn, TernaryResult.warn(2, 'slow!'));
|
|
16
|
+
* assert.deepStrictEqual(okPassthrough, TernaryResult.ok(3));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function mapWarn<R extends UnknownTernaryResult, W2>(result: R, mapFn: (warning: UnwrapWarn<R>) => W2): TernaryResult<UnwrapOk<R>, UnwrapErr<R>, W2>;
|
|
20
|
+
export declare function mapWarn<W, W2>(mapFn: (warning: W) => W2): <S, E>(result: TernaryResult<S, E, W>) => TernaryResult<S, E, W2>;
|
|
21
|
+
//# sourceMappingURL=ternary-result-map-warn.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary-result-map-warn.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-map-warn.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,oBAAoB,EAAE,EAAE,EACxD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,GACpC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAGhD,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAC3B,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,GACxB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC"}
|